From 52fed39afb49d8f9ad64ccdb514d0507cc7d9015 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Thu, 8 Jun 2023 20:27:33 +0200 Subject: [PATCH 01/10] Normative: Add Source Phase Imports --- spec.html | 373 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 312 insertions(+), 61 deletions(-) diff --git a/spec.html b/spec.html index 4b3f04c202..540e776fe7 100644 --- a/spec.html +++ b/spec.html @@ -18754,6 +18754,7 @@

Syntax

ImportCall[Yield, Await] : `import` `(` AssignmentExpression[+In, ?Yield, ?Await] `)` + `import` `.` `source` `(` AssignmentExpression[+In, ?Yield, ?Await] `)` Arguments[Yield, Await] : `(` `)` @@ -19316,21 +19317,41 @@

Runtime Semantics: Evaluation

ImportCall : `import` `(` AssignmentExpression `)` - 1. Let _referrer_ be GetActiveScriptOrModule(). - 1. If _referrer_ is *null*, set _referrer_ to the current Realm Record. - 1. Let _argRef_ be ? Evaluation of |AssignmentExpression|. - 1. Let _specifier_ be ? GetValue(_argRef_). - 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). - 1. Let _specifierString_ be Completion(ToString(_specifier_)). - 1. IfAbruptRejectPromise(_specifierString_, _promiseCapability_). - 1. Perform HostLoadImportedModule(_referrer_, _specifierString_, ~empty~, _promiseCapability_). - 1. Return _promiseCapability_.[[Promise]]. + 1. Return ? EvaluateImportCall(|AssignmentExpression|, ~evaluation~). + + + ImportCall : `import` `.` `source` `(` AssignmentExpression[+In, ?Yield, ?Await] `)` + + 1. Return ? EvaluateImportCall(|AssignmentExpression|, ~source~). + +

+ EvaluateImportCall ( + _specifierExpression_: a ParseNode, + _phase_: ~source~ or ~evaluation~ + ): either a normal completion containing a Promise or a throw completion +

+
+ + 1. Let _referrer_ be GetActiveScriptOrModule(). + 1. If _referrer_ is *null*, set _referrer_ to the current Realm Record. + 1. Let _specifierRef_ be the result of evaluating _specifierExpression_. + 1. Let _specifier_ be ? GetValue(_specifierRef_). + 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). + 1. Let _specifierString_ be Completion(ToString(_specifier_)). + 1. IfAbruptRejectPromise(_specifierString_, _promiseCapability_). + 1. Let _moduleRequest_ be a new ModuleRequest Record { [[Specifier]]: _specifierString_, [[Phase]]: _phase_ }. + 1. Perform HostLoadImportedModule(_referrer_, _moduleRequest_, ~empty~, _promiseCapability_). + 1. Return _promiseCapability_.[[Promise]]. + +
+

ContinueDynamicImport ( _promiseCapability_: a PromiseCapability Record, + _phase_: ~source~ or ~evaluation~, _moduleCompletion_: either a normal completion containing a Module Record or a throw completion, ): ~unused~

@@ -19343,6 +19364,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_ »). @@ -25895,8 +25923,54 @@

+ +

ModuleRequest Records

+

A ModuleRequest Record represents the request to import a module up to a given phase. It consists of the following fields:

+ + + + + + + + + + + + + + + + + + + +
+ Field Name + + Value Type + + Meaning +
+ [[Specifier]] + + String + + The module specifier +
+ [[Phase]] + + ~source~ or ~evaluation~ + + The target import phase +
+
+ + In general, this proposal replaces places where module specifiers are passed around with ModuleRequest Records. For example, several syntax-directed operations, such as ModuleRequests produce Lists of ModuleRequest Records rather than Lists of Strings which are interpreted as module specifiers. Some algorithms like ImportEntries and ImportEntriesForModule pass around ModuleRequest Records rather than Strings, in a way which doesn't require any particular textual change. Additionally, record fields in Cyclic Module Records and Source Text Module Records which contained Lists of Strings are replaced by Lists of ModuleRequest Records, as indicated above. +
+ -

Static Semantics: ModuleRequests ( ): a List of Strings

+

Static Semantics: ModuleRequests ( ): a List of ModuleRequest Records

Module : [empty] @@ -25909,12 +25983,17 @@

Static Semantics: ModuleRequests ( ): a List of Strings

ModuleItemList : ModuleItemList ModuleItem - 1. Let _moduleNames_ be ModuleRequests of |ModuleItemList|. - 1. Let _additionalNames_ be ModuleRequests of |ModuleItem|. - 1. For each String _name_ of _additionalNames_, do - 1. If _moduleNames_ does not contain _name_, then - 1. Append _name_ to _moduleNames_. - 1. Return _moduleNames_. + 1. Let _requests_ be ModuleRequests of |ModuleItemList|. + 1. Let _additionalRequests_ be ModuleRequests of |ModuleItem|. + 1. For each ModuleRequest Record _mr_ of _additionalRequests_, do + 1. Let _found_ be *false*. + 1. For each ModuleRequest Record _mr2_ of _requests_, do + 1. If _mr_.[[Specifer]] is _mr2_.[[Specifer]] and _mr_.[[Phase]] is _mr2_.[[Phase]], then + 1. Assert: _found_ is *false*. + 1. Set _found_ to *true*. + 1. If _found_ is *false*, then + 1. Append _mr_ to _requests_. + 1. Return _requests_. ModuleItem : StatementListItem @@ -25922,17 +26001,20 @@

Static Semantics: ModuleRequests ( ): a List of Strings

ImportDeclaration : `import` ImportClause FromClause `;` - 1. Return ModuleRequests of |FromClause|. + 1. Let _specifier_ be SV of |FromClause|. + 1. Return a List whose sole element is the ModuleRequest Record { [[Specifer]]: _specifier_, [[Phase]]: ~evaluation~ }. - ModuleSpecifier : StringLiteral + ImportDeclaration : `import` `source` ImportedBinding FromClause `;` - 1. Return a List whose sole element is the SV of |StringLiteral|. + 1. Let _specifier_ be SV of |FromClause|. + 1. Return a List whose sole element is the ModuleRequest Record { [[Specifer]]: _specifier_, [[Phase]]: ~source~ }. ExportDeclaration : `export` ExportFromClause FromClause `;` - 1. Return the ModuleRequests of |FromClause|. + 1. Let _specifier_ be SV of |FromClause|. + 1. Return a List whose sole element is the ModuleRequest Record { [[Specifer]]: _specifier_, [[Phase]]: ~evaluation~ }. ExportDeclaration : @@ -25948,6 +26030,40 @@

