This change adds support for dynamic import to ses and @endo/module-source, such that import(x) in the scope of a module loaded from source (using ModuleSource in a Compartment module loading hook).
Security Considerations
This change builds on prior work to ensure that dynamic import is facilitated by a hidden lexical name injected by ses. The dynamic import mechanism is isolated to the surrounding compartment and specifiers are resolved on the surrounding module.
Scaling Considerations
This change introduces a static analysis for the presence of a dynamic import in the module source, which it communicates on the module source, even if marshaled through JSON, to ses that it should create an import closure bound to the calling module’s base specifier. This avoids an allocation for most modules.
Documentation Considerations
Only news included. Dynamic import is a language feature that is expected to work in general and documented where JavaScript is documented as a language.
Testing Considerations
This change includes a minimal happy path test that verifies that dynamic import produces a promise that settles on a module namespace object. Note that dynamic import does not box namespaces regardless of the __noNamespaceBox__ compartment option.
Closes: #291
Description
This change adds support for dynamic
import
toses
and@endo/module-source
, such thatimport(x)
in the scope of a module loaded from source (usingModuleSource
in aCompartment
module loading hook).Security Considerations
This change builds on prior work to ensure that dynamic import is facilitated by a hidden lexical name injected by
ses
. The dynamic import mechanism is isolated to the surrounding compartment and specifiers are resolved on the surrounding module.Scaling Considerations
This change introduces a static analysis for the presence of a dynamic
import
in the module source, which it communicates on the module source, even if marshaled through JSON, toses
that it should create animport
closure bound to the calling module’s base specifier. This avoids an allocation for most modules.Documentation Considerations
Only news included. Dynamic import is a language feature that is expected to work in general and documented where JavaScript is documented as a language.
Testing Considerations
This change includes a minimal happy path test that verifies that dynamic import produces a promise that settles on a module namespace object. Note that dynamic import does not box namespaces regardless of the
__noNamespaceBox__
compartment option.Compatibility Considerations
Backward compatible.
Upgrade Considerations
None.