They have defined:
The CommonJS module proposal specifies a simple API for declaring modules server-side (and unlike AMD) attempts to cover the server side with io, filesystem, promises and more. Due to its history and implementation 3) , using CommonJS modules in the most common of JS environments, the browser, is non-optimal today.
The commonJS format is the default format used by Node.js. Therefore a CommonJS module will run on node.
Import is done via the require function
// require will import code from another module var MyDependency = require('my-dependency');
The module exposes its public api via the exports property
// module.exports will make its property public exports = ...;
There is not so much adoption of CJS in the browser because:
- many CommonJS APIs address server-oriented features that could not be implement in a browser (for example, io, system and js)
There was loader but most of them are now no more supported
- curl.js (discontinued 8 years ago - 2014)