171
edits
Petermichaux (talk | contribs) |
(Added a note about ServerJS securable module identifiers.) |
||
| Line 4: | Line 4: | ||
# A module receives an "exports" object that it may add its exported API to as it executes. | # A module receives an "exports" object that it may add its exported API to as it executes. | ||
# Interoperable modules must use the exports object as the only means of exporting, since an implementation may prevent tampering with any other object shared among modules. | # Interoperable modules must use the exports object as the only means of exporting, since an implementation may prevent tampering with any other object shared among modules. | ||
=== Module Identifiers === | |||
# A module identifier is a String of "terms" delimited by forward slashes. | |||
# A term must be a camelCase identifier, ".", or "..". | |||
# The extension of the file corresponding to a module identifier must be inferred by loaders. | |||
# Module identifiers may be "relative" or "absolute". A module identifier is "relative" if the first term is "." or "..". | |||
# Absolute identifiers are resolved off the conceptual name space root. A loader may check multiple roots in a consistent order, like a PATH. | |||
# Relative identifiers are resolved relative to the file in which "require" is called. | |||
=== Security === | |||
To be interoperable with secure environments, a module must satisfy the following additional constraints: | To be interoperable with secure environments, a module must satisfy the following additional constraints: | ||
| Line 9: | Line 21: | ||
# A module must not have any free variables apart from primordials ("Object", "Array", etc.), "require", and "exports". | # A module must not have any free variables apart from primordials ("Object", "Array", etc.), "require", and "exports". | ||
# A module must not tamper with (assign to, assign to members of, delete, or otherwise mutate) the transitive primordials, the "require" object, or any object returned by "require". | # A module must not tamper with (assign to, assign to members of, delete, or otherwise mutate) the transitive primordials, the "require" object, or any object returned by "require". | ||
=== Unspecified === | |||
This specification leaves the following important points of interoperability unspecified: | This specification leaves the following important points of interoperability unspecified: | ||
# Whether relative module identifiers are supported. | # Whether relative module identifiers are supported. | ||
# Whether a PATH is supported by the module loader for resolving module identifiers. | # Whether a PATH is supported by the module loader for resolving module identifiers. | ||
== Loaders == | == Loaders == | ||
edits