JavaScript module types
The following info is useful when you wish to use modern JavaScript tooling outside of a build system.
For instance I wanted to use a bundled React application in a static website not created using NPM.
Great account by Julia Evans.
In essence there are three main module formats:
CommonJS
- Native Node JS module system using
require()
andmodule.exports()
- Native Node JS module system using
ESModules
- The defacto standard that works in both the browser and Node.js
AMD
- A browser-friendly version of CommonJS since superseded by ESModules
Then there is UMD, Universal Module Definition. This is a wrapper that combines compatibility for multiple module systems and works with AMD, CommonJS, as well as global variables.