3 ms·
> Duplication of module dependencies is also tedious and error-prone. You can combine these with RequireJS as well. Instead of: define(['a', 'b', 'c'], func
by stusmith1977 14y ago
> Duplication of module dependencies is also tedious and error-prone.
You can combine these with RequireJS as well. Instead of:
define(['a', 'b', 'c'], function () {
var a = require('a');
var b = require('b');
var c = require('c');
...
});
You can instead just do:
define(['a', 'b', 'c'], function (a, b, c) {
...
});
- base698 14y agoOr: define(function(require) { var a = require('a'); var b = require('b'); var c = require('c'); ... });
- nickfisher 14y agoThis approach does actually address a lot of the complaints: - Boilerplate is greatly reduced (though still present) - Way less error-prone since you're not relying on keeping two separate lists of dependencies in same the order But, it still does require rewriting before use (to add the module name), so I don't see a huge win here either way. I'll also point out that this "sugared" syntax was added to requirejs after we started developing. If it were there at the start, perhaps we would have used that instead.