Modules

From CommonJS Spec Wiki
Jump to: navigation, search

STATUS: 1.1 RATIFIED

Contents

Modules

To date, client side JavaScript has generally been able to get away with something as simple as the <script> tag and no standard way to do namespaces. On the server, it's a bit different because you're more likely to use more libraries and you can potentially load up a lot of code. Having a basic system for loading code and encouraging the use of namespaces to avoid unintentional interference will underlie everything else.

Specifications

Proposals

Several proposals were made. There was convergence toward the Securable Modules proposal, with several implementations passing the unit tests.

  1. Global File Loading
  2. Global Object Loading
  3. Pythonic Modules
  4. Securable Modules
  5. Declarative Modules proposal, introducing readable module definition format suitable for both server and browser.

There are also proposals for amendments and supplements to these proposals:

  1. Modules/Meta ratified and incorporated into Modules/1.1.
  2. Modules/Loaders for module loader specification proposals
  3. Modules/Transport for module transport format proposals (for a module format suitable for browser script injection)
  4. Modules/SetExports function for exporting something other than a plain object.
  5. Modules/Async/A proposes async loading.
  6. Modules/Metadata proposes JSON metadata.

We need proposals for:

  1. A module-relative "resource" object, like module.resource(path).open(…).
  2. To fix the module identifier domain. The current specification restricts module identifiers to camelCase delimited by slashes, but this is hazardous in case-insensitve stores, and not restricted in practice.
  3. A page for discussing a system for injecting free variables from the exports of a foreign module
  4. module.setExports(exports) exports Object

Prior Art

Related Discussions

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox