The AMD and CommonJS modules
As time went on, library authors joined forces and two de facto standards emerged in the JavaScript community: Asynchronous Module Definition (AMD) and CommonJS (CJS). Both of these are specifications for module types that also describe a way to load those modules and their dependencies.
AMD modules were mainly used by RequireJS (https://requirejs.org) and Dojo Toolkit (https://dojotoolkit.org) while CJS modules were initially used by Node.js before it created its own derived module specification.
CommonJS modules allow you to export symbols (variables, functions, classes, and many more) using the exports.<symbol> syntax. Both CommonJS and AMD allow you to load other modules using a require function. The specification ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access