CommonJS explained

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.[1] 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).[2] 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.

History

The project was started by Mozilla engineer Kevin Dangoor in January, 2009 and initially named ServerJS.[3] In August 2009, the project was renamed CommonJS to show the broader applicability of the APIs.[4] Specifications are created and approved in an open process. A specification is only considered final after it has been finished by multiple implementations.[5] CommonJS is not affiliated with the Ecma International group TC39 working on ECMAScript, but some members of TC39 participate in the project.[6]

Specifications

The list of specifications includes:[7]

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.

See also

External links

Notes and References

  1. Book: Eric Elliott. Programming JavaScript Applications: Robust Web Architecture with Node, HTML5, and Modern JS Libraries. 26 June 2014. "O'Reilly Media, Inc.". 978-1-4919-5027-2. 87–.
  2. Book: Mario Casciaro. Node.js Design Patterns: Design and implement production-grade Node.js applications using proven patterns and techniques, 3rd Edition. Luciano Mammino. 29 July 2020. Packt Publishing. 978-1-83921-044-0. 62.
  3. Web site: What Server Side JavaScript needs ·. 2021-08-05. www.blueskyonmars.com.
  4. Web site: CommonJS: JavaScript Standard Library. 2021-08-05. www.commonjs.org. 2017-11-13. https://web.archive.org/web/20171113103236/http://www.commonjs.org/history. dead.
  5. Web site: ProposalProcess - CommonJS Spec Wiki. 2021-08-05. wiki.commonjs.org.
  6. Web site: CommonJS: the First Year ·. 2021-08-05. www.blueskyonmars.com.
  7. Web site: JavaScript Standard Library . https://web.archive.org/web/20140528134342/http://www.commonjs.org/specs/. 2014-05-28. CommonJS . unfit . 2014-05-28.