Modules

  • Revision slug: CommonJS/Modules
  • Revision title: Modules
  • Revision id: 93361
  • Created:
  • Creator: kriszyp
  • Is current revision? No
  • Comment 14 words added

Revision Content

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.

Prior Art

  • Spidermonkey and Rhino offer a load function, but does not have any specific pattern for namespacing.
  • Dojo has a complete incremental loading facility in the form of dojo.require and a standard mechanism for declaring modules. dojo.require ensures that the module is loaded only once.
  • The Jack project implements a simple "require" system.
  • Persevere uses "require" (similar to Jack) for module loading.
  • Helma NG implements a module system with per-module scopes and import, include and require functions.

Proposed API

TBD

Related discussions

 

Revision Source

<p>To date, client side JavaScript has generally been able to get away with something as simple as the &lt;script&gt; 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.</p>
<h3>Prior Art</h3>
<ul> <li>Spidermonkey and Rhino offer a <a class="external" href="/En/SpiderMonkey/Introduction_to_the_JavaScript_shell" title="https://developer.mozilla.org/editor/fckeditor/core/editor/en/Introduction_to_the_JavaScript_shell">load</a> function, but does not have any specific pattern for namespacing.</li> <li>Dojo has a complete incremental loading facility in the form of <a class="external" href="http://dojotoolkit.org/book/dojo-book-0-9/part-3-programmatic-dijit-and-dojo/functions-used-everywhere/dojo-require" title="http://dojotoolkit.org/book/dojo-book-0-9/part-3-programmatic-dijit-and-dojo/functions-used-everywhere/dojo-require">dojo.require</a> and a standard mechanism for declaring modules. dojo.require ensures that the module is loaded only once.</li> <li>The Jack project <a class="external" href="http://github.com/tlrobinson/jack/blob/54a28398425287bddd9466955d5e8ea616eb8d47/core.js" title="http://github.com/tlrobinson/jack/blob/54a28398425287bddd9466955d5e8ea616eb8d47/core.js">implements a simple "require" system</a>.</li> <li><a class="external" href="http://docs.persvr.org/documentation/server-side-js" title="http://docs.persvr.org/documentation/server-side-js">Persevere uses "require"</a> (similar to Jack) for module loading.</li> <li>Helma NG implements a <a class="external" href="http://dev.helma.org/ng/Modules+and+Scopes/" title="http://dev.helma.org/ng/Modules+and+Scopes/">module system</a> with per-module scopes and import, include and require functions.</li>
</ul>
<h3>Proposed API</h3>
<p>TBD</p>
<h3>Related discussions</h3>
<ul> <li><a class="external" href="http://groups.google.com/group/serverjs/browse_thread/thread/d761996c25769e6c" title="http://groups.google.com/group/serverjs/browse_thread/thread/d761996c25769e6c">"a module system (difficult to agree)"<br> </a> </li>
</ul>
<p> </p>
Revert to this revision