Modular notes for personal use

Insert picture description here

1. History of development

Insert picture description here

2. Modular specification

(1) [Back-end] commonJS (see node)

Insert picture description here
Insert picture description here

(2) [Front end] AMD (require)

Insert picture description here
Insert picture description here

(3) [Front end] CMD (sea is not commonly used)

Insert picture description here
Insert picture description here

(4) [Front end] ES6 (the most commonly used front end)

See es6 notesInsert picture description here

3. Summary

 The CommonJS specification is mainly used for server-side programming, and the loading module is synchronous, which is not suitable for the browser environment, because synchronization means blocking loading, and browser resources are loaded asynchronously, so there is an AMD CMD solution.
 AMD specification loads modules asynchronously in the browser environment, and multiple modules can be loaded in parallel. However, AMD specification development costs are high, code reading and writing are difficult, and the semantics of the module definition method is not smooth.
 The CMD specification is very similar to the AMD specification. Both are used for browser programming, relying on the nearest, delayed execution, and can be easily run in Node.js. However, relying on SPM packaging, the loading logic of the module is biased
 ES6 implements module functions at the level of language standards, and the implementation is quite simple, which can completely replace CommonJS and AMD specifications and become a common module solution for browsers and servers.

Guess you like

Origin blog.csdn.net/s8806479/article/details/115211857