CommonJS Modules/1.1 http://wiki.commonjs.org/wiki/Modules/1.1
CommonJS Modules/2.0 (draft) http://www.page.ca/~wes/CommonJS/modules-2.0-draft8/
AMD Modules https://github.com/amdjs/amdjs-api/wiki/AMD
Harmony Modules (note: Not backwards-compatible with ES3) http://wiki.ecmascript.org/doku.php?id=harmony:modules
// YUI
YUI.add([identifier], function(Y){
// Export Y.foobar
Y.foobar = "YUI!";
// Export Y.baz as a concatenation of two imported values
Y.baz = Y.fizz + Y.buzz;
}, [version,] [config/dependencies] );
// AMD
define([name,] ["dependencyA", "dependencyB"], function(dependencyA, dependencyB){
// Always returns an object
return {…};
});
// CommonJS Modules/1.1 + Wrapper
define(function(require, exports, module) {
//Require is passed in as a local
var someModule = require("someModule");
// Exports is what you hang values/functions off of, similar to Y.
exports.baz = someModule.bop;
exports.fizzbuzz = function() {
...
}
});
// CommonJS Modules/2.0
module.declare([identifier,] function(require, exports, module) {
exports.hello = function() {
return "Hello World";
}
});
- http://unscriptable.com/code/Using%2DAMD%2Dloaders/#20
- http://unscriptable.com/code/AMD%2Dmodule%2Dpatterns/#25
There are a few issues, but seems to work reasonably well and is a nice proof of concept. I'll ask if he is actually using this in a live application. https://github.com/WilcoFiers/UseYUI-for-RequireJS
- http://groups.google.com/group/amd-implement
- http://groups.google.com/group/requirejs
- http://groups.google.com/group/commonjs
AMD supported in Node.js (then later removed) http://groups.google.com/group/nodejs-dev/browse_thread/thread/c084c613c4cb9363
AMD no longer a CommonJS spec http://groups.google.com/group/commonjs/browse_thread/thread/96a0963bcb4ca78f/cf73db49ce267ce1?lnk=gst#
Mikeal's thoughts on Node.js & AMD http://groups.google.com/group/commonjs/browse_thread/thread/b22da8744d9fd603/04b9fa446905474b
Perspectives on YUI's modules (hint: ctrl-f "YUI") http://requirejs.org/docs/history.html http://tagneto.blogspot.com/2011/04/on-inventing-js-module-formats-and.html