You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>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 _referencingModule_.</p>
<p>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 script or module represented by the Script Record or Module Record _referencingScriptOrModule_. _referencingScriptOrModule_ may also be *null*, if the resolution is being performed in the context of an <emu-xref href="#sec-import-calls">`import()`</emu-xref> expression, and there is no active script or module at that time.</p>
22624
+
22625
+
<emu-note>
22626
+
<p>An example of when _referencingScriptOrModule_ can be *null* is in a web browser host. There, if a user clicks on a control given by</p>
<p>there will be no active script or module at the time the <emu-xref href="#sec-import-calls">`import()`</emu-xref> expression runs. More generally, this can happen in any situation where the host pushes execution contexts with *null* ScriptOrModule components onto the execution context stack.</p>
22631
+
</emu-note>
22632
+
22599
22633
<p>The implementation of HostResolveImportedModule must conform to the following requirements:</p>
22600
22634
<ul>
22601
22635
<li>
22602
22636
The normal return value must be an instance of a concrete subclass of Module Record.
22603
22637
</li>
22604
22638
<li>
22605
-
If a Module Record corresponding to the pair _referencingModule_, _specifier_ does not exist or cannot be created, an exception must be thrown.
22639
+
If a Module Record corresponding to the pair _referencingScriptOrModule_, _specifier_ does not exist or cannot be created, an exception must be thrown.
22606
22640
</li>
22607
22641
<li>
22608
-
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.
22642
+
This operation must be idempotent if it completes normally. Each time it is called with a specific _referencingScriptOrModule_, _specifier_ pair as arguments it must return the same Module Record instance.
22609
22643
</li>
22610
22644
</ul>
22611
-
<p>Multiple different _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.</p>
22645
+
<p>Multiple different _referencingScriptOrModule_, _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.</p>
<p>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_. (_referencingScriptOrModule_ may also be *null*, if there is no active script or module when the <emu-xref href="#sec-import-calls">`import()`</emu-xref> expression occurs.) It then performs FinishDynamicImport to finish the dynamic import process.</p>
22652
+
22653
+
<p>The implementation of HostImportModuleDynamically must conform to the following requirements:</p>
22654
+
22655
+
<ul>
22656
+
<li>
22657
+
The abstract operation must always complete normally with *undefined*. Success or failure must instead be signaled as discussed below.
22658
+
</li>
22659
+
<li>
22660
+
The host environment must conform to one of the two following sets of requirements:
22661
+
<dl>
22662
+
<dt>Success path</dt>
22663
+
22664
+
<dd>
22665
+
<ul>
22666
+
<li>At some future time, the host environment must perform FinishDynamicImport(_referencingScriptOrModule_, _specifier_, _promiseCapability_, NormalCompletion(*undefined*)).</li>
22667
+
22668
+
<li>Any subsequent call to HostResolveImportedModule after FinishDynamicImport has completed, given the arguments _referencingScriptOrModule_ and _specifier_, must complete normally.</li>
22669
+
22670
+
<li>The completion value of any subsequent call to HostResolveImportedModule after FinishDynamicImport has completed, given the arguments _referencingScriptOrModule_ and _specifier_, must be a module which has already been evaluated, i.e. whose Evaluate concrete method has already been called and returned a normal completion.</li>
22671
+
</ul>
22672
+
</dd>
22673
+
22674
+
<dt>Failure path</dt>
22675
+
22676
+
<dd>
22677
+
<ul>
22678
+
<li>At some future time, the host environment must perform FinishDynamicImport(_referencingScriptOrModule_, _specifier_, _promiseCapability_, an abrupt completion), with the abrupt completion representing the cause of failure.</li>
22679
+
</ul>
22680
+
</dd>
22681
+
</dl>
22682
+
</li>
22683
+
<li>
22684
+
Every call to HostImportModuleDynamically with the same _referencingScriptOrModule_ and _specifier_ arguments must conform to the <em>same</em> set of requirements above as previous calls do. That is, if the host environment takes the success path once for a given _referencingScriptOrModule_, _specifier_ pair, it must always do so, and the same for the failure path.
22685
+
</li>
22686
+
<li>
22687
+
The operation must not call _promiseCapability_.[[Resolve]] or _promiseCapability_.[[Reject]], but instead must treat _promiseCapability_ as an opaque identifying value to be passed through to FinishDynamicImport.
22688
+
</li>
22689
+
</ul>
22690
+
22691
+
<p>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 Evaluate concrete method. This might require performing similar normalization as HostResolveImportedModule does.</p>
<p>FinishDynamicImport completes the process of a dynamic import originally started by an <emu-xref href="#sec-import-calls">`import()`</emu-xref> 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.</p>
22698
+
22699
+
<emu-alg>
22700
+
1. If _completion_ is an abrupt completion, then perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _completion_.[[Value]] »).
22701
+
1. Else,
22702
+
1. Assert: _completion_ is a normal completion and _completion_.[[Value]] is *undefined*.
22703
+
1. Let _moduleRecord_ be ! HostResolveImportedModule(_referencingScriptOrModule_, _specifier_).
22704
+
1. Assert: Evaluate has already been invoked on _moduleRecord_ and successfully completed.
22705
+
1. Let _namespace_ be GetModuleNamespace(_moduleRecord_).
22706
+
1. If _namespace_ is an abrupt completion, perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _namespace_.[[Value]] »).
When parsing for the |Module| goal symbol, the lexical grammar extensions defined in <emu-xref href="#sec-html-like-comments"></emu-xref> must not be supported.
23345
23442
</li>
23443
+
<li>
23444
+
|ImportCall| must not be extended.
23445
+
<!-- This is so that in the future we can potentially add new arguments or support ArgumentList. -->
0 commit comments