Reputation: 41
What do people use to handle javascript module dependencies? I've been using dojo.require() build system. It's pretty good so far. But I'm just wondering if there are alternatives?
Require.JS came up as a popular hit, but I find it too rudimentary; it will only allow me to specify an array of files before the wrapping closure block. Tell me if I am mistaken, but is this array recursive? or is it only one-level.
Thanks!
Upvotes: 1
Views: 385
Reputation: 22555
RequireJS will recurse dependencies as necessary, so if you define one module that requires another module and that module in turn requires another all dependencies from all modules will be loaded
Upvotes: 1
Reputation: 1978
You might want to check on AMD system, available in Dojo since 1.7 more info here : http://unscriptable.com/code/Using-AMD-loaders/
To see a real world example, you can check dijits in dojo 1.7 :)
Hope this helps
Upvotes: 5
Reputation: 187302
Require.js is cool, yes. It's one level deep, but modules you require can also have dependencies of their own. So if A
depends on B
and C
, then all you have to do is require A
in order to load A
B
and C
.
Upvotes: 3