Menu
Home Explore People Places Arts History Plants & Animals Science Life & Culture Technology
On this page
CommonJS
CommonJS was a project with the goal to establish conventions on module ecosystem for JavaScript outside of the web browser.

CommonJS is a project to standardize the module ecosystem for JavaScript outside of web browsers (e.g. on web servers or native desktop applications).

CommonJS's specification of how modules should work is widely used today for server-side JavaScript with Node.js. It is also used for browser-side JavaScript, but that code must be packaged with a transpiler since browsers don't support CommonJS. The other major module specification in use is the ECMAScript (ES) modules specification (ES6 modules aka ES2015 modules). CommonJS can be recognized by the use of the require() function and module.exports, while ES modules use import and export statements for similar (though not identical) functionality.

We don't have any images related to CommonJS yet.
We don't have any YouTube videos related to CommonJS yet.
We don't have any PDF documents related to CommonJS yet.
We don't have any Books related to CommonJS yet.
We don't have any archived web articles related to CommonJS yet.

History

The project was started by Mozilla engineer Kevin Dangoor in January, 2009 and initially named ServerJS.4

What I’m describing here is not a technical problem. It’s a matter of people getting together and making a decision to step forward and start building up something bigger and cooler together.

— Kevin Dangoor5

In August 2009, the project was renamed CommonJS to show the broader applicability of the APIs.6 Specifications are created and approved in an open process. A specification is only considered final after it has been finished by multiple implementations.7 CommonJS is not affiliated with the Ecma International group TC39 working on ECMAScript, but some members of TC39 participate in the project.8

Specifications

The list of specifications includes:9

Current

  • Modules/1.0 (Superseded by Modules/1.1)
  • Modules/1.1
  • Modules/1.1.1
  • Packages/1.0
  • System/1.0

Proposals

The proposals cover much more than modules. They intend to define a set of APIs that are useful both for non-web JavaScript implementations, with standardized package names to provide interoperability within the ecosystem. This goal sometimes overlaps with that of TC39, and parts such as Promises have indeed made it into ECMAScript itself.

The part after the slash is the version. When a proposal is in contention, each individual proposal (including sequential revisions from the same author) is assigned a new letter. When the main direction is known it starts being assigned numeric versions.

  • Binary/B,F
  • Console (ported from Web)
  • Encodings/A,C
  • Encodings/A
  • HTTP Client/B
  • IO/A
  • Filesystem/A,A/0
  • Modules/Async/A
  • Modules/AsynchronousDefinition
  • Modules/LoaderPlugin
  • Modules/Resources
  • Modules/SimpleAsynchronous
  • Modules/Transport/B,C,D,E
  • Modules/Wrappings
  • Modules/Wrappings-Explicit-Dependencies
  • Packages/1.1
  • Packages/AsynchronousDefinition
  • Packages/Mappings/A,B,C,D
  • Promises/B,D
  • Unit Testing/B,1.0,1.0.1

Implementations

  • Common Node10
  • CommonJS Compiler - a command-line tool that makes Common JS modules suitable for in-browser use11
  • CommonJS for PHP - a light-weight CommonJS implementation for PHP 5.3+12
  • CouchDB13
  • Flusspferd14
  • GPSEE15
  • Jetpack
  • Joyent Smart Platform16
  • JSBuild17
  • MongoDB18
  • Narwhal (JavaScript platform)19
  • Node.js (partial; synchronous)20
  • Persevere21
  • PINF JavaScript Loader22
  • PythonMonkey implements a CommonJS Modules/1.1.1 environment which can load modules written in either JavaScript or Python (or both).23
  • RingoJS24
  • SilkJS25
  • SproutCore26
  • TeaJS27
  • Wakanda28
  • XULJet29
  • QUnit

See also

