ServerJS/Modules: Difference between revisions
< ServerJS
Jump to navigation
Jump to search
(Initial revision of the ServerJS module project summary) |
|||
| Line 2: | Line 2: | ||
== Modules == | == 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. | |||
=== Prior Art === | === Prior Art === | ||
* Spidermonkey (and Jaxer) and Rhino offer a [https://developer.mozilla.org/En/SpiderMonkey/Introduction_to_the_JavaScript_shell load] function, but does not have any specific pattern for namespacing. | |||
* Dojo has a complete incremental loading facility in the form of [http://dojotoolkit.org/book/dojo-book-0-9/part-3-programmatic-dijit-and-dojo/functions-used-everywhere/dojo-require dojo.require] and a standard mechanism for declaring modules. dojo.require ensures that the module is loaded only once. It also manages dependecies between modules. | |||
* The Jack project [http://github.com/tlrobinson/jack/blob/54a28398425287bddd9466955d5e8ea616eb8d47/core.js implements a simple "require" system]. | |||
* [http://docs.persvr.org/documentation/server-side-js Persevere uses "require"] (similar to Jack) for module loading. | |||
* Helma NG implements [http://dev.helma.org/ng/Modules+and+Scopes/ a module system] with per-module scopes and import, include and require functions. | |||
* jslibs bootstrapping jshost provides only basic code and loading module support, direct from file and either into the global namespace or a chosen namespace http://code.google.com/p/jslibs/wiki/jshost | |||
* Advanced JavaScript Importing & Loading Extension is the browser-independent extension that provides Javascript with namespace and dynamic script loading support ( http://ajile.iskitz.com/ ) | |||
* modulesjs an XHR JS module loader provides module loading, singleton modules ( http://modulesjs.com/ ) | |||
* [http://synchro.net/ Synchronet] provides a global load() method which allows a specified scope/sandbox object, passing arguments, and background/concurrent execution: http://synchro.net/docs/jsobjs.html#global | |||
* [http://www.ejscript.org/ Ejscript] has a loadable module mechanism based on language extensions "module" and "use module" definitions. Modules can have scope, dependencies, incremental loading and optional backing native code. | |||
=== Proposals === | === Proposals === | ||
| Line 15: | Line 29: | ||
=== Related Discussions === | === Related Discussions === | ||
* [http://groups.google.com/group/serverjs/browse_thread/thread/d761996c25769e6c "a module system (difficult to agree)"] | |||
* [http://groups.google.com/group/serverjs/browse_frm/thread/b99a5b6eb9ed8a23 Concerns about the proposed module system(s)] | |||
* [http://groups.google.com/group/serverjs/browse_frm/thread/2dcfbff6b6ba5928 do we need a Module object instead of require() function?] | |||
* [http://groups.google.com/group/serverjs/browse_frm/thread/1abef605cf13c337 Are we agreed on require, in general?] | |||
Revision as of 01:12, 5 February 2009
This page is being ported from [[1]]
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.
Prior Art
- Spidermonkey (and Jaxer) 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. It also manages dependecies between modules.
- 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.
- jslibs bootstrapping jshost provides only basic code and loading module support, direct from file and either into the global namespace or a chosen namespace http://code.google.com/p/jslibs/wiki/jshost
- Advanced JavaScript Importing & Loading Extension is the browser-independent extension that provides Javascript with namespace and dynamic script loading support ( http://ajile.iskitz.com/ )
- modulesjs an XHR JS module loader provides module loading, singleton modules ( http://modulesjs.com/ )
- Synchronet provides a global load() method which allows a specified scope/sandbox object, passing arguments, and background/concurrent execution: http://synchro.net/docs/jsobjs.html#global
- Ejscript has a loadable module mechanism based on language extensions "module" and "use module" definitions. Modules can have scope, dependencies, incremental loading and optional backing native code.
Proposals
Several proposals have been made: