The Commonjs loading module is synchronous, and the AMD module is added to the non-synchronous, allowing for the designation of the callback function. Since Nodejs is mainly used for server programming, module files are generally present in the local, so load quickly, do not need to consider the non-synchronous loading, with COMMONJS can. But the browser is loaded from the server module, which requires the use of non-synchronous mode, GU Select AMD will be appropriate.
AMD uses the Define method to define modules such as:
1 define (['./b '],function () { 2 var a=function() {3 }; 4 return {5 a:a6 }; 7 })
AMD is allowed to output modules compatible with COMMONJS, so the notation can be changed to:
1 define (Funciton (require,exports,module) {2 var a=require ('./b '); 3 Exports. c=function() {4 }5 })
Nodejs Study Notes -2.AMD specification