The modular front-end development specifications

1 Overview

Are often faced with the traditional development model of a number of issues, such as naming conflicts, file dependence, it is necessary to solve the problem through modularity.

Modular:  is a function of the individual encapsulated into a module, isolation between modules, but can be disclosed through a specific internal members interfaces, may be dependent on other modules.
Benefits:  to facilitate code reuse, which commission the development efficiency, and easy ongoing maintenance.

2. The browser modular specification

AMD  typical representatives  Require.js
CMD  typical representatives  Sea.js

3. The modular server specifications

CommonJS

  1. Into a single module and file module package
  2. Export module members: module.exports  and  exports
  3. Import module members: the require ( 'module identifier')

Modular 4.ES6

Prerequisite: Before ES6 modular specification birth, Javascript attempt to raise community although AMD, CMD, and CommonJS and other modular specification, but because of their own there are some differences and limitations, not the browser and server versatile modular standard ,E.g:

  • AMD  and  CMD  only applies to browser-side  Javascript  modular
  • CommonJS  only applies to server-side  Javascript  modular

Therefore, the definition of the ES6 modular specification, is browser and server versatile modular development specifications.

ES6 modular specification defines:

    1. Every  JS  file is a separate module
    2. Import module members to use  import  keywords
    3. Exposure module members to use  export  keyword

 

Guess you like

Origin www.cnblogs.com/-muzi/p/11898977.html