From CommonJS Spec Wiki
Jump to: navigation, search



This proposal amends Modules/1.1.

  • The "module" free variable exposes a "setExports" function.
  • This function sets the module's export to the first argument, and returns it.
  • To prevent problems with inconsistencies in the case of circular dependencies, if the module has already been required by another module, calling module.setExports() must throw an Error.

Relevant Discussions

Show of Hands

Those in favor of incorporating this proposal in the next minor revision of Modules/1:

  • Isaac Schlueter
  • Dean Landolt
  • Kevin Dangoor
  • Kris Zyp
  • Francisco Tolmasky
  • Jhuni

Those against:

  • Mark S. Miller -- keep it simple. Why is there even a "module" free variable anyway?
  • Ihab Awad
  • Wes Garland
  • Ondrej Zara -- a sane function (require) ought to return one data type
  • Daniel Friesen
  • Tom Robinson


  • Node (isaacs branch)
  • Narwhal (kriskowal's refactor and using-packages branches, landing in the 0.3 timeframe if ratified)