Static Semantics: ModuleRequests ( ): a List of Strings

+ +

ModuleSource Records

+ +

A ModuleSource Record represents the request to import a module up to a given phase. It consists of the following fields:

+ + + + + + + + + + + + + + +
+ Field Name + + Value Type + + Meaning +
+ [[SourceClassName]] + + String + + The unique source class name string used to represent this module source. Source Text Module Records are usually represented by the *"ModuleSource"* class. +
+
+
+

Abstract Module Records

A Module Record encapsulates structural information about the imports and exports of a single module. This information is used to link the imports and exports of sets of connected modules. A Module Record includes four fields that are only used when evaluating a module.

@@ -26024,6 +26140,17 @@

Abstract Module Records

Purpose + + + GetModuleSource() + + +

It returns either a normal completion completion for the ModuleSource 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 be an instance of a subclass of %AbstractModuleSource%, and it must have an internal slot [[ModuleSourceRecord]].

+

Module Record's that do not have a source represemtation must always return a throw completion containing a *ReferenceError*.

+ + LoadRequestedModules( [ _hostDefined_ ] ) @@ -26139,10 +26266,10 @@

Cyclic Module Records

[[RequestedModules]] - a List of Strings + a List of ModuleRequest Records - A List of all the |ModuleSpecifier| strings used by the module represented by this record to request the importation of a module. The List is in source text occurrence order. + A List of all the |ModuleSpecifier| strings used by the module represented by this record to request the importation of a module, along with their associated phase (~source~ or ~evaluation~). The List is in source text occurrence order. @@ -26344,7 +26471,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_, *true*). 1. Return _pc_.[[Promise]]. @@ -26358,6 +26485,7 @@

InnerModuleLoading ( _state_: a GraphLoadingState Record, _module_: a Module Record, + _loadRecursively_: a Boolean ): ~unused~

@@ -26367,14 +26495,16 @@

1. Assert: _state_.[[IsLoading]] is *true*. - 1. If _module_ is a Cyclic Module Record, _module_.[[Status]] is ~new~, and _state_.[[Visited]] does not contain _module_, then + 1. If _module_ is a Cyclic Module Record, _module_.[[Status]] is ~new~, _state_.[[Visited]] does not contain _module_, and _loadRecursively_ is *true*, then 1. Append _module_ to _state_.[[Visited]]. 1. Let _requestedModulesCount_ be the number of elements in _module_.[[RequestedModules]]. 1. Set _state_.[[PendingModulesCount]] to _state_.[[PendingModulesCount]] + _requestedModulesCount_. - 1. For each String _required_ of _module_.[[RequestedModules]], do - 1. If _module_.[[LoadedModules]] contains a Record whose [[Specifier]] is _required_, then + 1. For each ModuleRequest Record _required_ of _module_.[[RequestedModules]], do + 1. If _module_.[[LoadedModules]] contains a Record whose [[Specifier]] is _required_.[[Specifier]], then 1. Let _record_ be that Record. - 1. Perform InnerModuleLoading(_state_, _record_.[[Module]]). + 1. Let _innerLoadRecursively_ be *true*. + 1. If _required_.[[Phase]] is ~source~ set _innerLoadRecursively_ to *false*. + 1. Perform InnerModuleLoading(_state_, _record_.[[Module]], _innerLoadRecursively_). 1. Else, 1. Perform HostLoadImportedModule(_module_, _required_, _state_.[[HostDefined]], _state_). 1. NOTE: HostLoadImportedModule will call FinishLoadingImportedModule, which re-enters the graph loading process through ContinueModuleLoading. @@ -26394,6 +26524,7 @@

ContinueModuleLoading ( _state_: a GraphLoadingState Record, + _phase_: ~source~ or ~evaluation~, _moduleCompletion_: either a normal completion containing a Module Record or a throw completion, ): ~unused~

@@ -26405,7 +26536,9 @@

1. If _state_.[[IsLoading]] is *false*, return ~unused~. 1. If _moduleCompletion_ is a normal completion, then - 1. Perform InnerModuleLoading(_state_, _moduleCompletion_.[[Value]]). + 1. Let _loadRecursively_ be *true*. + 1. If _phase_ is ~source~ set _loadRecursively_ to *false*. + 1. Perform InnerModuleLoading(_state_, _moduleCompletion_.[[Value]], _loadRecursively_). 1. Else, 1. Set _state_.[[IsLoading]] to *false*. 1. Perform ! Call(_state_.[[PromiseCapability]].[[Reject]], *undefined*, « _moduleCompletion_.[[Value]] »). @@ -26464,14 +26597,15 @@

1. Set _module_.[[DFSAncestorIndex]] to _index_. 1. Set _index_ to _index_ + 1. 1. Append _module_ to _stack_. - 1. For each String _required_ of _module_.[[RequestedModules]], do - 1. Let _requiredModule_ be GetImportedModule(_module_, _required_). - 1. Set _index_ to ? InnerModuleLinking(_requiredModule_, _stack_, _index_). - 1. If _requiredModule_ is a Cyclic Module Record, then - 1. Assert: _requiredModule_.[[Status]] is one of ~linking~, ~linked~, ~evaluating-async~, or ~evaluated~. - 1. Assert: _requiredModule_.[[Status]] is ~linking~ if and only if _stack_ contains _requiredModule_. - 1. If _requiredModule_.[[Status]] is ~linking~, then - 1. Set _module_.[[DFSAncestorIndex]] to min(_module_.[[DFSAncestorIndex]], _requiredModule_.[[DFSAncestorIndex]]). + 1. For each ModuleRequest Record _required_ of _module_.[[RequestedModules]], do + 1. If _required_.[[Phase]] is ~evaluation~, then + 1. Let _requiredModule_ be GetImportedModule(_module_, _required_.[[Specifier]]). + 1. Set _index_ to ? InnerModuleLinking(_requiredModule_, _stack_, _index_). + 1. If _requiredModule_ is a Cyclic Module Record, then + 1. Assert: _requiredModule_.[[Status]] is one of ~linking~, ~linked~, ~evaluating-async~, or ~evaluated~. + 1. Assert: _requiredModule_.[[Status]] is ~linking~ if and only if _stack_ contains _requiredModule_. + 1. If _requiredModule_.[[Status]] is ~linking~, then + 1. Set _module_.[[DFSAncestorIndex]] to min(_module_.[[DFSAncestorIndex]], _requiredModule_.[[DFSAncestorIndex]]). 1. Perform ? _module_.InitializeEnvironment(). 1. Assert: _module_ occurs exactly once in _stack_. 1. Assert: _module_.[[DFSAncestorIndex]] ≤ _module_.[[DFSIndex]]. @@ -26557,21 +26691,22 @@

