Amd, Cmd, Commonjs, ES6 import / export of similarities and differences

Amd, Cmd, Commonjs, ES6 import / export so is a modular program

1, Commonjs used in Nodejs, load modules are synchronized.

2, Amd is standardized output requirejs in the promotion process module definition, asynchronous module definition, requirejs is an implementation of this concept, like the JavaScript language to achieve ECMAScript specification.

3, Cmdisstandardized output seajs in the promotion process of the module definition is the definition of a synchronization module,seajs is a realization of the concept cmd, seajs is a module Taobao team developed js framework.

4, ES6 the introduction of import / export modular

The difference between CMD and AMD: 
1. For AMD relies module is executed in advance, delay CMD is executed. However RequireJS from 2.0, can also be changed to perform delay (depending on the writing, by no treatment). 
2.CMD respected rely nearby, AMD respected front-dependent. 
The AMD // 
DEFINE ([ './ C', '. / D'], function (C, D) { 
    // dependent outset written 
    c.test (); 
    d.test (); 
}); 
/ / the CMD 
DEFINE (function (requie, Exports, Module1) { 
    // Write dependence can be close 
    var A = the require ( './ C'); 
    c.test (); 
    ... 
    // soft dependent 
    IF (Status) { 
        var requie = D ( './ D'); 
        d.test (); 
    } 
}); 
3.AMD the api is a default when a plurality of, CMD strict distinction between single duty respected.
For example: AMD in points require global and local. Overall there is no CMD require, provided seajs.use (), by loading module system startup. CMD in each API are simple and pure. 

Guess you like

Origin www.cnblogs.com/robint/p/11308334.html