1.1.1Runtime Semantics: HostResolveImportedModule (
referencingModule, specifier )
HostResolveImportedModule is an implementation defined abstract operation that provides the concrete Module Record subclass instance that corresponds to the ModuleSpecifier String, specifier, occurring within the context of the module represented by the Module Record
The implementation of HostResolveImportedModule must conform to the following requirements:
The normal return value must be an instance of a concrete subclass of Module Record.
If a Module Record corresponding to the pair
referencingModule, specifier does not exist or cannot be created, an exception must be thrown.
This operation must be idempotent if it completes normally. Each time it is called with a specific
referencingModule, specifier pair as arguments it must return the same Module Record instance.
referencingModule, specifier pairs may map to the same Module Record instance. The actual mapping semantic is implementation defined but typically a normalization process is applied to specifier as part of the mapping process. A typical normalization process would include actions such as alphabetic case folding and expansion of relative and abbreviated path specifiers.
HostImportModuleDynamically is an implementation defined abstract operation that performs any necessary setup work in order to make available the module corresponding to the ModuleSpecifier String, specifier, occurring within the context of the script or module represented by the Script Record or Module Record referencingScriptOrModule. It then performs FinishDynamicImport to finish the dynamic import process.
The implementation of HostImportModuleDynamically must conform to the following requirements:
The actual process performed is implementation defined, but typically consists of performing whatever I/O operations are necessary to allow HostResolveImportedModule to synchronously retrieve the appropriate Module Record, and then calling its ModuleEvaluation concrete method. This might require performing similar normalization as HostResolveImportedModule does.
FinishDynamicImport completes the process of a dynamic import originally started by an
import() call, resolving or rejecting the promise returned by that call as appropriate according to completion. It is performed by host environments as part of HostImportModuleDynamically.
- If completion is an abrupt completion, then perform ! Call(promiseCapability.[[Reject]], undefined, « completion.[[Value]] »).
- Assert: completion is a normal completion and completion.[[Value]] is undefined.
- Let moduleRecord be ! HostResolveImportedModule(referencingScriptOrModule, specifierString).
- Assert: ModuleEvaluation has already been invoked on moduleRecord and successfully completed.
- Let namespace be GetModuleNamespace(moduleRecord).
- If namespace is an abrupt completion, perform ! Call(promiseCapability.[[Reject]], undefined, « namespace.[[Value]] »).
- Otherwise, perform ! Call(promiseCapability.[[Resolve]], undefined, « namespace.[[Value]] »).