I try to make a non-AMD library loadable with dojo, I've chosen a separate folder as a new (pseudo) AMD-package and placed the files of that library in that folder, together with the main.js
file, which will get loaded by convention by the dojo loader when the package is requested. In this main.js file I simply put the names of my library files in the dependency list of the define()
call.
define([
"jquery",
"./lib/jquery-ui/jquery-ui.min",
"./the.actual.library.that.uses.the.others",
], function () {
return window.someGlobalSetByTheLibrary;
});
The problem with this is: the loading order of that dependencies depends on the network latency, it is not guaranteed to be the order they appear in the define()
.
That causes (sometimes) an error because the actual library file needs its own dependencies to be loaded first.
normalize
method in your loader and return an absolute module id with a unique postfix (which you later remove again in theload
method.) That way, you prevent caching and ensure that you get a call to load() for each of your sequential references, even if some of them occur multiple times (in different files). – Golconda