Open ScottFreeCode opened 8 years ago
So, I've done more digging, and I suspect my initial guess was a red herring -- the onload
/onreadystatechange
for the script should fire (and provide the script's id) before setTimeout
callbacks, I should think. Rather, what's happening is that anonymous top-level define
calls never have an id set at all, thus the error. Some testing indicates this is consistent with RequireJS, only RequireJS's error says something like "Mismatches anonymous define" so it's clearer what's wrong -- something like that should probably be added.
The reason I tried using define
at the top level in the first place, however, is that there's no global require
(which is what kicks off actually resolving the modules in RequireJS). That should be easy enough to add, however, as a simple function delegating to define(<module base url>, dependencies, callback)
(or as a function that calls the underlying code from the local require in such a way that it will get the module base url as the name instead of undefined as it does when called locally).
JavaScript gives an error about trying to call
this.id.indexOf
whenthis.id
is undefined, in at least some browsers. If I'm reading the source correctly, I think that means thatloadDependencies
was called on the module before the onload event updated the module's id.I'll see if I can get a fix cooked up.