Skip to content

Conversation

@arctelix
Copy link

@arctelix arctelix commented Apr 1, 2014

allows for implementing a shimmed require.config() as shown in
https://github.com/requirejs/example-multipage-shim

allows for implementing a shimmed require.config() as shown in
https://github.com/requirejs/example-multipage-shim
@etianen
Copy link
Owner

etianen commented Apr 1, 2014

Thanks for putting the time into formatting this into a pull request.

I'm still a little unclear as to the mechanics behind the mode="shim" mode for require_module. In particular, this still looks like something that could be implemented using the existing tools provided by django-require. Manually putting your own require() calls in your templates seems perfectly reasonable, and more clear as to what is actually going on.

I'm also a bit confused about the keys in the REQUIRE_COMMON_MODULE setting. In particular, putting in more than one common module seems to raise an error (https://github.com/arctelix/django-require/blob/master/require/storage.py#L163). If a user needs more than one common module, they would be on their own again.

@arctelix
Copy link
Author

arctelix commented Apr 1, 2014

  1. When the module does not match the REQUIRE_COMMON_MODULE and mode='shim' the issue is that the required script tags change based on the debug setting plus the MD5 hash needs to be appended in non-debug mode. So manually entering require calls is not an option.

  2. Only the common module is specified in REQUIRE_COMMON_MODULE. Detecting more than one key is simply a way to enforce that only one common module should be specified. Nobody should need more than one common with requirejs.

  3. Any additional modules are specified in the app.build.js as regular modules (not common) that require the common module.

  4. The benefit is that requirejs is automatically included in the common module and the MD5 hash is appended to the name for cache busting.

  5. Most importantly, a data-main entry point can not be used with a shimmed config. Currently the only way to do this with django-require is to use a stand alone module which is not what is desired in this use case since full requirejs is needed, not almond.

Perhaps a skype screen cast walk through could help us go through the scenarios more efficiently?

I am certainly open to any ideas you have. This was my best try at getting the results i was looking for.

@selenite29
Copy link

👍 Indeed, multipage-shim is an important functionality of RequireJS. Thx, @arctelix, I'll try your pull request in the next few weeks.

@thijstriemstra
Copy link
Contributor

Thanks @arctelix. The travis build is failing after your fixes, could you take a look at that? https://travis-ci.org/etianen/django-require/jobs/21990149

@thijstriemstra
Copy link
Contributor

Oh I thought it was posted april this year but the PR is already a year old.

@arctelix
Copy link
Author

arctelix commented Apr 7, 2015

@thijstriemstra the code works perfectly. I suspect the travis tests failed due to lack of incorporation of the changes. I never got arround to modifying tests since etianen was not convinced it should be incorporated into the master branch.

@arctelix
Copy link
Author

arctelix commented Apr 7, 2015

@selenite29 Did you ever try this out? Curious to see if it worked out for you...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants