AMD
AMD is an Asynchronous Module Definition. The AMD specification was later implemented as RequireJS by the authors of this draft, so AMD is generally referred to as RequireJS.
RequireJs basic usage
Define a module and import the defined module using require
Features: Pre-dependent, pre-executed
CMD
CMD is a specification for module definition produced by SeaJS during the promotion process. SeaJS and RequireJS are called together in the module loader on the Web browser side
SeaJs basic usage
Features: Proximity dependency, delayed execution
CommonJS
The CommonJS specification is proposed by the CommonJS group to compensate for the lack of modular mechanism in JavaScript server. NodeJS and WebPack are implemented based on this specification.
CommenJs Basic usage
Resolution:
Exports and module.exports share the same address
Features:
1. All code runs in the module scope and does not pollute the global scope;
2, module loading is synchronous, that is, only after the loading is completed, it will be executed down
3. The module will be cached after the first loading, and only the cached result will be returned after the second loading
4. The value returned by require is a copy of the output value. Changes within the module do not affect this value
Module
ES6 Module is a Module system specified in ES6. Compared with the specification mentioned above, ES6 Module has more advantages and is expected to become a common Module solution for browsers and servers.
Module Basic Usage
Module features (compare commonJs)
1, commonJs is run time load, module is compile time output interface
2, commonJs is an output module that loads all interfaces in it. The Module can load one of the interfaces separately
3, commonJs outputs a copy of a value, module outputs a reference to a value, and changes within the output module affect the reference changes
4, commonJs this refers to the current module, module this refers to undefined