diff --git a/spec.html b/spec.html
index 3dc99bc2c3..34a4096181 100644
--- a/spec.html
+++ b/spec.html
@@ -7418,11 +7418,11 @@
@@ -7812,7 +7812,7 @@ Static Semantics: LexicallyScopedDeclarations ( ): a List of Parse Nodes
ExportDeclaration :
- `export` ExportFromClause FromClause `;`
+ `export` ExportFromClause FromClause WithClause? `;`
`export` NamedExports `;`
`export` VariableStatement
@@ -9915,11 +9915,19 @@ Static Semantics: PropName ( ): a String or ~empty~
1. Return the PropName of |PropertyName|.
- LiteralPropertyName : IdentifierName
+
+ LiteralPropertyName : IdentifierName
+
+ AttributeKey : IdentifierName
+
1. Return the StringValue of |IdentifierName|.
- LiteralPropertyName : StringLiteral
+
+ LiteralPropertyName : StringLiteral
+
+ AttributeKey : StringLiteral
+
1. Return the SV of |StringLiteral|.
@@ -11667,10 +11675,10 @@ Realms
[[LoadedModules]]
- a List of Records with fields [[Specifier]] (a String) and [[Module]] (a Module Record)
+ a List of LoadedModuleRequest Records
|
- A map from the specifier strings imported by this realm to the resolved Module Record. The list does not contain two different Records with the same [[Specifier]].
+ A map from the specifier strings imported by this realm to the resolved Module Record. The list does not contain two different Records _r1_ and _r2_ such that ModuleRequestsEqual(_r1_, _r2_) is *true*.
As mentioned in HostLoadImportedModule (), [[LoadedModules]] in Realm Records is only used when running an `import()` expression in a context where there is no active script or module.
@@ -19047,7 +19055,8 @@ Syntax
`super` Arguments[?Yield, ?Await]
ImportCall[Yield, Await] :
- `import` `(` AssignmentExpression[+In, ?Yield, ?Await] `)`
+ `import` `(` AssignmentExpression[+In, ?Yield, ?Await] `,`? `)`
+ `import` `(` AssignmentExpression[+In, ?Yield, ?Await] `,` AssignmentExpression[+In, ?Yield, ?Await] `,`? `)`
Arguments[Yield, Await] :
`(` `)`
@@ -19606,58 +19615,108 @@ Import Calls
Runtime Semantics: Evaluation
- ImportCall : `import` `(` AssignmentExpression `)`
+ ImportCall : `import` `(` AssignmentExpression `,`? `)`
+
+ 1. Return ? EvaluateImportCall(|AssignmentExpression|).
+
+
+ ImportCall : `import` `(` AssignmentExpression `,` AssignmentExpression `,`? `)`
+
+ 1. Return ? EvaluateImportCall(the first |AssignmentExpression|, the second |AssignmentExpression|).
+
+
+
+
+
+ EvaluateImportCall (
+ _specifierExpression_: a Parse Node,
+ optional _optionsExpression_: a Parse Node,
+ ): 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 _argRef_ be ? Evaluation of |AssignmentExpression|.
- 1. Let _specifier_ be ? GetValue(_argRef_).
+ 1. Let _specifierRef_ be ? Evaluation of _specifierExpression_.
+ 1. Let _specifier_ be ? GetValue(_specifierRef_).
+ 1. If _optionsExpression_ is present, then
+ 1. Let _optionsRef_ be ? Evaluation of _optionsExpression_.
+ 1. Let _options_ be ? GetValue(_optionsRef_).
+ 1. Else,
+ 1. Let _options_ be *undefined*.
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. Let _attributes_ be a new empty List.
+ 1. If _options_ is not *undefined*, then
+ 1. If _options_ is not an Object, then
+ 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « a newly created *TypeError* object »).
+ 1. Return _promiseCapability_.[[Promise]].
+ 1. Let _attributesObj_ be Completion(Get(_options_, *"with"*)).
+ 1. IfAbruptRejectPromise(_attributesObj_, _promiseCapability_).
+ 1. If _attributesObj_ is not *undefined*, then
+ 1. If _attributesObj_ is not an Object, then
+ 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « a newly created *TypeError* object »).
+ 1. Return _promiseCapability_.[[Promise]].
+ 1. Let _entries_ be Completion(EnumerableOwnProperties(_attributesObj_, ~key+value~)).
+ 1. IfAbruptRejectPromise(_entries_, _promiseCapability_).
+ 1. For each element _entry_ of _entries_, do
+ 1. Let _key_ be ! Get(_entry_, *"0"*).
+ 1. Let _value_ be ! Get(_entry_, *"1"*).
+ 1. If _key_ is a String, then
+ 1. If _value_ is not a String, then
+ 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « a newly created *TypeError* object »).
+ 1. Return _promiseCapability_.[[Promise]].
+ 1. Append the ImportAttribute Record { [[Key]]: _key_, [[Value]]: _value_ } to _attributes_.
+ 1. If AllImportAttributesSupported(_attributes_) is *false*, then
+ 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. Perform HostLoadImportedModule(_referrer_, _moduleRequest_, ~empty~, _promiseCapability_).
1. Return _promiseCapability_.[[Promise]].
+
-
-
- ContinueDynamicImport (
- _promiseCapability_: a PromiseCapability Record,
- _moduleCompletion_: either a normal completion containing a Module Record or a throw completion,
- ): ~unused~
-
-
-
- 1. If _moduleCompletion_ is an abrupt completion, then
- 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _moduleCompletion_.[[Value]] »).
- 1. Return ~unused~.
- 1. Let _module_ be _moduleCompletion_.[[Value]].
- 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_ »).
+
+
+ ContinueDynamicImport (
+ _promiseCapability_: a PromiseCapability Record,
+ _moduleCompletion_: either a normal completion containing a Module Record or a throw completion,
+ ): ~unused~
+
+
+
+ 1. If _moduleCompletion_ is an abrupt completion, then
+ 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _moduleCompletion_.[[Value]] »).
+ 1. Return ~unused~.
+ 1. Let _module_ be _moduleCompletion_.[[Value]].
+ 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_ »).
+ 1. Return ~unused~.
+ 1. Let _onRejected_ be CreateBuiltinFunction(_rejectedClosure_, 1, *""*, « »).
+ 1. Let _linkAndEvaluateClosure_ be a new Abstract Closure with no parameters that captures _module_, _promiseCapability_, and _onRejected_ and performs the following steps when called:
+ 1. Let _link_ be Completion(_module_.Link()).
+ 1. If _link_ is an abrupt completion, then
+ 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _link_.[[Value]] »).
1. Return ~unused~.
- 1. Let _onRejected_ be CreateBuiltinFunction(_rejectedClosure_, 1, *""*, « »).
- 1. Let _linkAndEvaluateClosure_ be a new Abstract Closure with no parameters that captures _module_, _promiseCapability_, and _onRejected_ and performs the following steps when called:
- 1. Let _link_ be Completion(_module_.Link()).
- 1. If _link_ is an abrupt completion, then
- 1. Perform ! Call(_promiseCapability_.[[Reject]], *undefined*, « _link_.[[Value]] »).
- 1. Return ~unused~.
- 1. Let _evaluatePromise_ be _module_.Evaluate().
- 1. Let _fulfilledClosure_ be a new Abstract Closure with no parameters that captures _module_ and _promiseCapability_ and performs the following steps when called:
- 1. Let _namespace_ be GetModuleNamespace(_module_).
- 1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « _namespace_ »).
- 1. Return ~unused~.
- 1. Let _onFulfilled_ be CreateBuiltinFunction(_fulfilledClosure_, 0, *""*, « »).
- 1. Perform PerformPromiseThen(_evaluatePromise_, _onFulfilled_, _onRejected_).
+ 1. Let _evaluatePromise_ be _module_.Evaluate().
+ 1. Let _fulfilledClosure_ be a new Abstract Closure with no parameters that captures _module_ and _promiseCapability_ and performs the following steps when called:
+ 1. Let _namespace_ be GetModuleNamespace(_module_).
+ 1. Perform ! Call(_promiseCapability_.[[Resolve]], *undefined*, « _namespace_ »).
1. Return ~unused~.
- 1. Let _linkAndEvaluate_ be CreateBuiltinFunction(_linkAndEvaluateClosure_, 0, *""*, « »).
- 1. Perform PerformPromiseThen(_loadPromise_, _linkAndEvaluate_, _onRejected_).
+ 1. Let _onFulfilled_ be CreateBuiltinFunction(_fulfilledClosure_, 0, *""*, « »).
+ 1. Perform PerformPromiseThen(_evaluatePromise_, _onFulfilled_, _onRejected_).
1. Return ~unused~.
-
-
+ 1. Let _linkAndEvaluate_ be CreateBuiltinFunction(_linkAndEvaluateClosure_, 0, *""*, « »).
+ 1. Perform PerformPromiseThen(_loadPromise_, _linkAndEvaluate_, _onRejected_).
+ 1. Return ~unused~.
+
@@ -25929,10 +25988,10 @@ Script Records
[[LoadedModules]]
|
- a List of Records with fields [[Specifier]] (a String) and [[Module]] (a Module Record)
+ a List of LoadedModuleRequest Records
|
- A map from the specifier strings imported by this script to the resolved Module Record. The list does not contain two different Records with the same [[Specifier]].
+ A map from the specifier strings imported by this script to the resolved Module Record. The list does not contain two different Records _r1_ and _r2_ such that ModuleRequestsEqual(_r1_, _r2_) is *true*.
|
@@ -26173,8 +26232,173 @@
+
+ ModuleRequest Records
+
+ A ModuleRequest Record represents the request to import a module with given import attributes. It consists of the following fields:
+
+
+
+
+ Field Name
+ |
+
+ Value Type
+ |
+
+ Meaning
+ |
+
+
+
+ [[Specifier]]
+ |
+
+ a String
+ |
+
+ The module specifier
+ |
+
+
+
+ [[Attributes]]
+ |
+
+ a List of ImportAttribute Records
+ |
+
+ The import attributes
+ |
+
+
+
+
+ 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]]:
+
+
+
+
+ Field Name
+ |
+
+ Value Type
+ |
+
+ Meaning
+ |
+
+
+
+ [[Specifier]]
+ |
+
+ a String
+ |
+
+ The module specifier
+ |
+
+
+
+ [[Attributes]]
+ |
+
+ a List of ImportAttribute Records
+ |
+
+ The import attributes
+ |
+
+
+
+ [[Module]]
+ |
+
+ a Module Record
+ |
+
+ The loaded module corresponding to this module request
+ |
+
+
+
+
+ An ImportAttribute Record consists of the following fields:
+
+
+
+
+ Field Name
+ |
+
+ Value Type
+ |
+
+ Meaning
+ |
+
+
+
+ [[Key]]
+ |
+
+ a String
+ |
+
+ The attribute key
+ |
+
+
+
+ [[Value]]
+ |
+
+ a String
+ |
+
+ The attribute value
+ |
+
+
+
+
+
+
+ ModuleRequestsEqual (
+ _left_: a ModuleRequest Record or a LoadedModuleRequest Record,
+ _right_: a ModuleRequest Record or a LoadedModuleRequest Record,
+ ): a Boolean
+
+
+
+
+ 1. If _left_.[[Specifier]] is not _right_.[[Specifier]], return *false*.
+ 1. Let _leftAttrs_ be _left_.[[Attributes]].
+ 1. Let _rightAttrs_ be _right_.[[Attributes]].
+ 1. Let _leftAttrsCount_ be the number of elements in _leftAttrs_.
+ 1. Let _rightAttrsCount_ be the number of elements in _rightAttrs_.
+ 1. If _leftAttrsCount_ ≠ _rightAttrsCount_, return *false*.
+ 1. For each ImportAttribute Record _l_ of _leftAttrs_, do
+ 1. Let _found_ be *false*.
+ 1. For each ImportAttribute Record _r_ of _rightAttrs_, do
+ 1. If _l_.[[Key]] is _r_.[[Key]], then
+ 1. If _l_.[[Value]] is _r_.[[Value]], then
+ 1. Assert: _found_ is *false*.
+ 1. Set _found_ to *true*.
+ 1. Else,
+ 1. Return *false*.
+ 1. If _found_ is *false*, return *false*.
+ 1. Return *true*.
+
+
+
+
- Static Semantics: ModuleRequests ( ): a List of Strings
+ Static Semantics: ModuleRequests ( ): a List of ModuleRequest Records
Module : [empty]
@@ -26187,12 +26411,12 @@ Static Semantics: ModuleRequests ( ): a List of Strings
ModuleItemList : ModuleItemList ModuleItem
- 1. Let _moduleNames_ be the ModuleRequests of |ModuleItemList|.
- 1. Let _additionalNames_ be the 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 the ModuleRequests of |ModuleItemList|.
+ 1. Let _additionalRequests_ be the ModuleRequests of |ModuleItem|.
+ 1. For each ModuleRequest Record _mr_ of _additionalRequests_, do
+ 1. If _requests_ does not contain a ModuleRequest Record _mr2_ such that ModuleRequestsEqual(_mr_, _mr2_) is *true*, then
+ 1. Append _mr_ to _requests_.
+ 1. Return _requests_.
ModuleItem : StatementListItem
@@ -26200,17 +26424,40 @@ Static Semantics: ModuleRequests ( ): a List of Strings
ImportDeclaration : `import` ImportClause FromClause `;`
- 1. Return the ModuleRequests of |FromClause|.
+ 1. Let _specifier_ be the SV of |FromClause|.
+ 1. Return a List whose sole element is the ModuleRequest Record { [[Specifier]]: _specifier_, [[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_ }.
+
+ 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]]: « » }.
- ModuleSpecifier : StringLiteral
+ ImportDeclaration : `import` ModuleSpecifier WithClause `;`
- 1. Return a List whose sole element is the SV of |StringLiteral|.
+ 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_ }.
ExportDeclaration : `export` ExportFromClause FromClause `;`
- 1. Return the ModuleRequests of |FromClause|.
+ 1. Let _specifier_ be the SV of |FromClause|.
+ 1. Return a List whose sole element is the ModuleRequest Record { [[Specifier]]: _specifier_, [[Attributes]]: « » }.
+
+
+ ExportDeclaration : `export` ExportFromClause 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_ }.
ExportDeclaration :
@@ -26421,10 +26668,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 the ModuleRequest Records associated with the imports in this module. The List is in source text occurrence order of the imports.
|
@@ -26432,10 +26679,10 @@ Cyclic Module Records
[[LoadedModules]]
- a List of Records with fields [[Specifier]] (a String) and [[Module]] (a Module Record)
+ a List of LoadedModuleRequest Records
|
- A map from the specifier strings used by the module represented by this record to request the importation of a module to the resolved Module Record. The list does not contain two different Records with the same [[Specifier]].
+ A map from the specifier strings used by the module represented by this record to request the importation of a module with the relative import attributes to the resolved Module Record. The list does not contain two different Records _r1_ and _r2_ such that ModuleRequestsEqual(_r1_, _r2_) is *true*.
|
@@ -26657,12 +26904,14 @@
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. Let _record_ be that Record.
+ 1. For each ModuleRequest Record _request_ of _module_.[[RequestedModules]], do
+ 1. If AllImportAttributesSupported(_request_.[[Attributes]]) is *false*, then
+ 1. Let _error_ be ThrowCompletion(a newly created *SyntaxError* object).
+ 1. Perform ContinueModuleLoading(_state_, _error_).
+ 1. Else if _module_.[[LoadedModules]] contains a LoadedModuleRequest Record _record_ such that ModuleRequestsEqual(_record_, _request_) is *true*, then
1. Perform InnerModuleLoading(_state_, _record_.[[Module]]).
1. Else,
- 1. Perform HostLoadImportedModule(_module_, _required_, _state_.[[HostDefined]], _state_).
+ 1. Perform HostLoadImportedModule(_module_, _request_, _state_.[[HostDefined]], _state_).
1. NOTE: HostLoadImportedModule will call FinishLoadingImportedModule, which re-enters the graph loading process through ContinueModuleLoading.
1. If _state_.[[IsLoading]] is *false*, return ~unused~.
1. Assert: _state_.[[PendingModulesCount]] ≥ 1.
@@ -26750,8 +26999,8 @@
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. For each ModuleRequest Record _request_ of _module_.[[RequestedModules]], do
+ 1. Let _requiredModule_ be GetImportedModule(_module_, _request_).
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~.
@@ -26843,8 +27092,8 @@
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. For each ModuleRequest Record _request_ of _module_.[[RequestedModules]], do
+ 1. Let _requiredModule_ be GetImportedModule(_module_, _request_).
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~.
@@ -27623,10 +27872,10 @@ Source Text Module Records
[[ModuleRequest]]
- a String
+ a ModuleRequest Record
|
- String value of the |ModuleSpecifier| of the |ImportDeclaration|.
+ ModuleRequest Record representing the |ModuleSpecifier| and import attributes of the |ImportDeclaration|.
|
@@ -27772,10 +28021,10 @@ Source Text Module Records
[[ModuleRequest]]
- a String or *null*
+ a ModuleRequest Record or *null*
|
- The String value of the |ModuleSpecifier| of the |ExportDeclaration|. *null* if the |ExportDeclaration| does not have a |ModuleSpecifier|.
+ The ModuleRequest Record representing the |ModuleSpecifier| and import attributes of the |ExportDeclaration|. *null* if the |ExportDeclaration| does not have a |ModuleSpecifier|.
|
@@ -28259,7 +28508,7 @@
GetImportedModule (
_referrer_: a Cyclic Module Record,
- _specifier_: a String,
+ _request_: a ModuleRequest Record,
): a Module Record
- 1. Assert: Exactly one element of _referrer_.[[LoadedModules]] is a Record whose [[Specifier]] is _specifier_, since LoadRequestedModules has completed successfully on _referrer_ prior to invoking this abstract operation.
- 1. Let _record_ be the Record in _referrer_.[[LoadedModules]] whose [[Specifier]] is _specifier_.
+ 1. [declared="r"] Let _records_ be a List consisting of each LoadedModuleRequest Record _r_ of _referrer_.[[LoadedModules]] such that ModuleRequestsEqual(_r_, _request_) is *true*.
+ 1. Assert: _records_ has exactly one element, since LoadRequestedModules has completed successfully on _referrer_ prior to invoking this abstract operation.
+ 1. Let _record_ be the sole element of _records_.
1. Return _record_.[[Module]].
@@ -28278,7 +28528,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~
@@ -28299,24 +28549,29 @@
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_, _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.
+
If this operation is called multiple times with two (_referrer_, _moduleRequest_) pairs such that:
+
+ - the first _referrer_ is the same as the second _referrer_;
+ - ModuleRequestsEqual(the first _moduleRequest_, the second _moduleRequest_) is *true*;
+
+ 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.
-
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]], _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.
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~
@@ -28327,10 +28582,10 @@
1. If _result_ is a normal completion, then
- 1. If _referrer_.[[LoadedModules]] contains a Record whose [[Specifier]] is _specifier_, then
- 1. Assert: That Record's [[Module]] is _result_.[[Value]].
+ 1. If _referrer_.[[LoadedModules]] contains a LoadedModuleRequest Record _record_ such that ModuleRequestsEqual(_record_, _moduleRequest_) is *true*, then
+ 1. Assert: _record_.[[Module]] and _result_.[[Value]] are the same Module Record.
1. Else,
- 1. Append the Record { [[Specifier]]: _specifier_, [[Module]]: _result_.[[Value]] } to _referrer_.[[LoadedModules]].
+ 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. Else,
@@ -28339,6 +28594,44 @@
+
+
+ AllImportAttributesSupported (
+ _attributes_: a List of ImportAttribute Records,
+ ): a Boolean
+
+
+
+ 1. Let _supported_ be HostGetSupportedImportAttributes().
+ 1. For each ImportAttribute Record _attribute_ of _attributes_, do
+ 1. If _supported_ does not contain _attribute_.[[Key]], return *false*.
+ 1. Return *true*.
+
+
+
+ HostGetSupportedImportAttributes ( ): a List of Strings
+
+
+ An implementation of HostGetSupportedImportAttributes must conform to the following requrements:
+
+
+ - It must return a List of Strings, each indicating a supported attribute.
+
+ - Each time this operation is called, it must return the same List with the same contents in the same order.
+
+
+ The default implementation of HostGetSupportedImportAttributes is to return a new empty List.
+
+ The purpose of requiring the host to specify its supported import attributes, rather than passing all attributes to the host and letting it then choose which ones it wants to handle, is to ensure that unsupported attributes are handled in a consistent way across different hosts.
+
+
+
GetModuleNamespace (
@@ -28401,8 +28694,8 @@ Imports
Syntax
ImportDeclaration :
- `import` ImportClause FromClause `;`
- `import` ModuleSpecifier `;`
+ `import` ImportClause FromClause WithClause? `;`
+ `import` ModuleSpecifier WithClause? `;`
ImportClause :
ImportedDefaultBinding
@@ -28438,6 +28731,18 @@ Syntax
ImportedBinding :
BindingIdentifier[~Yield, +Await]
+
+ WithClause :
+ `with` `{` `}`
+ `with` `{` WithEntries `,`? `}`
+
+ WithEntries :
+ AttributeKey `:` StringLiteral
+ AttributeKey `:` StringLiteral `,` WithEntries
+
+ AttributeKey :
+ IdentifierName
+ StringLiteral
@@ -28448,6 +28753,13 @@ Static Semantics: Early Errors
It is a Syntax Error if the BoundNames of |ImportDeclaration| contains any duplicate entries.
+
+ WithClause : `with` `{` WithEntries `,`? `}`
+
+ -
+ It is a Syntax Error if WithClauseToAttributes of |WithClause| has two different entries _a_ and _b_ such that _a_.[[Key]] is _b_.[[Key]].
+
+
@@ -28472,12 +28784,12 @@ Static Semantics: ImportEntries ( ): a List of ImportEntry Records
1. Return a new empty List.
- ImportDeclaration : `import` ImportClause FromClause `;`
+ ImportDeclaration : `import` ImportClause FromClause WithClause? `;`
- 1. Let _module_ be the sole element of the ModuleRequests of |FromClause|.
+ 1. Let _module_ be the sole element of the ModuleRequests of |ImportDeclaration|.
1. Return the ImportEntriesForModule of |ImportClause| with argument _module_.
- ImportDeclaration : `import` ModuleSpecifier `;`
+ ImportDeclaration : `import` ModuleSpecifier WithClause? `;`
1. Return a new empty List.
@@ -28486,7 +28798,7 @@ Static Semantics: ImportEntries ( ): a List of ImportEntry Records
Static Semantics: ImportEntriesForModule (
- _module_: a String,
+ _module_: a ModuleRequest Record,
): a List of ImportEntry Records
+
+
+ Static Semantics: WithClauseToAttributes ( ): a List of ImportAttribute Records
+
+
+
+ WithClause : `with` `{` `}`
+
+
+ 1. Return a new empty List.
+
+
+
+ WithClause : `with` `{` WithEntries `,`? `}`
+
+
+ 1. Let _attributes_ be WithClauseToAttributes of |WithEntries|.
+ 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. Return _attributes_.
+
+
+ WithEntries : AttributeKey `:` StringLiteral
+
+ 1. Let _key_ be the PropName of |AttributeKey|.
+ 1. Let _entry_ be the ImportAttribute Record { [[Key]]: _key_, [[Value]]: the SV of |StringLiteral| }.
+ 1. Return « _entry_ ».
+
+
+ WithEntries : AttributeKey `:` StringLiteral `,` WithEntries
+
+ 1. Let _key_ be the PropName of |AttributeKey|.
+ 1. Let _entry_ be the ImportAttribute Record { [[Key]]: _key_, [[Value]]: the SV of |StringLiteral| }.
+ 1. Let _rest_ be WithClauseToAttributes of |WithEntries|.
+ 1. Return the list-concatenation of « _entry_ » and _rest_.
+
+
@@ -28546,7 +28895,7 @@ Exports
Syntax
ExportDeclaration :
- `export` ExportFromClause FromClause `;`
+ `export` ExportFromClause FromClause WithClause? `;`
`export` NamedExports `;`
`export` VariableStatement[~Yield, +Await]
`export` Declaration[~Yield, +Await]
@@ -28610,10 +28959,7 @@ Static Semantics: ExportedBindings ( ): a List of Strings
1. Return a new empty List.
-
- ExportDeclaration :
- `export` ExportFromClause FromClause `;`
-
+ ExportDeclaration : `export` ExportFromClause FromClause WithClause? `;`
1. Return a new empty List.
@@ -28683,7 +29029,7 @@ Static Semantics: ExportedNames ( ): a List of Strings
1. Return a new empty List.
- ExportDeclaration : `export` ExportFromClause FromClause `;`
+ ExportDeclaration : `export` ExportFromClause FromClause WithClause? `;`
1. Return the ExportedNames of |ExportFromClause|.
@@ -28758,9 +29104,9 @@ Static Semantics: ExportEntries ( ): a List of ExportEntry Records
1. Return a new empty List.
- ExportDeclaration : `export` ExportFromClause FromClause `;`
+ ExportDeclaration : `export` ExportFromClause FromClause WithClause? `;`
- 1. Let _module_ be the sole element of the ModuleRequests of |FromClause|.
+ 1. Let _module_ be the sole element of the ModuleRequests of |ExportDeclaration|.
1. Return the ExportEntriesForModule of |ExportFromClause| with argument _module_.
ExportDeclaration : `export` NamedExports `;`
@@ -28808,7 +29154,7 @@ Static Semantics: ExportEntries ( ): a List of ExportEntry Records
Static Semantics: ExportEntriesForModule (
- _module_: a String or *null*,
+ _module_: a ModuleRequest Record or *null*,
): a List of ExportEntry Records