1. Set _module_.[[PendingAsyncDependencies]] to 0. 1. Set _index_ to _index_ + 1. 1. Append _module_ to _stack_. - 1. For each String _required_ of _module_.[[RequestedModules]], do - 1. Let _requiredModule_ be GetImportedModule(_module_, _required_). - 1. Set _index_ to ? InnerModuleEvaluation(_requiredModule_, _stack_, _index_). - 1. If _requiredModule_ is a Cyclic Module Record, then - 1. Assert: _requiredModule_.[[Status]] is one of ~evaluating~, ~evaluating-async~, or ~evaluated~. - 1. Assert: _requiredModule_.[[Status]] is ~evaluating~ if and only if _stack_ contains _requiredModule_. - 1. If _requiredModule_.[[Status]] is ~evaluating~, then - 1. Set _module_.[[DFSAncestorIndex]] to min(_module_.[[DFSAncestorIndex]], _requiredModule_.[[DFSAncestorIndex]]). - 1. Else, - 1. Set _requiredModule_ to _requiredModule_.[[CycleRoot]]. - 1. Assert: _requiredModule_.[[Status]] is either ~evaluating-async~ or ~evaluated~. - 1. If _requiredModule_.[[EvaluationError]] is not ~empty~, return ? _requiredModule_.[[EvaluationError]]. - 1. If _requiredModule_.[[AsyncEvaluation]] is *true*, then - 1. Set _module_.[[PendingAsyncDependencies]] to _module_.[[PendingAsyncDependencies]] + 1. - 1. Append _module_ to _requiredModule_.[[AsyncParentModules]]. + 1. For each ModuleRequest Record _required_ of _module_.[[RequestedModules]], do + 1. Let _requiredModule_ be GetImportedModule(_module_, _required_.[[Specifier]]). + 1. If _requiredModule_.[[Phase]] is ~evaluation~, then + 1. Set _index_ to ? InnerModuleEvaluation(_requiredModule_, _stack_, _index_). + 1. If _requiredModule_ is a Cyclic Module Record, then + 1. Assert: _requiredModule_.[[Status]] is one of ~evaluating~, ~evaluating-async~, or ~evaluated~. + 1. Assert: _requiredModule_.[[Status]] is ~evaluating~ if and only if _stack_ contains _requiredModule_. + 1. If _requiredModule_.[[Status]] is ~evaluating~, then + 1. Set _module_.[[DFSAncestorIndex]] to min(_module_.[[DFSAncestorIndex]], _requiredModule_.[[DFSAncestorIndex]]). + 1. Else, + 1. Set _requiredModule_ to _requiredModule_.[[CycleRoot]]. + 1. Assert: _requiredModule_.[[Status]] is either ~evaluating-async~ or ~evaluated~. + 1. If _requiredModule_.[[EvaluationError]] is not ~empty~, return ? _requiredModule_.[[EvaluationError]]. + 1. If _requiredModule_.[[AsyncEvaluation]] is *true*, then + 1. Set _module_.[[PendingAsyncDependencies]] to _module_.[[PendingAsyncDependencies]] + 1. + 1. Append _module_ to _requiredModule_.[[AsyncParentModules]]. 1. If _module_.[[PendingAsyncDependencies]] > 0 or _module_.[[HasTLA]] is *true*, then 1. Assert: _module_.[[AsyncEvaluation]] is *false* and was never previously set to *true*. 1. Set _module_.[[AsyncEvaluation]] to *true*. @@ -27668,6 +27803,25 @@

+ +

+ GetModuleSource ( ): either a normal completion containing an Object or a throw completion +

+
+
for
+
a Source Text Module Record _module_
+ +
description
+
+

Source Text Module Record provides a GetModuleSource implementation with an abrupt completion to provide a standard reference error that a source phase import is not available.

+
+
+ + 1. Let _error_ be a newly created *ReferenceError* object. + 1. Return ThrowCompletion(_error_). + +
+

GetExportedNames ( @@ -27790,6 +27944,10 @@

InitializeEnvironment ( ): either a normal completion containing ~unused~ or 1. Let _namespace_ be GetModuleNamespace(_importedModule_). 1. Perform ! _env_.CreateImmutableBinding(_in_.[[LocalName]], *true*). 1. Perform ! _env_.InitializeBinding(_in_.[[LocalName]], _namespace_). + 1. Else if _in_.[[ImportName]] is ~source~, then + 1. Let _moduleSourceObject_ be ? _importedModule_.GetModuleSource(). + 1. Perform ! _env_.CreateImmutableBinding(_in_.[[LocalName]], *true*). + 1. Perform ! _env_.InitializeBinding(_in_.[[LocalName]], _moduleSourceObject_). 1. Else, 1. Let _resolution_ be _importedModule_.ResolveExport(_in_.[[ImportName]]). 1. If _resolution_ is either *null* or ~ambiguous~, throw a *SyntaxError* exception. @@ -27893,7 +28051,7 @@

HostLoadImportedModule ( _referrer_: a Script Record, a Cyclic Module Record, or a Realm Record, - _specifier_: a String, + _moduleRequest_: a ModuleRequest Record, _hostDefined_: anything, _payload_: a GraphLoadingState Record or a PromiseCapability Record, ): ~unused~ @@ -27914,24 +28072,31 @@

An implementation of HostLoadImportedModule must conform to the following requirements:

  • - The host environment must perform FinishLoadingImportedModule(_referrer_, _specifier_, _payload_, _result_), where _result_ is either a normal completion containing the loaded Module Record or a throw completion, either synchronously or asynchronously. + The host environment must perform FinishLoadingImportedModule(_referrer_, _moduleRequest_, _payload_, _result_), where _result_ is either a normal completion containing the loaded Module Record or a throw completion, either synchronously or asynchronously. +
  • +
  • + If this operation is called multiple times with the same (_referrer_, _moduleRequest_.[[Specifier]]) pair and it performs FinishLoadingImportedModule(_referrer_, _moduleRequest_, _payload_, _result_) where _result_ is a normal completion, then it must perform FinishLoadingImportedModule(_referrer_, _moduleRequest_, _payload_, _result_) with the same _result_ each time.
  • - If this operation is called multiple times with the same (_referrer_, _specifier_) pair and it performs FinishLoadingImportedModule(_referrer_, _specifier_, _payload_, _result_) where _result_ is a normal completion, then it must perform FinishLoadingImportedModule(_referrer_, _specifier_, _payload_, _result_) with the same _result_ each time. + 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_, _specifier_) pairs 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.

