ServerJS/Modules: Difference between revisions

m
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This page is being ported from [[https://developer.mozilla.org/ServerJS/Modules]]
== 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.
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.
=== Proposals ===
Several proposals have been made.  There has been convergence toward the [[ServerJS/Modules/SecurableModules|Securable Modules]] proposal, with several implementations passing the unit tests.
# [[ServerJS/Modules/GlobalFileLoading|Global File Loading]]
# [[ServerJS/Modules/GlobalObjectLoading|Global Object Loading]]
# [[ServerJS/Modules/PythonicModules|Pythonic Modules]]
# [[ServerJS/Modules/SecurableModules|Securable Modules]]


=== Prior Art ===
=== Prior Art ===
Line 18: Line 25:
* [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.
* [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.
* [http://torino.sourceforge.net Torino] implements a C-style "#include" preprocessor which is intended to provide a low-level loading mechanism on top of which more sophisticated module management schemes can be implemented in JavaScript.
* [http://torino.sourceforge.net Torino] implements a C-style "#include" preprocessor which is intended to provide a low-level loading mechanism on top of which more sophisticated module management schemes can be implemented in JavaScript.
 
* [http://wiki.eclipse.org/E4 Eclipse E4] is doing work using Rhino to support writing modular [http://wiki.eclipse.org/E4/JavaScript JavaScript bundles] that can  interoperate cleanly with the OSGi modularity layer used by Java plugins in the platform.
=== Proposals ===
 
Several proposals have been made:
 
# [[ServerJS/Modules/GlobalFileLoading|Global File Loading]]
# [[ServerJS/Modules/GlobalObjectLoading|Global Object Loading]]
# [[ServerJS/Modules/PythonicModules|Pythonic Modules]]
# [[ServerJS/Modules/SecurableModules|Securable Modules]]


=== Related Discussions ===
=== Related Discussions ===
Line 37: Line 36:
* [http://groups.google.com/group/serverjs/browse_thread/thread/5dc7db5ceeb1422a Do you think require() should be implemented in JS?]
* [http://groups.google.com/group/serverjs/browse_thread/thread/5dc7db5ceeb1422a Do you think require() should be implemented in JS?]
* [http://groups.google.com/group/serverjs/browse_thread/thread/d2dc85a2725992be Securable Modules show of hands]
* [http://groups.google.com/group/serverjs/browse_thread/thread/d2dc85a2725992be Securable Modules show of hands]
* [http://groups.google.com/group/serverjs/browse_thread/thread/c7016998d1087b5e Secureable Modules: "exports" vs "this"]
* [http://groups.google.com/group/serverjs/browse_thread/thread/e2258194f110eda2 SecurableModules: Namespacing, version numbers]
* [http://groups.google.com/group/serverjs/browse_thread/thread/d3dc1c0acd89dae5 Global Free Variable]
171

edits