CommonJS

Last updated

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

Contents

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

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 Dangoor [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]

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

See also

Related Research Articles

<span class="mw-page-title-main">Document Object Model</span> Convention for representing and interacting with objects in HTML, XHTML, and XML documents

The Document Object Model (DOM) is a cross-platform and language-independent interface that treats an HTML or XML document as a tree structure wherein each node is an object representing a part of the document. The DOM represents a document with a logical tree. Each branch of the tree ends in a node, and each node contains objects. DOM methods allow programmatic access to the tree; with them one can change the structure, style or content of a document. Nodes can have event handlers attached to them. Once an event is triggered, the event handlers get executed.

<span class="mw-page-title-main">JavaScript</span> High-level programming language

JavaScript, often abbreviated as JS, is a programming language and core technology of the Web, alongside HTML and CSS. 99% of websites use JavaScript on the client side for webpage behavior.

ECMAScript is a standard for scripting languages, including JavaScript, JScript, and ActionScript. It is best known as a JavaScript standard intended to ensure the interoperability of web pages across different web browsers. It is standardized by Ecma International in the document ECMA-262.

<span class="mw-page-title-main">SpiderMonkey</span> JavaScript and WebAssembly engine maintained by the Mozilla Foundation

SpiderMonkey is an open-source JavaScript and WebAssembly engine by the Mozilla Foundation.

Programming languages can be grouped by the number and types of paradigms supported.

The Web Server Gateway Interface is a simple calling convention for web servers to forward requests to web applications or frameworks written in the Python programming language. The current version of WSGI, version 1.0.1, is specified in Python Enhancement Proposal (PEP) 3333.

<span class="mw-page-title-main">JSON</span> Open standard file format and data interchange

JSON is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays. It is a commonly used data format with diverse uses in electronic data interchange, including that of web applications with servers.

In computer science, future, promise, delay, and deferred refer to constructs used for synchronizing program execution in some concurrent programming languages. They describe an object that acts as a proxy for a result that is initially unknown, usually because the computation of its value is not yet complete.

TypeScript is a free and open-source high-level programming language developed by Microsoft that adds static typing with optional type annotations to JavaScript. It is designed for the development of large applications and transpiles to JavaScript. Because TypeScript is a superset of JavaScript, all JavaScript programs are syntactically valid TypeScript, but they can fail to type-check for safety reasons.

<span class="mw-page-title-main">Node.js</span> JavaScript runtime environment

Node.js is a cross-platform, open-source JavaScript runtime environment that can run on Windows, Linux, Unix, macOS, and more. Node.js runs on the V8 JavaScript engine, and executes JavaScript code outside a web browser.

Chakra was a free and open-source JavaScript engine developed by Microsoft for its Microsoft Edge Legacy web browser. It is a fork of the same-named JScript engine used in Internet Explorer. Like the EdgeHTML browser engine, the declared intention was that it would reflect the "Living Web". The core components of Chakra were open-sourced as ChakraCore. In 2021, Microsoft terminated support for the engine, citing its transition to a Chromium based engine for Edge. Support has been transferred to the community, where it remains inactive.

JSGI, or JavaScript Gateway Interface, is an interface between web servers and JavaScript-based web applications and frameworks. It was inspired by the Rack for Ruby and WSGI for Python and was one of the inspirations of PSGI for Perl.

<span class="mw-page-title-main">Jasmine (software)</span> Open-source testing framework for JavaScript

Jasmine is an open-source testing framework for JavaScript. It aims to run on any JavaScript-enabled platform, to not intrude on the application nor the IDE, and to have easy-to-read syntax. It is heavily influenced by other unit testing frameworks, such as ScrewUnit, JSSpec, JSpec, and RSpec.

<span class="mw-page-title-main">Amber Smalltalk</span>

Amber Smalltalk, formerly named Jtalk, is an implementation of the programming language Smalltalk-80, that runs on the JavaScript runtime of a web browser. It is designed to enable client-side development using Smalltalk. The programming environment in Amber is named Helios.

