diff --git a/spec.html b/spec.html
index 34a4096181..03dcb61ae3 100644
--- a/spec.html
+++ b/spec.html
@@ -3280,6 +3280,17 @@
Well-Known Intrinsic Objects
+
+
+ %AbstractModuleSource%
+ |
+
+ `AbstractModuleSource`
+ |
+
+ The `AbstractModuleSource` constructor ()
+ |
+
%AggregateError%
@@ -19057,6 +19068,8 @@ Syntax
ImportCall[Yield, Await] :
`import` `(` AssignmentExpression[+In, ?Yield, ?Await] `,`? `)`
`import` `(` AssignmentExpression[+In, ?Yield, ?Await] `,` AssignmentExpression[+In, ?Yield, ?Await] `,`? `)`
+ `import` `.` `source` `(` AssignmentExpression[+In, ?Yield, ?Await] `,`? `)`
+ `import` `.` `source` `(` AssignmentExpression[+In, ?Yield, ?Await] `,` AssignmentExpression[+In, ?Yield, ?Await] `,`? `)`
Arguments[Yield, Await] :
`(` `)`
@@ -19617,12 +19630,22 @@ Runtime Semantics: Evaluation
ImportCall : `import` `(` AssignmentExpression `,`? `)`
- 1. Return ? EvaluateImportCall(|AssignmentExpression|).
+ 1. Return ? EvaluateImportCall(|AssignmentExpression|, ~evaluation~).
ImportCall : `import` `(` AssignmentExpression `,` AssignmentExpression `,`? `)`
- 1. Return ? EvaluateImportCall(the first |AssignmentExpression|, the second |AssignmentExpression|).
+ 1. Return ? EvaluateImportCall(the first |AssignmentExpression|, ~evaluation~, the second |AssignmentExpression|).
+
+
+ ImportCall : `import` `.` `source` `(` AssignmentExpression `,` AssignmentExpression `,`? `)`
+
+ 1. Return ? EvaluateImportCall(|AssignmentExpression|, ~source~).
+
+
+ ImportCall : `import` `.` `source` `(` AssignmentExpression `,` AssignmentExpression `,`? `)`
+
+ 1. Return ? EvaluateImportCall(the first |AssignmentExpression|, ~source~, the second |AssignmentExpression|).
@@ -19630,6 +19653,7 @@ Runtime Semantics: Evaluation
EvaluateImportCall (
_specifierExpression_: a Parse Node,
+ _phase_: ~source~ or ~evaluation~,
optional _optionsExpression_: a Parse Node,
): either a normal completion containing a Promise or a throw completion
@@ -19673,7 +19697,7 @@
1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « a newly created *TypeError* object »).
1. Return _promiseCapability_.[[Promise]].
1. Sort _attributes_ according to the lexicographic order of their [[Key]] fields, treating the value of each such field as a sequence of UTF-16 code unit values. NOTE: This sorting is observable only in that hosts are prohibited from changing behaviour based on the order in which attributes are enumerated.
- 1. Let _moduleRequest_ be a new ModuleRequest Record { [[Specifier]]: _specifierString_, [[Attributes]]: _attributes_ }.
+ 1. Let _moduleRequest_ be a new ModuleRequest Record { [[Specifier]]: _specifierString_, [[Phase]]: _phase_, [[Attributes]]: _attributes_ }.
1. Perform HostLoadImportedModule(_referrer_, _moduleRequest_, ~empty~, _promiseCapability_).
1. Return _promiseCapability_.[[Promise]].
@@ -19683,6 +19707,7 @@
ContinueDynamicImport (
_promiseCapability_: a PromiseCapability Record,
+ _phase_: ~source~ or ~evaluation~,
_moduleCompletion_: either a normal completion containing a Module Record or a throw completion,
): ~unused~
@@ -19695,6 +19720,13 @@
1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _moduleCompletion_.[[Value]] »).
1. Return ~unused~.
1. Let _module_ be _moduleCompletion_.[[Value]].
+ 1. If _phase_ is ~source~, then
+ 1. Let _moduleSourceCompletion_ be Completion(_module_.GetModuleSource()).
+ 1. If _moduleSourceCompletion_ is an abrupt completion, then
+ 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _moduleSourceCompletion_.[[Value]] »).
+ 1. Else,
+ 1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « _moduleSourceCompletion_.[[Value]] »).
+ 1. Return ~unused~.
1. Let _loadPromise_ be _module_.LoadRequestedModules().
1. Let _rejectedClosure_ be a new Abstract Closure with parameters (_reason_) that captures _promiseCapability_ and performs the following steps when called:
1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _reason_ »).
@@ -26260,6 +26292,17 @@ ModuleRequest Records
The module specifier
|
+
+
+ [[Phase]]
+ |
+
+ ~source~ or ~evaluation~
+ |
+
+ The target import phase
+ |
+
[[Attributes]]
@@ -26274,7 +26317,7 @@ ModuleRequest Records
- A LoadedModuleRequest Record represents the request to import a module together with the resulting Module Record. It consists of the same fields defined in table , with the addition of [[Module]]:
+ A LoadedModuleRequest Record represents the request to import a module together with the resulting Module Record. It consists of the [[Specifier]] and [[Attributes]] fields defined in table , with the addition of [[Module]]:
@@ -26425,31 +26468,42 @@ Static Semantics: ModuleRequests ( ): a List of ModuleRequest Records
ImportDeclaration : `import` ImportClause FromClause `;`
1. Let _specifier_ be the SV of |FromClause|.
- 1. Return a List whose sole element is the ModuleRequest Record { [[Specifier]]: _specifier_, [[Attributes]]: « » }.
+ 1. Return a List whose sole element is the ModuleRequest Record { [[Specifier]]: _specifier_, [[Phase]]: ~evaluation~, [[Attributes]]: « » }.
ImportDeclaration : `import` ImportClause FromClause WithClause `;`
1. Let _specifier_ be the SV of |FromClause|.
1. Let _attributes_ be WithClauseToAttributes of |WithClause|.
- 1. Return a List whose sole element is the ModuleRequest Record { [[Specifier]]: _specifier_, [[Attributes]]: _attributes_ }.
+ 1. Return a List whose sole element is the ModuleRequest Record { [[Specifier]]: _specifier_, [[Phase]]: ~evaluation~, [[Attributes]]: _attributes_ }.
+
+ ImportDeclaration : `import` `source` ImportedBinding FromClause `;`
+
+ 1. Let _specifier_ be the SV of |FromClause|.
+ 1. Return a List whose sole element is the ModuleRequest Record { [[Specifier]]: _specifier_, [[Phase]]: ~source~, [[Attributes]]: « » }.
+
+ ImportDeclaration : `import` `source` ImportedBinding FromClause WithClause `;`
+
+ 1. Let _specifier_ be the SV of |FromClause|.
+ 1. Let _attributes_ be WithClauseToAttributes of |WithClause|.
+ 1. Return a List whose sole element is the ModuleRequest Record { [[Specifier]]: _specifier_, [[Phase]]: ~source~, [[Attributes]]: _attributes_ }.
ImportDeclaration : `import` ModuleSpecifier `;`
1. Let _specifier_ be the SV of |ModuleSpecifier|.
- 1. Return a List whose sole element is the ModuleRequest Record { [[Specifier]]: _specifier_, [[Attributes]]: « » }.
+ 1. Return a List whose sole element is the ModuleRequest Record { [[Specifier]]: _specifier_, [[Phase]]: ~evaluation~, [[Attributes]]: « » }.
ImportDeclaration : `import` ModuleSpecifier WithClause `;`
1. Let _specifier_ be the SV of |ModuleSpecifier|.
1. Let _attributes_ be WithClauseToAttributes of |WithClause|.
- 1. Return a List whose sole element is the ModuleRequest Record { [[Specifier]]: _specifier_, [[Attributes]]: _attributes_ }.
+ 1. Return a List whose sole element is the ModuleRequest Record { [[Specifier]]: _specifier_, [[Phase]]: ~evaluation~, [[Attributes]]: _attributes_ }.
ExportDeclaration : `export` ExportFromClause FromClause `;`
1. Let _specifier_ be the SV of |FromClause|.
- 1. Return a List whose sole element is the ModuleRequest Record { [[Specifier]]: _specifier_, [[Attributes]]: « » }.
+ 1. Return a List whose sole element is the ModuleRequest Record { [[Specifier]]: _specifier_, [[Phase]]: ~evaluation~, [[Attributes]]: « » }.
ExportDeclaration : `export` ExportFromClause FromClause WithClause `;`
@@ -26457,7 +26511,7 @@ Static Semantics: ModuleRequests ( ): a List of ModuleRequest Records
1. Let _specifier_ be the SV of |FromClause|.
1. Let _attributes_ be WithClauseToAttributes of |WithClause|.
- 1. Return a List whose sole element is the ModuleRequest Record { [[Specifier]]: _specifier_, [[Attributes]]: _attributes_ }.
+ 1. Return a List whose sole element is the ModuleRequest Record { [[Specifier]]: _specifier_, [[Phase]]: ~evaluation~, [[Attributes]]: _attributes_ }.
ExportDeclaration :
@@ -26596,6 +26650,17 @@ Abstract Module Records
Link must have completed successfully prior to invoking this method.
+
+
+ GetModuleSource()
+ |
+
+ It returns either a normal completion containing the Module Source Object corresponding to this source Module Record's source phase (), or a throw completion.
+ When called multiple times on the same Module Record, if GetModuleSource() returns a normal completion it must always return a normal completion containing the same object.
+ The returned object should have a [[Prototype]] internal slot whose value is %AbstractModuleSource.prototype%.
+ For Module Records that do not have a source representation, GetModuleSource() must always return a throw completion whose [[Value]] is a *SyntaxError*.
+ |
+
@@ -26671,7 +26736,7 @@ Cyclic Module Records
a List of ModuleRequest Records
|
- A List of the ModuleRequest Records associated with the imports in this module. The List is in source text occurrence order of the imports.
+ A List of the ModuleRequest Records associated with the imports in this module, along with their associated phase (~source~ or ~evaluation~). The List is in source text occurrence order of the imports.
|
@@ -26877,7 +26942,7 @@
1. If _hostDefined_ is not present, let _hostDefined_ be ~empty~.
1. Let _pc_ be ! NewPromiseCapability(%Promise%).
1. Let _state_ be the GraphLoadingState Record { [[IsLoading]]: *true*, [[PendingModulesCount]]: 1, [[Visited]]: « », [[PromiseCapability]]: _pc_, [[HostDefined]]: _hostDefined_ }.
- 1. Perform InnerModuleLoading(_state_, _module_).
+ 1. Perform InnerModuleLoading(_state_, _module_, ~recursive-load~).
1. Return _pc_.[[Promise]].
@@ -26891,6 +26956,7 @@
InnerModuleLoading (
_state_: a GraphLoadingState Record,
_module_: a Module Record,
+ _loadType_: ~single~ or ~recursive-load~,
): ~unused~
@@ -28400,6 +28471,22 @@
+
+ GetModuleSource ( ): either a normal completion containing an Object or a throw completion
+
+
+ 1. Throw a *SyntaxError* exception.
+
+
+
InitializeEnvironment ( ): either a normal completion containing ~unused~ or a throw completion
+ The completion record returned by this operation must not be affected by _moduleRequest_.[[Phase]].
+
The operation must treat _payload_ as an opaque value to be passed through to FinishLoadingImportedModule.
The actual process performed is host-defined, but typically consists of performing whatever I/O operations are necessary to load the appropriate Module Record. Multiple different (_referrer_, _moduleRequest_.[[Specifier]], _moduleRequest_.[[Attributes]]) triples may map to the same Module Record instance. The actual mapping semantics is host-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 expansion of relative and abbreviated path specifiers.
+
+
+ Implementations may provide unobservable module loading optimizations, such as speculative preloading of modules that are likely to be requested next. When doing so, they should consider whether the module is being imported for its ~source~ phase, which won't cause calls to the HostLoadImportedModule hook for its transitive dependencies, or for its ~evaluation~ phase, which will.
+
@@ -28587,13 +28685,35 @@
1. Else,
1. Append the LoadedModuleRequest Record { [[Specifier]]: _moduleRequest_.[[Specifier]], [[Attributes]]: _moduleRequest_.[[Attributes]], [[Module]]: _result_.[[Value]] } to _referrer_.[[LoadedModules]].
1. If _payload_ is a GraphLoadingState Record, then
- 1. Perform ContinueModuleLoading(_payload_, _result_).
+ 1. Perform ContinueModuleLoading(_payload_, _moduleRequest_.[[Phase]], _result_).
1. Else,
- 1. Perform ContinueDynamicImport(_payload_, _result_).
+ 1. Perform ContinueDynamicImport(_payload_, _moduleRequest_.[[Phase]], _result_).
1. Return ~unused~.
+
+
+ HostGetModuleSourceName (
+ _moduleSource_: an Object,
+ ): either a normal completion containing a String or a throw completion
+
+
+
+ An implementation of HostGetModuleSourceName must conform to the following requirements:
+
+ -
+ For any object that is a Module Source Object, returns a normal completion for a String corresponding to the source record type to be used as the strongly branded return value of the @@toStringTag getter on %AbstractModuleSource%.
+
+ -
+ For any object which is not a Module Source Object, returns a throw completion.
+
+
+
+
AllImportAttributesSupported (
@@ -28696,6 +28816,7 @@ Syntax
ImportDeclaration :
`import` ImportClause FromClause WithClause? `;`
`import` ModuleSpecifier WithClause? `;`
+ `import` `source` ImportedBinding FromClause WithClause? `;`
ImportClause :
ImportedDefaultBinding
@@ -28793,6 +28914,13 @@ Static Semantics: ImportEntries ( ): a List of ImportEntry Records
1. Return a new empty List.
+ ImportDeclaration : `import` `source` ImportedBinding FromClause WithClause? `;`
+
+ 1. Let _module_ be the sole element of the ModuleRequests of |ImportDeclaration|.
+ 1. Let _localName_ be the sole element of BoundNames of |ImportedBinding|.
+ 1. Let _entry_ be the ImportEntry Record { [[ModuleRequest]]: _module_, [[ImportName]]: ~source~, [[LocalName]]: _localName_ }.
+ 1. Return « _entry_ ».
+
@@ -49541,6 +49669,82 @@ %Symbol.toStringTag%
This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *false* }.
+
+
+ Module Source Objects
+ Module Source Objects represent modules in their source import phase, which are not linked, instantiated or executed.
+ A Module Source Object is an object for which HostGetModuleSourceName returns a normal completion.
+ All Module Source Objects should have a prototype of %AbstractModuleSource%.prototype.
+ Hosts may define their own %AbstractModuleSource% subclasses for custom module types.
+
+
+ The AbstractModuleSource Constructor
+ The AbstractModuleSource constructor:
+
+ - is %AbstractModuleSource%.
+ - along with its corresponding prototype object, provides common properties that are inherited by Module Source constructors and their instances.
+ - does not have a global name or appear as a property of the global object.
+ - acts as a common superclass of the constructors of Module Source Objects.
+ - will throw an error when invoked, because it is an abstract class constructor. The module source constructors do not perform a `super` call to it.
+
+
+
+ AbstractModuleSource ( )
+ This function performs the following steps when called:
+
+ 1. Throw a *TypeError* exception.
+
+
+
+
+
+ Properties of the %AbstractModuleSource% Intrinsic Object
+ The %AbstractModuleSource% intrinsic object:
+
+ - has a [[Prototype]] internal slot whose value is %Function.prototype%.
+ - has a *"name"* property whose value is *"AbstractModuleSource"*.
+ - has the following properties:
+
+
+
+ %AbstractModuleSource%.prototype
+ The initial value of %AbstractModuleSource%`.prototype` is the %AbstractModuleSource% prototype object.
+ This property has the attributes { [[Writable]]: *false*, [[Enumerable]]: *false*, [[Configurable]]: *false* }.
+
+
+
+
+ Properties of the %AbstractModuleSource% Prototype Object
+ The %AbstractModuleSource% prototype object:
+
+ - has a [[Prototype]] internal slot whose value is %Object.prototype%.
+ - is %AbstractModuleSource.prototype%.
+ - is an ordinary object.
+ - has the following properties:
+
+
+
+ %AbstractModuleSource%.prototype.constructor
+ The initial value of %AbstractModuleSource%`.prototype.constructor` is %AbstractModuleSource%.
+
+
+
+ get %AbstractModuleSource%.prototype [ @@toStringTag ]
+ %AbstractModuleSource%.prototype `[@@toStringTag]` is an accessor property whose set accessor function is *undefined*. Its get accessor function performs the following steps when called:
+
+ 1. Let _O_ be the *this* value.
+ 1. If _O_ is not an Object, return *undefined*.
+ 1. Let _sourceNameResult_ be Completion(HostGetModuleSourceName(_O_)).
+ 1. If _sourceNameResult_ is an abrupt completion, return *undefined*.
+ 1. Let _name_ be ! _sourceNameResult_.
+ 1. Assert: _name_ is a String.
+ 1. Return _name_.
+
+ This property has the attributes { [[Enumerable]]: *false*, [[Configurable]]: *true* }.
+ The initial value of the *"name"* property of this function is *"get [Symbol.toStringTag]"*.
+
+
+
@@ -51794,6 +51998,7 @@ Host Hooks
HostEnsureCanCompileStrings(...)
HostFinalizeImportMeta(...)
HostGetImportMetaProperties(...)
+ HostGetModuleSourceName(...)
HostGrowSharedArrayBuffer(...)
HostHasSourceTextAvailable(...)
HostLoadImportedModule(...)