Created
November 15, 2012 18:10
-
-
Save rauschma/4080200 to your computer and use it in GitHub Desktop.
Modules: AMD versus CJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//--------------------- | |
// AMD | |
define(["foo", "bar", "baz"], function (foo, bar, baz) { | |
return { | |
func: function (...) { ... } | |
}; | |
}); | |
//--------------------- | |
// CJS/Node.js | |
var foo = require("foo"); | |
var bar = require("bar"); | |
var baz = require("baz"); | |
exports.func = function (...) { ... }; |
I don't think the syntax differences are important. What is important: browsers require async and async is harder to use. Syntax is a side effect: browsers require async and async in JS requires callbacks. Hence AMD.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
exports.func
is evil. Usemodule.exports = function () {}