How Does Amd (require.js) Handle Multiple Classes In A Single Non-amd Js File?
I'm using a bunch of components from the MootoolsMore library which are all compiled into a single .js file. Is there a way to define the library once in the shim and have access t
Solution 1:
There is no need for "shim" functionality that is specific to RequireJS only. You can just use standard AMD loader API:
require(['js!path/to/MooToolsCore.js'], function(){
// nesting in order to insure that Moo Core runs firstrequire(['js!path/to/MooToolsMore.js'], function(){
// Your Slider and Sortables will be in global.// just use them.window.Slider(/* ... */)
})
})
Note, RequireJS does not need "js!" plugin to be declared explicitly, but, instead, just looks at the extension of the file. If it's ".js" it runs the file through "js" plugin. This is NON-standard behavior (as in not in AMD spec), but on RequireJS you should be able to replace line like:
['js!path/to/MooToolsMore.js']
with this:
['path/to/MooToolsMore.js']
Post a Comment for "How Does Amd (require.js) Handle Multiple Classes In A Single Non-amd Js File?"