+

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]]) pairs 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.

+

FinishLoadingImportedModule ( _referrer_: a Script Record, a Cyclic Module Record, or a Realm Record, - _specifier_: a String, + _moduleRequest_: a ModuleRequest Record, _payload_: a GraphLoadingState Record or a PromiseCapability Record, _result_: either a normal completion containing a Module Record or a throw completion, ): ~unused~ @@ -27942,14 +28107,14 @@

1. If _result_ is a normal completion, then - 1. If _referrer_.[[LoadedModules]] contains a Record whose [[Specifier]] is _specifier_, then + 1. If _referrer_.[[LoadedModules]] contains a Record whose [[Specifier]] is _moduleRequest_.[[Specifier]], then 1. Assert: That Record's [[Module]] is _result_.[[Value]]. 1. Else, - 1. Append the Record { [[Specifier]]: _specifier_, [[Module]]: _result_.[[Value]] } to _referrer_.[[LoadedModules]]. + 1. Append the Record { [[Specifier]]: _moduleRequest_.[[Specifier]], [[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~.
@@ -28018,6 +28183,7 @@

Syntax

ImportDeclaration : `import` ImportClause FromClause `;` `import` ModuleSpecifier `;` + `import` `source` ImportedBinding FromClause `;` ImportClause : ImportedDefaultBinding @@ -28089,13 +28255,20 @@

Static Semantics: ImportEntries ( ): a List of ImportEntry Records

ImportDeclaration : `import` ImportClause FromClause `;` - 1. Let _module_ be the sole element of ModuleRequests of |FromClause|. + 1. Let _module_ be the SV of |FromClause|. 1. Return ImportEntriesForModule of |ImportClause| with argument _module_. ImportDeclaration : `import` ModuleSpecifier `;` 1. Return a new empty List. + ImportDeclaration : `import` `source` ImportedBinding FromClause `;` + + 1. Let _module_ be the SV of |FromClause|. + 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_ ». +
@@ -46724,6 +46897,83 @@

Proxy.revocable ( _target_, _handler_ )

+ +

Module Source Objects

+

Module Source Objects represent modules in their source import phase, which are not linked, instantiated or executed.

+

All Module Source Objects should have a prototype of %AbstractModuleSource%.prototype and must define a [[ModuleSourceRecord]] internal slot.

+

Hosts may define their own Module Source subclasses for custom module record 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 the abstract superclass of the _ModuleSource_ constructor.
  • +
  • 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. + +

The *"length"* property of this function is *+0*𝔽.

+
+
+ + +

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.
  • +
  • does not have a global name or appear as a property of the global object.
  • +
  • does not have a [[ModuleSourceRecord]] slot that is specific to _AbstractModuleSource_ and _AbstractModuleSource_ subclass instance objects.
  • +
  • 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. If _O_ does not have a [[ModuleSourceRecord]] internal slot, return *undefined*. + 1. Let _name_ be _O_.[[ModuleSourceRecord]].[[SourceClassName]]. + 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]"*.

+
+
+
+

Module Namespace Objects

A Module Namespace Object is a module namespace exotic object that provides runtime property-based access to a module's exported bindings. There is no constructor function for Module Namespace Objects. Instead, such an object is created for each module that is imported by an |ImportDeclaration| that contains a |NameSpaceImport|.

@@ -48976,6 +49226,7 @@

Host-defined Fields

[[HostDefined]] on Realm Records: See .

[[HostDefined]] on Script Records: See .

[[HostDefined]] on Module Records: See .

+

[[HostDefined]] on ModuleSource Records: See .

[[HostDefined]] on JobCallback Records: See .

[[HostSynchronizesWith]] on Candidate Executions: See .

[[IsHTMLDDA]]: See .

From c0e32473127b7e869501fba5ff8ec7b0e1d7db73 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Thu, 29 Jun 2023 20:41:07 +0200 Subject: [PATCH 02/10] loadRecursively bool -> loadType enum --- spec.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/spec.html b/spec.html index 540e776fe7..e9160985f8 100644 --- a/spec.html +++ b/spec.html @@ -26485,7 +26485,7 @@

InnerModuleLoading ( _state_: a GraphLoadingState Record, _module_: a Module Record, - _loadRecursively_: a Boolean + _loadType_: ~single~ or ~recursive~ ): ~unused~

@@ -26495,16 +26495,16 @@