References

  1. Eric Elliott (26 June 2014). Programming JavaScript Applications: Robust Web Architecture with Node, HTML5, and Modern JS Libraries. "O'Reilly Media, Inc.". pp. 87–. ISBN 978-1-4919-5027-2. 978-1-4919-5027-2

  2. Eric Elliott (26 June 2014). Programming JavaScript Applications: Robust Web Architecture with Node, HTML5, and Modern JS Libraries. "O'Reilly Media, Inc.". pp. 87–. ISBN 978-1-4919-5027-2. 978-1-4919-5027-2

  3. Mario Casciaro; Luciano Mammino (29 July 2020). Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques, 3rd Edition. Packt Publishing. p. 62. ISBN 978-1-83921-044-0. 978-1-83921-044-0

  4. "What Server Side JavaScript needs ·". www.blueskyonmars.com. Retrieved 2021-08-05. https://www.blueskyonmars.com/2009/01/29/what-server-side-javascript-needs/

  5. "What Server Side JavaScript needs ·". www.blueskyonmars.com. Retrieved 2021-08-05. https://www.blueskyonmars.com/2009/01/29/what-server-side-javascript-needs/

  6. "CommonJS: JavaScript Standard Library". www.commonjs.org. Archived from the original on 2017-11-13. Retrieved 2021-08-05. https://web.archive.org/web/20171113103236/http://www.commonjs.org/history

  7. "ProposalProcess - CommonJS Spec Wiki". wiki.commonjs.org. Retrieved 2021-08-05. http://wiki.commonjs.org/wiki/ProposalProcess

  8. "CommonJS: the First Year ·". www.blueskyonmars.com. Retrieved 2021-08-05. https://www.blueskyonmars.com/2010/01/29/commonjs-the-first-year/

  9. "JavaScript Standard Library". CommonJS. Archived from the original on 2014-05-28. Retrieved 2014-05-28. https://web.archive.org/web/20140528134342/http://www.commonjs.org/specs/

  10. "olegp/common-node @ GitHub". olegp.github.io. Retrieved 2021-08-05. https://olegp.github.io/common-node/

  11. "CommonJS Compiler - makes your Common JS modules suitable for in-browser use". dsheiko.github.io. Retrieved 2021-08-05. https://dsheiko.github.io/cjsc/

  12. "GitHub - DrBenton/CommonJSForPHP: A simple CommonJS spec implementation for PHP 5.3+". GitHub. Retrieved 2021-08-05. https://github.com/DrBenton/CommonJSForPHP

  13. "Implementations/CouchDB - CommonJS Spec Wiki". wiki.commonjs.org. Retrieved 2021-08-05. http://wiki.commonjs.org/wiki/Implementations/CouchDB

  14. "Flusspferd - CommonJS platform | Javascript bindings for C". Archived from the original on 2013-01-28. Retrieved 2017-09-19. https://web.archive.org/web/20130128180944/http://flusspferd.github.com/

  15. "Implementations/GPSEE - CommonJS Spec Wiki". wiki.commonjs.org. Retrieved 2021-08-05. http://wiki.commonjs.org/wiki/Implementations/GPSEE

  16. "Implementations/Smart - CommonJS Spec Wiki". wiki.commonjs.org. Retrieved 2021-08-05. http://wiki.commonjs.org/wiki/Implementations/Smart

  17. "Homepage - JSBuild". Archived from the original on January 4, 2011. https://web.archive.org/web/20110104112332/http://jsbuild.kodfabrik.com/

  18. "The most popular database for modern apps". MongoDB. Retrieved 2021-08-05. https://www.mongodb.com/

  19. "Implementations/Narwhal - CommonJS Spec Wiki". wiki.commonjs.org. Retrieved 2021-08-05. http://wiki.commonjs.org/wiki/Implementations/Narwhal

  20. "Implementations/node.js - CommonJS Spec Wiki". wiki.commonjs.org. Retrieved 2021-08-05. http://wiki.commonjs.org/wiki/Implementations/node.js

  21. "Implementations/Persevere - CommonJS Spec Wiki". wiki.commonjs.org. Retrieved 2021-08-05. http://wiki.commonjs.org/wiki/Implementations/Persevere

  22. "GitHub - pinf/loader-js: EARLY STALLED EXPLORATION". GitHub. 30 July 2021. Retrieved 2021-08-05. https://github.com/pinf/loader-js

  23. "Distributive-Network/PythonMonkey: A Mozilla SpiderMonkey JavaScript engine embedded into the Python VM, using the Python engine to provide the JS host environment". GitHub. 2023-07-07. Retrieved 2023-07-10. https://github.com/Distributive-Network/PythonMonkey

  24. "Implementations/RingoJS - CommonJS Spec Wiki". wiki.commonjs.org. Retrieved 2021-08-05. http://wiki.commonjs.org/wiki/Implementations/RingoJS

  25. "SilkJS WWW Site". Archived from the original on 2017-09-12. Retrieved 2012-10-19. https://web.archive.org/web/20170912134815/http://silkjs.net/

  26. "Implementations/SproutCore - CommonJS Spec Wiki". wiki.commonjs.org. Retrieved 2021-08-05. http://wiki.commonjs.org/wiki/Implementations/SproutCore

  27. "Implementations/TeaJS - CommonJS Spec Wiki". wiki.commonjs.org. Retrieved 2021-08-05. http://wiki.commonjs.org/wiki/Implementations/TeaJS

  28. SAS, Wakanda. "Wakanda FullStack JavaScript Platform". Wakanda FullStack JavaScript Platform. Retrieved 2021-08-05. https://wakanda.github.io/

  29. "Google Code Archive - Long-term storage for Google Code Project Hosting". code.google.com. Retrieved 2021-08-05. https://code.google.com/archive/p/xuljet