/ #ffffff

JS Module Systems

Systems to be aware of include CommonJS (CJS), ES2015 Modules (ESM), Asynchronous Module Definition (AMD) and Universal Module Definition (UMD).

CommonJS is what started off Node.js and does not lend itself well to the browser as it is a synchronous system

It uses the require/exports syntax.

1const someModule = require('someModule');
1function myFunc() { ... };
2
3exports.myFunc = myFunc;

AMD is a spin off from CJS but with an asynchronous module loading system.
Require.js implements AMD which can be used in the browser.


ESM is a system designed to support synchronous and asynchronous operation.

It uses the import/export syntax and is widely used for client side code.

1import someModule from 'someModule';
1function myFunc() { ... }
2
3export default myFunc

Resources