Mustache is a web template system. Mustache is described as a logic-less system because it lacks any explicit control flow statements, like if and else conditionals or for loops; however, both looping and conditional evaluation can be achieved using section tags processing lists and anonymous functions (lambdas). It is named "Mustache" because of heavy use of braces, { }, that resemble a sideways moustache. Mustache is used mainly for mobile and web applications.

asm.js is a subset of JavaScript designed to allow computer software written in languages such as C to be run as web applications while maintaining performance characteristics considerably better than standard JavaScript, which is the typical language used for such applications.

A headless browser is a web browser without a graphical user interface.

<span class="mw-page-title-main">Deno (software)</span> Secure JavaScript and TypeScript runtime

Deno is a runtime for JavaScript, TypeScript, and WebAssembly that is based on the V8 JavaScript engine and the Rust programming language. Deno was co-created by Ryan Dahl, who also created Node.js.

References

  1. 1 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.
  2. 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.
  3. 1 2 "What Server Side JavaScript needs ·". www.blueskyonmars.com. Retrieved 2021-08-05.
  4. "CommonJS: JavaScript Standard Library". www.commonjs.org. Archived from the original on 2017-11-13. Retrieved 2021-08-05.
  5. "ProposalProcess - CommonJS Spec Wiki". wiki.commonjs.org. Retrieved 2021-08-05.
  6. "CommonJS: the First Year ·". www.blueskyonmars.com. Retrieved 2021-08-05.
  7. "JavaScript Standard Library". CommonJS. Archived from the original on 2014-05-28. Retrieved 2014-05-28.{{cite web}}: CS1 maint: unfit URL (link)
  8. "olegp/common-node @ GitHub". olegp.github.io. Retrieved 2021-08-05.
  9. "CommonJS Compiler - makes your Common JS modules suitable for in-browser use". dsheiko.github.io. Retrieved 2021-08-05.
  10. "GitHub - DrBenton/CommonJSForPHP: A simple CommonJS spec implementation for PHP 5.3+". GitHub. Retrieved 2021-08-05.
  11. "Implementations/CouchDB - CommonJS Spec Wiki". wiki.commonjs.org. Retrieved 2021-08-05.
  12. "Flusspferd - CommonJS platform | Javascript bindings for C". Archived from the original on 2013-01-28. Retrieved 2017-09-19.
  13. "Implementations/GPSEE - CommonJS Spec Wiki". wiki.commonjs.org. Retrieved 2021-08-05.
  14. "Implementations/Smart - CommonJS Spec Wiki". wiki.commonjs.org. Retrieved 2021-08-05.
  15. "Homepage - JSBuild". Archived from the original on January 4, 2011.
  16. "The most popular database for modern apps". MongoDB. Retrieved 2021-08-05.
  17. "Implementations/Narwhal - CommonJS Spec Wiki". wiki.commonjs.org. Retrieved 2021-08-05.
  18. "Implementations/node.js - CommonJS Spec Wiki". wiki.commonjs.org. Retrieved 2021-08-05.
  19. "Implementations/Persevere - CommonJS Spec Wiki". wiki.commonjs.org. Retrieved 2021-08-05.
  20. "GitHub - pinf/loader-js: EARLY STALLED EXPLORATION". GitHub. 30 July 2021. Retrieved 2021-08-05.
  21. "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.
  22. "Implementations/RingoJS - CommonJS Spec Wiki". wiki.commonjs.org. Retrieved 2021-08-05.
  23. "SilkJS WWW Site". Archived from the original on 2017-09-12. Retrieved 2012-10-19.
  24. "Implementations/SproutCore - CommonJS Spec Wiki". wiki.commonjs.org. Retrieved 2021-08-05.
  25. "Implementations/TeaJS - CommonJS Spec Wiki". wiki.commonjs.org. Retrieved 2021-08-05.
  26. SAS, Wakanda. "Wakanda FullStack JavaScript Platform". Wakanda FullStack JavaScript Platform. Retrieved 2021-08-05.
  27. "Google Code Archive - Long-term storage for Google Code Project Hosting". code.google.com. Retrieved 2021-08-05.