Open glenpike opened 9 years ago
After trying to grok a way of adding context variables into r.js' parser, I went for some lower hanging fruit and have a good workaround.
One of our apps is optimised to a single file, which means we can build it with almond.js included and use wrap: true to ensure that it contains it's own require / define variables, then we can use requirejs to load our second app in the normal way.
Not sure if this will help anyone, but that's how I sorted the problem. There will still be an impossible situation if you need multiple contexts for apps that have multiple require'd files (lazy loaders).
I had a problem with my multiversion context as referred to here https://github.com/jrburke/requirejs/issues/1302 which I managed to resolve by fixing my "main" file (https://github.com/jrburke/requirejs/issues/1302#issuecomment-78234529)
I am now having an issue with the optimization that I believe is due to contexts.
https://github.com/jrburke/r.js/pull/436 and associated require issue https://github.com/jrburke/requirejs/issues/726 are similar to mine.
I tried setting the initial require call in my main-dist file to use the specific context as with the main file:
r.js fails to optimize that file because reqTwo is not being looked for I guess? (https://groups.google.com/forum/#!topic/requirejs/C-u34eSmUgE)
I also tried wrapping my main-dist file in another file which does use this context, e.g.
So main-prod doesn't really offer any kind of solution to this problem and I reverted to just require-ing main-dist from the index.html file.
Can anyone shed light on this and if it's possible to have a specific context for my optimized files (even those which nest require calls)?