Currently the AMD syntax requires a large amount of repetition just to always get access to our required modules, this could be simplified by doing the following:
/**
* Defines a new module
*
* @param {String} name An optional name for the module || filename.
* @param {Array} dependencies Dependencies for the module, can be omitted.
* @param {Function|Object} module The Modules code.
**/
define([name,] [dependencies,] module);
I propose that the signature of the module argument be changed such that if module is a function, then the signature is:
function(dep1, dep2, dep3, dep4)
The changes here are that I've removed the require and exports members,
instead, you would attach methods to the this variable. Example:
define('alpha', ['beta', 'gamma'], function(beta, gamma) {
this.verb = function() {
return beta.foo;
}
});
Essentially, if you're needing to call require() then you should really be defining that as a module dependency.
Likewise for object literal definitions:
define('alpha', ['beta', 'gamma'], {
verb: function() {
return this.dependencies.beta.foo;
}
});
Actually it won't, as the signature is missing the exports and require variables.
vs.