ServerJS/Modules/SecurableModules: Difference between revisions

Jump to navigation Jump to search
→‎Module Context: added the normative clauses for adding "global" to modules.
(→‎Unit Tests: added a link to Ash Berlin's unit test mirror)
(→‎Module Context: added the normative clauses for adding "global" to modules.)
Line 5: Line 5:
=== Module Context ===
=== Module Context ===


# A module receives a "require" function.
# In a module, there is a free variable "require", that is a function.
## The "require" function accepts a module identifier.
## The "require" function accepts a module identifier.
## "require" returns an object containing the exported API of the foreign module.
## "require" returns the exported API of the foreign module.
## If there is a dependency cycle, the foreign module may not have finished executing at the time it is required by one of its transitive dependencies; in this case, the object returned by "require" must contain at least the exports that the foreign module has prepared before the call to require that led to the current module's execution.
## If there is a dependency cycle, the foreign module may not have finished executing at the time it is required by one of its transitive dependencies; in this case, the object returned by "require" must contain at least the exports that the foreign module has prepared before the call to require that led to the current module's execution.
## If the requested module cannot be returned, "require" must throw an error.
## If the requested module cannot be returned, "require" must throw an error.
# A module receives an "exports" object that it may add its exported API to as it executes.
# In a module, there is a free variable called "exports", that is an object that the module may add its API to as it executes.
# modules must use the "exports" object as the only means of exporting.
# modules must use the "exports" object as the only means of exporting.
# In a module, there is a free variable "global", that is the global object.
## The "global" object must contain all of the standard JavaScript primordial objects (including Object, Array, String, Date, and Math)
## "global" may be frozen in secure sandboxes
## "global" and its contents must be identical in all modules from a given sandbox.
## "global" and its contents must be identical in all modules for all secure sandboxes.
## "global" and its contents must be identical in all modules for all permissive sandboxes.


=== Module Identifiers ===
=== Module Identifiers ===
171

edits

Navigation menu