Consider this:
<script src='global.js'></script> <script src='require.js'></script> <script> require(['modular_foo'], function() {
... and in side global.js we have, by the way:
//global.js $.getScript("modular_bar.js");
where the modular_foo and modular_bar modules are anonymously defined AMD modules. Using requireJS, loading something like the above will give you our favorite error, mismatched anonymous module parameters () .
Good enough, why does this error occur (read this page if you want to find out), but the problem is that if you cannot get out of this situation?
I work on the installed platform, which gradually switches to the RJS stream, since now there is no way to use outdated scripts as built-in (some of which have AMD checks to run define ()) and our requireJS record is a point at the same time.
In some cases, I can simply place the built-in AMD-compatible scripts above the require.js library load, but this does not work if you need to load other things asynchronously (modular_bar.js) depending on the contents of the DOM. I could also just comment on all AMD checks from these files that are loaded externally into RJS, but which do not allow them to be incompatible with those ever loaded into a modular stream.
Did any of them have a similar experience? How do you mix your flows to overcome such conflicts?
source share