Fix for RequireJS - #506
Conversation
…e to actually run the code when it's loaded as AMD modules.
|
I'd love to have RequireJS support fixed, using DDT is difficult in the meantime. |
|
I'm unable to assess this pull request with my limited frontend skills. Is there a tutorial somewhere to educate myself? I've tried to find my way through http://requirejs.org/ but there's lots of material in there and most of it is lost on me. |
|
I'm not aware of any good simple tutorials to start with. But a good start And here is about the naming error that occurs: AMD loaders, such as RequireJS, works by registering a global function like Each time anyone define a module by calling the define function the So the way DDT uses today works fine for a library like jquery-cookie that |
|
Having this problem myself with upgrade to 1.0. The changes in this pull request fix the issue in an appropriate way. The alternative is to not use the UMD-inspired wrapper added here: acc0f84 and just use browser globals like mentioned in the PR. I agree with @Lundgren that most users would want DDT to work passively and not using RequireJS to register the module. It seems no other DDT module is relying on To try to explain what @Lundgren said further, RequireJS keeps an internal registry of all modules it loads itself or registered via the Basically RequireJS complains when it doesn't know how to register the module because then other modules can't consume it. The solution is to name it or remove the define call. |
|
Variations of this issue have been reported several times. I'm moving the discussion to #535. Thanks for your understanding. |
There are two problems with the current support of AMD modules in DDT when it comes to RequireJs (and probably other module loaders as well). First all modules that are imported through script tags from an html page have to be named and second is that the code never run, its only added to modules.
One possible solution is to name each module (first parameter in define()) and to call the code (the require() in base.html). But this would only work for RequireJS and no other AMD loaders (to my knowledge at least).
Perhaps the best solution is just be to go back to browser global's? DDT is only used during development anyways.