1. Assert: _state_.[[IsLoading]] is *true*. - 1. If _module_ is a Cyclic Module Record, _module_.[[Status]] is ~new~, _state_.[[Visited]] does not contain _module_, and _loadRecursively_ is *true*, then + 1. If _module_ is a Cyclic Module Record, _module_.[[Status]] is ~new~, _state_.[[Visited]] does not contain _module_, and _loadType_ is ~recursive~, then 1. Append _module_ to _state_.[[Visited]]. 1. Let _requestedModulesCount_ be the number of elements in _module_.[[RequestedModules]]. 1. Set _state_.[[PendingModulesCount]] to _state_.[[PendingModulesCount]] + _requestedModulesCount_. 1. For each ModuleRequest Record _required_ of _module_.[[RequestedModules]], do 1. If _module_.[[LoadedModules]] contains a Record whose [[Specifier]] is _required_.[[Specifier]], then 1. Let _record_ be that Record. - 1. Let _innerLoadRecursively_ be *true*. - 1. If _required_.[[Phase]] is ~source~ set _innerLoadRecursively_ to *false*. - 1. Perform InnerModuleLoading(_state_, _record_.[[Module]], _innerLoadRecursively_). + 1. Let _innerLoadType_ be ~recursive~. + 1. If _required_.[[Phase]] is ~source~, set _innerLoadType_ to ~single~. + 1. Perform InnerModuleLoading(_state_, _record_.[[Module]], _innerLoadType_). 1. Else, 1. Perform HostLoadImportedModule(_module_, _required_, _state_.[[HostDefined]], _state_). 1. NOTE: HostLoadImportedModule will call FinishLoadingImportedModule, which re-enters the graph loading process through ContinueModuleLoading. @@ -26536,9 +26536,9 @@

1. If _state_.[[IsLoading]] is *false*, return ~unused~. 1. If _moduleCompletion_ is a normal completion, then - 1. Let _loadRecursively_ be *true*. - 1. If _phase_ is ~source~ set _loadRecursively_ to *false*. - 1. Perform InnerModuleLoading(_state_, _moduleCompletion_.[[Value]], _loadRecursively_). + 1. Let _loadType_ be ~recursive~. + 1. If _phase_ is ~source~, set _loadType_ to ~single~. + 1. Perform InnerModuleLoading(_state_, _moduleCompletion_.[[Value]], _loadType_). 1. Else, 1. Set _state_.[[IsLoading]] to *false*. 1. Perform ! Call(_state_.[[PromiseCapability]].[[Reject]], *undefined*, « _moduleCompletion_.[[Value]] »). From 78c0396e09969787722988114f320e3bc0d6d3b1 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Thu, 29 Jun 2023 20:41:36 +0200 Subject: [PATCH 03/10] fix throw completion --- spec.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec.html b/spec.html index e9160985f8..1e56a1878f 100644 --- a/spec.html +++ b/spec.html @@ -26148,7 +26148,7 @@

Abstract Module Records

It returns either a normal completion completion for the ModuleSource 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 be an instance of a subclass of %AbstractModuleSource%, and it must have an internal slot [[ModuleSourceRecord]].

-

Module Record's that do not have a source represemtation must always return a throw completion containing a *ReferenceError*.

+

For Module Records that do not have a source representation, GetModuleSource() must always return a throw completion whose [[Value]] is a *ReferenceError*.

From 56b73385fe32f2e0d5b7ed3cbfb7f3d32fc045a5 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Thu, 29 Jun 2023 20:43:58 +0200 Subject: [PATCH 04/10] Remove Module Source Record --- spec.html | 43 ++++--------------------------------------- 1 file changed, 4 insertions(+), 39 deletions(-) diff --git a/spec.html b/spec.html index 1e56a1878f..e62d3f62d5 100644 --- a/spec.html +++ b/spec.html @@ -26030,40 +26030,6 @@

Static Semantics: ModuleRequests ( ): a List of ModuleRequest Records

- -

ModuleSource Records

- -

A ModuleSource Record represents the request to import a module up to a given phase. It consists of the following fields:

- - - - - - - - - - - - - - -
- Field Name - - Value Type - - Meaning -
- [[SourceClassName]] - - String - - The unique source class name string used to represent this module source. Source Text Module Records are usually represented by the *"ModuleSource"* class. -
-
-
-

Abstract Module Records

A Module Record encapsulates structural information about the imports and exports of a single module. This information is used to link the imports and exports of sets of connected modules. A Module Record includes four fields that are only used when evaluating a module.

@@ -26147,7 +26113,7 @@

Abstract Module Records

It returns either a normal completion completion for the ModuleSource 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 be an instance of a subclass of %AbstractModuleSource%, and it must have an internal slot [[ModuleSourceRecord]].

+

The returned object should be an instance of a subclass of %AbstractModuleSource%, and it must have an internal slot [[ModuleSourceClassName]].

For Module Records that do not have a source representation, GetModuleSource() must always return a throw completion whose [[Value]] is a *ReferenceError*.

@@ -46900,7 +46866,7 @@

Proxy.revocable ( _target_, _handler_ )

Module Source Objects

Module Source Objects represent modules in their source import phase, which are not linked, instantiated or executed.

-

All Module Source Objects should have a prototype of %AbstractModuleSource%.prototype and must define a [[ModuleSourceRecord]] internal slot.

+

All Module Source Objects should have a prototype of %AbstractModuleSource%.prototype and must define a [[ModuleSourceClassName]] internal slot.

Hosts may define their own Module Source subclasses for custom module record types.

@@ -46963,8 +46929,8 @@

get %AbstractModuleSource%.prototype [ @@toStringTag ]

1. Let _O_ be the *this* value. 1. If _O_ is not an Object, return *undefined*. - 1. If _O_ does not have a [[ModuleSourceRecord]] internal slot, return *undefined*. - 1. Let _name_ be _O_.[[ModuleSourceRecord]].[[SourceClassName]]. + 1. If _O_ does not have a [[ModuleSourceClassName]] internal slot, return *undefined*. + 1. Let _name_ be _O_.[[ModuleSourceClassName]]. 1. Assert: _name_ is a String. 1. Return _name_. @@ -49226,7 +49192,6 @@

Host-defined Fields

[[HostDefined]] on Realm Records: See .

[[HostDefined]] on Script Records: See .

[[HostDefined]] on Module Records: See .

-

[[HostDefined]] on ModuleSource Records: See .

[[HostDefined]] on JobCallback Records: See .

[[HostSynchronizesWith]] on Candidate Executions: See .

[[IsHTMLDDA]]: See .

From 50ddac9466d6704a06f50f95fc7d65546bcbdd84 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Thu, 29 Jun 2023 20:44:07 +0200 Subject: [PATCH 05/10] other typos --- spec.html | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/spec.html b/spec.html index e62d3f62d5..b18667809f 100644 --- a/spec.html +++ b/spec.html @@ -19328,7 +19328,7 @@

