Reputation: 2052
I have a project which is using a lot of AMD modules. How do I approach combining and minifying those modules without using the r.js optimizer? If all of my AMD modules are named, can I just safely concatenate and minify them?
Upvotes: 0
Views: 290
Reputation: 151370
If all of my AMD modules are named, can I just safely concatenate and minify them?
It depends. For simple enough setups, the answer is "yes". For instance, if you have module A
defined as define('A', ['B'], function (B) { return ... });
and B
as define('B', function () { return ... })
and the config you pass to require.config
is such that requesting the modules can be requested as A
and B
, then you could merely concatenate them and minify them with whatever tool you want. You could skip using r.js
.
For more complex setups, concatenating and minifying without using r.js
is asking for trouble. shim
configurations, for instance, require special handling. The order in which shimmed modules are put in an optimized bundle matters and r.js
creates define
stubs for them so that any dependencies they need are loaded first and anything defined in a shim's exports
option is actual exported.
Upvotes: 1