CMD
is the domestic Yuber in the development SeaJS
of the time proposed, belong to CommonJS
a specification, in addition AMD
, its framework isRequireJS。
Similarities and differences between the two:
- Both are an implementation of asynchronous (Asynchronuous Module Definition);
CMD
And is a AMD
CommonJS
normative implementation of the definition, RequireJS
and is the SeaJS
corresponding practice;
CMD
and AMD
the difference: the CMD
equivalent of on-demand loading, the definition of a module does not need to immediately set up a dependency module, when needed require can be, more convenient, but AMD
instead, the definition of modules need to develop a dependency module, and introduced into the factory by means of formal parameters.
AMD Mode definition module define ([' Dep1 ', ' Dep2 '],function (DEP1,DEP2) { //internal can only use the developed Module return function () {};}); /cmddefine (function (require,exports,module) { //here if you need an XX module, you can introduce var xx=require (' xx ');});
CMD and AMD