Runtime Semantics: Evaluation

EvaluateImportCall ( - _specifierExpression_: a ParseNode, + _specifierExpression_: a Parse Node, _phase_: ~source~ or ~evaluation~ ): either a normal completion containing a Promise or a throw completion

@@ -19336,7 +19336,7 @@

1. Let _referrer_ be GetActiveScriptOrModule(). 1. If _referrer_ is *null*, set _referrer_ to the current Realm Record. - 1. Let _specifierRef_ be the result of evaluating _specifierExpression_. + 1. Let _specifierRef_ be ? Evaluation of _specifierExpression_. 1. Let _specifier_ be ? GetValue(_specifierRef_). 1. Let _promiseCapability_ be ! NewPromiseCapability(%Promise%). 1. Let _specifierString_ be Completion(ToString(_specifier_)). @@ -25925,7 +25925,7 @@

ModuleRequest Records

-

A ModuleRequest Record represents the request to import a module up to a given phase. It consists of the following fields:

+

A ModuleRequest Record represents a request to import a module up to a given phase. It consists of the following fields:

@@ -26111,7 +26111,7 @@

Abstract Module Records

GetModuleSource() @@ -28054,7 +28054,7 @@

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]]) pairs 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.

+

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.

@@ -46886,7 +46886,6 @@

%AbstractModuleSource% ( )

1. Throw a *TypeError* exception. -

The *"length"* property of this function is *+0*𝔽.

@@ -46914,7 +46913,6 @@

Properties of the %AbstractModuleSource% Prototype Object

  • is %AbstractModuleSource.prototype%.
  • is an ordinary object.
  • does not have a global name or appear as a property of the global object.
  • -
  • does not have a [[ModuleSourceRecord]] slot that is specific to _AbstractModuleSource_ and _AbstractModuleSource_ subclass instance objects.
  • has the following properties:
  • @@ -46924,7 +46922,7 @@

    %AbstractModuleSource%.prototype.constructor

    -

    get %AbstractModuleSource%.prototype [ @@toStringTag ]

    +

    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. From 0a558892268eb9004754ef1adf009c431de228e8 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Thu, 29 Jun 2023 20:51:12 +0200 Subject: [PATCH 06/10] Fix load type enum --- spec.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec.html b/spec.html index b18667809f..cdea9510b4 100644 --- a/spec.html +++ b/spec.html @@ -26437,7 +26437,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_, *true*). + 1. Perform InnerModuleLoading(_state_, _module_, ~recursive-load~). 1. Return _pc_.[[Promise]]. @@ -26451,7 +26451,7 @@

    InnerModuleLoading ( _state_: a GraphLoadingState Record, _module_: a Module Record, - _loadType_: ~single~ or ~recursive~ + _loadType_: ~single~ or ~recursive-load~ ): ~unused~

    @@ -26461,14 +26461,14 @@

    1. Assert: _state_.[[IsLoading]] is *true*. - 1. If _module_ is a Cyclic Module Record, _module_.[[Status]] is ~new~, _state_.[[Visited]] does not contain _module_, and _loadType_ is ~recursive~, then + 1. If _module_ is a Cyclic Module Record, _module_.[[Status]] is ~new~, _state_.[[Visited]] does not contain _module_, and _loadType_ is ~recursive-load~, then 1. Append _module_ to _state_.[[Visited]]. 1. Let _requestedModulesCount_ be the number of elements in _module_.[[RequestedModules]]. 1. Set _state_.[[PendingModulesCount]] to _state_.[[PendingModulesCount]] + _requestedModulesCount_. 1. For each ModuleRequest Record _required_ of _module_.[[RequestedModules]], do 1. If _module_.[[LoadedModules]] contains a Record whose [[Specifier]] is _required_.[[Specifier]], then 1. Let _record_ be that Record. - 1. Let _innerLoadType_ be ~recursive~. + 1. Let _innerLoadType_ be ~recursive-load~. 1. If _required_.[[Phase]] is ~source~, set _innerLoadType_ to ~single~. 1. Perform InnerModuleLoading(_state_, _record_.[[Module]], _innerLoadType_). 1. Else, @@ -26502,7 +26502,7 @@

    1. If _state_.[[IsLoading]] is *false*, return ~unused~. 1. If _moduleCompletion_ is a normal completion, then - 1. Let _loadType_ be ~recursive~. + 1. Let _loadType_ be ~recursive-load~. 1. If _phase_ is ~source~, set _loadType_ to ~single~. 1. Perform InnerModuleLoading(_state_, _moduleCompletion_.[[Value]], _loadType_). 1. Else, @@ -46922,7 +46922,7 @@

    %AbstractModuleSource%.prototype.constructor

    -

    get %AbstractModuleSource%.prototype [ @@toStringTag ] ( )

    +

    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. From 24624fef3c0d10cd8d17d110a9eb3ca6d5da5233 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Thu, 29 Jun 2023 20:59:20 +0200 Subject: [PATCH 07/10] michael's comments --- spec.html | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/spec.html b/spec.html index cdea9510b4..a1fa7cb7a1 100644 --- a/spec.html +++ b/spec.html @@ -27779,12 +27779,11 @@

    description
    -

    Source Text Module Record provides a GetModuleSource implementation with an abrupt completion to provide a standard reference error that a source phase import is not available.

    +

    Source Text Module Record provides a GetModuleSource implementation that always returns an abrupt completion indicating that a source phase import is not available.

    - 1. Let _error_ be a newly created *ReferenceError* object. - 1. Return ThrowCompletion(_error_). + 1. Throw a *ReferenceError* exception.
    @@ -46867,16 +46866,15 @@

    Proxy.revocable ( _target_, _handler_ )

    Module Source Objects

    Module Source Objects represent modules in their source import phase, which are not linked, instantiated or executed.

    All Module Source Objects should have a prototype of %AbstractModuleSource%.prototype and must define a [[ModuleSourceClassName]] internal slot.

    -

    Hosts may define their own Module Source subclasses for custom module record types.

    +

    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.
    • +
    • 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 the abstract superclass of the _ModuleSource_ constructor.
    • +
    • 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.
    @@ -46910,9 +46908,8 @@

    Properties of the %AbstractModuleSource% Prototype Object

    The %AbstractModuleSource% prototype object:

    • has a [[Prototype]] internal slot whose value is %Object.prototype%.
    • -
    • is %AbstractModuleSource.prototype%.
    • +
    • is %AbstractModuleSource.prototype%.
    • is an ordinary object.
    • -
    • does not have a global name or appear as a property of the global object.
    • has the following properties:
    From d62f5126508b8d883042561c3ee1175545ef615e Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Tue, 11 Jul 2023 10:45:36 +0200 Subject: [PATCH 08/10] review comments --- spec.html | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/spec.html b/spec.html index a1fa7cb7a1..741f722d98 100644 --- a/spec.html +++ b/spec.html @@ -26461,15 +26461,14 @@

    1. Assert: _state_.[[IsLoading]] is *true*. - 1. If _module_ is a Cyclic Module Record, _module_.[[Status]] is ~new~, _state_.[[Visited]] does not contain _module_, and _loadType_ is ~recursive-load~, then + 1. If _loadType_ is ~recursive-load~, _module_ is a Cyclic Module Record, _module_.[[Status]] is ~new~, and _state_.[[Visited]] does not contain _module_, then 1. Append _module_ to _state_.[[Visited]]. 1. Let _requestedModulesCount_ be the number of elements in _module_.[[RequestedModules]]. 1. Set _state_.[[PendingModulesCount]] to _state_.[[PendingModulesCount]] + _requestedModulesCount_. 1. For each ModuleRequest Record _required_ of _module_.[[RequestedModules]], do 1. If _module_.[[LoadedModules]] contains a Record whose [[Specifier]] is _required_.[[Specifier]], then 1. Let _record_ be that Record. - 1. Let _innerLoadType_ be ~recursive-load~. - 1. If _required_.[[Phase]] is ~source~, set _innerLoadType_ to ~single~. + 1. If _required_.[[Phase]] is ~source~, let _innerLoadType_ be ~single~; otherwise let _innerLoadType_ be ~recursive-load~. 1. Perform InnerModuleLoading(_state_, _record_.[[Module]], _innerLoadType_). 1. Else, 1. Perform HostLoadImportedModule(_module_, _required_, _state_.[[HostDefined]], _state_). @@ -26502,8 +26501,7 @@

    1. If _state_.[[IsLoading]] is *false*, return ~unused~. 1. If _moduleCompletion_ is a normal completion, then - 1. Let _loadType_ be ~recursive-load~. - 1. If _phase_ is ~source~, set _loadType_ to ~single~. + 1. If _phase_ is ~source~, let _loadType_ be ~single~; otherwise let _loadType_ be ~recursive-load~. 1. Perform InnerModuleLoading(_state_, _moduleCompletion_.[[Value]], _loadType_). 1. Else, 1. Set _state_.[[IsLoading]] to *false*. @@ -27365,7 +27363,7 @@

    Source Text Module Records

    a String or ~namespace-object~ or ~source~

    @@ -28053,7 +28051,7 @@

    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]]) pairs 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.

    +

    Implementations may provide unobservable module loading optimizations, such as speculative preloading of modules that are likely to be requested next. When doing so, they must 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.

    @@ -46865,7 +46863,8 @@

    Proxy.revocable ( _target_, _handler_ )

    Module Source Objects

    Module Source Objects represent modules in their source import phase, which are not linked, instantiated or executed.

    -

    All Module Source Objects should have a prototype of %AbstractModuleSource%.prototype and must define a [[ModuleSourceClassName]] internal slot.

    +

    All Module Source Objects must define a [[ModuleSourceClassName]] internal slot.

    +

    All Module Source Objects should have a prototype of %AbstractModuleSource%.prototype.

    Hosts may define their own %AbstractModuleSource% subclasses for custom module types.

    From 4875e372c408fcf812f8ae7e57862e00ff7184a4 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Tue, 11 Jul 2023 10:46:14 +0200 Subject: [PATCH 09/10] fmt --- spec.html | 80 ++++++++++++++++++++++++++----------------------------- 1 file changed, 38 insertions(+), 42 deletions(-) diff --git a/spec.html b/spec.html index 741f722d98..4ca3564fa0 100644 --- a/spec.html +++ b/spec.html @@ -19329,7 +19329,7 @@

    Runtime Semantics: Evaluation

    EvaluateImportCall ( _specifierExpression_: a Parse Node, - _phase_: ~source~ or ~evaluation~ + _phase_: ~source~ or ~evaluation~, ): either a normal completion containing a Promise or a throw completion

    @@ -19367,9 +19367,9 @@

    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. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _moduleSourceCompletion_.[[Value]] »). 1. Else, - 1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « _moduleSourceCompletion_.[[Value]] »). + 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: @@ -25928,41 +25928,39 @@

    ModuleRequest Records

    A ModuleRequest Record represents a request to import a module up to a given phase. It consists of the following fields:

    -

    It returns either a normal completion completion for the ModuleSource Object corresponding to this source Module Record's source phase (), or a throw completion.

    +

    It returns either a normal completion completion for 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 be an instance of a subclass of %AbstractModuleSource%, and it must have an internal slot [[ModuleSourceClassName]].

    For Module Records that do not have a source representation, GetModuleSource() must always return a throw completion whose [[Value]] is a *ReferenceError*.

    @@ -27362,10 +27362,10 @@

    Source Text Module Records

    [[ImportName]]
    - a String or ~namespace-object~ + a String or ~namespace-object~ or ~source~ - The name under which the desired binding is exported by the module identified by [[ModuleRequest]]. The value ~namespace-object~ indicates that the import request is for the target module's namespace object. + The name under which the desired binding is exported by the module identified by [[ModuleRequest]]. The value ~namespace-object~ indicates that the import request is for the target module's namespace object. The value ~source~ represents an import of the import phase representation at that phase name.
    - The name under which the desired binding is exported by the module identified by [[ModuleRequest]]. The value ~namespace-object~ indicates that the import request is for the target module's namespace object. The value ~source~ represents an import of the import phase representation at that phase name. + The name under which the desired binding is exported by the module identified by [[ModuleRequest]]. The value ~namespace-object~ indicates that the import request is for the target module's namespace object. The value ~source~ represents an import at the source phase.
    - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + +
    - Field Name - - Value Type - - Meaning -
    - [[Specifier]] - - String - - The module specifier -
    - [[Phase]] - - ~source~ or ~evaluation~ - - The target import phase -
    + Field Name + + Value Type + + Meaning +
    + [[Specifier]] + + String + + The module specifier +
    + [[Phase]] + + ~source~ or ~evaluation~ + + The target import phase +
    @@ -26451,7 +26449,7 @@

    InnerModuleLoading ( _state_: a GraphLoadingState Record, _module_: a Module Record, - _loadType_: ~single~ or ~recursive-load~ + _loadType_: ~single~ or ~recursive-load~, ): ~unused~

    @@ -27768,9 +27766,7 @@

    -

    - GetModuleSource ( ): either a normal completion containing an Object or a throw completion -

    +

    GetModuleSource ( ): either a normal completion containing an Object or a throw completion

    for
    a Source Text Module Record _module_
    From 09325f7864b5954fe96da155c4a59df84411fbe6 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Wed, 12 Jul 2023 10:54:56 +0200 Subject: [PATCH 10/10] jmdyck review feedback --- spec.html | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/spec.html b/spec.html index 4ca3564fa0..feab4a0f1a 100644 --- a/spec.html +++ b/spec.html @@ -3232,6 +3232,16 @@

    Well-Known Intrinsic Objects

    ECMAScript Language Association + + + %AbstractModuleSource% + + + + + The %AbstractModuleSource% constructor () + + %AggregateError% @@ -19320,7 +19330,7 @@

    Runtime Semantics: Evaluation

    1. Return ? EvaluateImportCall(|AssignmentExpression|, ~evaluation~). - ImportCall : `import` `.` `source` `(` AssignmentExpression[+In, ?Yield, ?Await] `)` + ImportCall : `import` `.` `source` `(` AssignmentExpression `)` 1. Return ? EvaluateImportCall(|AssignmentExpression|, ~source~). @@ -19332,7 +19342,8 @@

    _phase_: ~source~ or ~evaluation~, ): either a normal completion containing a Promise or a throw completion

    -
    +
    +
    1. Let _referrer_ be GetActiveScriptOrModule(). 1. If _referrer_ is *null*, set _referrer_ to the current Realm Record. @@ -25926,7 +25937,7 @@

    ModuleRequest Records

    A ModuleRequest Record represents a request to import a module up to a given phase. It consists of the following fields:

    - +
    @@ -25986,7 +25997,7 @@

    Static Semantics: ModuleRequests ( ): a List of ModuleRequest Records

    1. For each ModuleRequest Record _mr_ of _additionalRequests_, do 1. Let _found_ be *false*. 1. For each ModuleRequest Record _mr2_ of _requests_, do - 1. If _mr_.[[Specifer]] is _mr2_.[[Specifer]] and _mr_.[[Phase]] is _mr2_.[[Phase]], then + 1. If _mr_.[[Specifier]] is _mr2_.[[Specifier]] and _mr_.[[Phase]] is _mr2_.[[Phase]], then 1. Assert: _found_ is *false*. 1. Set _found_ to *true*. 1. If _found_ is *false*, then @@ -26000,19 +26011,19 @@

    Static Semantics: ModuleRequests ( ): a List of ModuleRequest Records

    ImportDeclaration : `import` ImportClause FromClause `;` 1. Let _specifier_ be SV of |FromClause|. - 1. Return a List whose sole element is the ModuleRequest Record { [[Specifer]]: _specifier_, [[Phase]]: ~evaluation~ }. + 1. Return a List whose sole element is the ModuleRequest Record { [[Specifier]]: _specifier_, [[Phase]]: ~evaluation~ }. ImportDeclaration : `import` `source` ImportedBinding FromClause `;` 1. Let _specifier_ be SV of |FromClause|. - 1. Return a List whose sole element is the ModuleRequest Record { [[Specifer]]: _specifier_, [[Phase]]: ~source~ }. + 1. Return a List whose sole element is the ModuleRequest Record { [[Specifier]]: _specifier_, [[Phase]]: ~source~ }. ExportDeclaration : `export` ExportFromClause FromClause `;` 1. Let _specifier_ be SV of |FromClause|. - 1. Return a List whose sole element is the ModuleRequest Record { [[Specifer]]: _specifier_, [[Phase]]: ~evaluation~ }. + 1. Return a List whose sole element is the ModuleRequest Record { [[Specifier]]: _specifier_, [[Phase]]: ~evaluation~ }. ExportDeclaration : @@ -26109,7 +26120,7 @@

    Abstract Module Records

    GetModuleSource()
    -

    It returns either a normal completion completion for the Module Source Object corresponding to this source Module Record's source phase (), or a throw completion.

    +

    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 be an instance of a subclass of %AbstractModuleSource%, and it must have an internal slot [[ModuleSourceClassName]].

    For Module Records that do not have a source representation, GetModuleSource() must always return a throw completion whose [[Value]] is a *ReferenceError*.

    @@ -26655,7 +26666,7 @@

    1. Append _module_ to _stack_. 1. For each ModuleRequest Record _required_ of _module_.[[RequestedModules]], do 1. Let _requiredModule_ be GetImportedModule(_module_, _required_.[[Specifier]]). - 1. If _requiredModule_.[[Phase]] is ~evaluation~, then + 1. If _required_.[[Phase]] is ~evaluation~, then 1. Set _index_ to ? InnerModuleEvaluation(_requiredModule_, _stack_, _index_). 1. If _requiredModule_ is a Cyclic Module Record, then 1. Assert: _requiredModule_.[[Status]] is one of ~evaluating~, ~evaluating-async~, or ~evaluated~. @@ -27358,7 +27369,7 @@

    Source Text Module Records

    [[ImportName]]
    - a String or ~namespace-object~ or ~source~ + a String, ~source~, or ~namespace-object~ The name under which the desired binding is exported by the module identified by [[ModuleRequest]]. The value ~namespace-object~ indicates that the import request is for the target module's namespace object. The value ~source~ represents an import at the source phase. @@ -46915,7 +46926,7 @@

    %AbstractModuleSource%.prototype.constructor

    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:

    +

    %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*.