Stage 2.7 Draft / March 5, 2026

ECMAScript Module Phase Imports

1 ECMAScript Data Types and Values

1.1 ECMAScript Language Types

1.1.1 Object Type

1.1.1.1 Well-Known Intrinsic Objects

Well-known intrinsics are built-in objects that are explicitly referenced by the algorithms of this specification and which usually have realm-specific identities. Unless otherwise specified each intrinsic object actually corresponds to a set of similar objects, one per realm.

Within this specification a reference such as %name% means the intrinsic object, associated with the current realm, corresponding to the name. A reference such as %name.a.b% means, as if the "b" property of the value of the "a" property of the intrinsic object %name% was accessed prior to any ECMAScript code being evaluated. Determination of the current realm and its intrinsics is described in 9.4. The well-known intrinsics are listed in Table 1.

Table 1: Well-Known Intrinsic Objects
Intrinsic Name Global Name ECMAScript Language Association
%AbstractModuleSource% AbstractModuleSource The AbstractModuleSource constructor
%AggregateError% AggregateError The AggregateError constructor (20.5.7.1)
%Array% Array The Array constructor (23.1.1)
%ArrayBuffer% ArrayBuffer The ArrayBuffer constructor (25.1.4)
%ArrayIteratorPrototype% The prototype of Array iterator objects (23.1.5)
%AsyncFromSyncIteratorPrototype% The prototype of async-from-sync iterator objects (27.1.5)
%AsyncFunction% The constructor of async function objects (27.7.1)
%AsyncGeneratorFunction% The constructor of async generator function objects (27.4.1)
%AsyncGeneratorPrototype% The prototype of async generator objects (27.6)
%AsyncIteratorPrototype% An object that all standard built-in async iterator objects indirectly inherit from
%Atomics% Atomics The Atomics object (25.4)
%BigInt% BigInt The BigInt constructor (21.2.1)
%BigInt64Array% BigInt64Array The BigInt64Array constructor (23.2)
%BigUint64Array% BigUint64Array The BigUint64Array constructor (23.2)
%Boolean% Boolean The Boolean constructor (20.3.1)
%DataView% DataView The DataView constructor (25.3.2)
%Date% Date The Date constructor (21.4.2)
%decodeURI% decodeURI The decodeURI function (19.2.6.1)
%decodeURIComponent% decodeURIComponent The decodeURIComponent function (19.2.6.2)
%encodeURI% encodeURI The encodeURI function (19.2.6.3)
%encodeURIComponent% encodeURIComponent The encodeURIComponent function (19.2.6.4)
%Error% Error The Error constructor (20.5.1)
%eval% eval The eval function (19.2.1)
%EvalError% EvalError The EvalError constructor (20.5.5.1)
%FinalizationRegistry% FinalizationRegistry The FinalizationRegistry constructor (26.2.1)
%Float32Array% Float32Array The Float32Array constructor (23.2)
%Float64Array% Float64Array The Float64Array constructor (23.2)
%ForInIteratorPrototype% The prototype of For-In iterator objects (14.7.5.10)
%Function% Function The Function constructor (20.2.1)
%GeneratorFunction% The constructor of generator function objects (27.3.1)
%GeneratorPrototype% The prototype of generator objects (27.5)
%Int8Array% Int8Array The Int8Array constructor (23.2)
%Int16Array% Int16Array The Int16Array constructor (23.2)
%Int32Array% Int32Array The Int32Array constructor (23.2)
%isFinite% isFinite The isFinite function (19.2.2)
%isNaN% isNaN The isNaN function (19.2.3)
%IteratorPrototype% An object that all standard built-in iterator objects indirectly inherit from
%JSON% JSON The JSON object (25.5)
%Map% Map The Map constructor (24.1.1)
%MapIteratorPrototype% The prototype of Map iterator objects (24.1.5)
%Math% Math The Math object (21.3)
%ModuleSource% ModuleSource A ModuleSource object (28.1.2)
%Number% Number The Number constructor (21.1.1)
%Object% Object The Object constructor (20.1.1)
%parseFloat% parseFloat The parseFloat function (19.2.4)
%parseInt% parseInt The parseInt function (19.2.5)
%Promise% Promise The Promise constructor (27.2.3)
%Proxy% Proxy The Proxy constructor (28.2.1)
%RangeError% RangeError The RangeError constructor (20.5.5.2)
%ReferenceError% ReferenceError The ReferenceError constructor (20.5.5.3)
%Reflect% Reflect The Reflect object (28.1)
%RegExp% RegExp The RegExp constructor (22.2.4)
%RegExpStringIteratorPrototype% The prototype of RegExp String Iterator objects (22.2.9)
%Set% Set The Set constructor (24.2.2)
%SetIteratorPrototype% The prototype of Set iterator objects (24.2.6)
%SharedArrayBuffer% SharedArrayBuffer The SharedArrayBuffer constructor (25.2.3)
%String% String The String constructor (22.1.1)
%StringIteratorPrototype% The prototype of String iterator objects (22.1.5)
%Symbol% Symbol The Symbol constructor (20.4.1)
%SyntaxError% SyntaxError The SyntaxError constructor (20.5.5.4)
%ThrowTypeError% A function object that unconditionally throws a new instance of %TypeError%
%TypedArray% The super class of all typed Array constructors (23.2.1)
%TypeError% TypeError The TypeError constructor (20.5.5.5)
%Uint8Array% Uint8Array The Uint8Array constructor (23.2)
%Uint8ClampedArray% Uint8ClampedArray The Uint8ClampedArray constructor (23.2)
%Uint16Array% Uint16Array The Uint16Array constructor (23.2)
%Uint32Array% Uint32Array The Uint32Array constructor (23.2)
%URIError% URIError The URIError constructor (20.5.5.6)
%WeakMap% WeakMap The WeakMap constructor (24.3.1)
%WeakRef% WeakRef The WeakRef constructor (26.1.1)
%WeakSet% WeakSet The WeakSet constructor (24.4.1)
Note

Additional entries in Table 97.

13 ECMAScript Language: Expressions

13.3 Left-Hand-Side Expressions

Syntax

13.3.10 Import Calls

13.3.10.1 EvaluateImportCall ( specifierExpression, phase [ , optionsExpression ] )

The abstract operation EvaluateImportCall takes arguments specifierExpression (a Parse Node) and phase (source or evaluation) and optional argument optionsExpression (a Parse Node) and returns either a normal completion containing a Promise or a throw completion. It performs the following steps when called:

  1. Let referrer be GetActiveScriptOrModule().
  2. If referrer is null, set referrer to the current Realm Record.
  3. Let specifierRef be ? Evaluation of specifierExpression.
  4. Let specifier be ? GetValue(specifierRef).
  5. If optionsExpression is present, then
    1. Let optionsRef be ? Evaluation of optionsExpression.
    2. Let options be ? GetValue(optionsRef).
  6. Else,
    1. Let options be undefined.
  7. Let promiseCapability be ! NewPromiseCapability(%Promise%).
  8. Let attributesObj be undefined.
  9. If specifier is an Object, then
    1. Let moduleSourceRecord be GetModuleSourceRecord(specifier).
    2. If moduleSourceRecord is not not-a-source, then
      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 »).
          2. Return promiseCapability.[[Promise]].
        2. Set attributesObj to Completion(Get(options, "with")).
        3. IfAbruptRejectPromise(attributesObj, promiseCapability).
      2. If attributesObj is not undefined, then
        1. Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »).
        2. Return promiseCapability.[[Promise]].
      3. Let proto be ? specifier.[[GetPrototypeOf]]().
      4. Let superProto be ? proto.[[GetPrototypeOf]]().
      5. if SameValue(superProto, %AbstractModuleSource.prototype%) is false, then:
        1. Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »).
        2. Return promiseCapability.[[Promise]].
      6. Let moduleRequest be a new ModuleRequest Record { [[Specifier]]: moduleSourceRecord, [[Phase]]: phase, [[Attributes]]: « » }.
      7. Perform HostLoadImportedModule(referrer, moduleRequest, empty, promiseCapability).
      8. Return promiseCapability.[[Promise]].
  10. Let specifierString be Completion(ToString(specifier)).
  11. IfAbruptRejectPromise(specifierString, promiseCapability).
  12. Let attributes be a new empty List.
  13. 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 »).
      2. Return promiseCapability.[[Promise]].
    2. Set attributesObj to Completion(Get(options, "with")).
    3. IfAbruptRejectPromise(attributesObj, promiseCapability).
    4. 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 »).
        2. Return promiseCapability.[[Promise]].
      2. Let entries be Completion(EnumerableOwnProperties(attributesObj, key+value)).
      3. IfAbruptRejectPromise(entries, promiseCapability).
      4. For each element entry of entries, do
        1. Let key be ! Get(entry, "0").
        2. Let value be ! Get(entry, "1").
        3. 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 »).
            2. Return promiseCapability.[[Promise]].
          2. Append the ImportAttribute Record { [[Key]]: key, [[Value]]: value } to attributes.
    5. If AllImportAttributesSupported(attributes) is false, then
      1. Perform ! Call(promiseCapability.[[Reject]], undefined, « a newly created TypeError object »).
      2. Return promiseCapability.[[Promise]].
    6. 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.
  14. Let moduleRequest be a new ModuleRequest Record { [[Specifier]]: specifierString, [[Phase]]: phase, [[Attributes]]: attributes }.
  15. Perform HostLoadImportedModule(referrer, moduleRequest, empty, promiseCapability).
  16. Return promiseCapability.[[Promise]].

13.3.10.2 ContinueDynamicImport ( promiseCapability, phase, moduleCompletion )

The abstract operation ContinueDynamicImport takes arguments promiseCapability (a PromiseCapability Record), phase (source or evaluation), and moduleCompletion (either a normal completion containing a Module Record or a throw completion) and returns unused. It completes the process of a dynamic import originally started by an import() call, resolving or rejecting the promise returned by that call as appropriate. It performs the following steps when called:

  1. If moduleCompletion is an abrupt completion, then
    1. Perform ! Call(promiseCapability.[[Reject]], undefined, « moduleCompletion.[[Value]] »).
    2. Return unused.
  2. Let module be moduleCompletion.[[Value]].
  3. If phase is source, then
    1. Let moduleSource be module.[[ModuleSource]]module.[[SourceRecord]].[[ModuleSource]].
    2. If moduleSource is empty, then
      1. Perform ! Call(promiseCapability.[[Reject]], undefined, « a new SyntaxError »).
    3. Else,
      1. Perform ! Call(promiseCapability.[[Resolve]], undefined, « moduleSource »).
    4. Return unused.
  4. ...

16 ECMAScript Language: Scripts and Modules

16.1 Modules

16.1.1 Module Semantics

16.1.1.1 ModuleRequest Records

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

Table 2: ModuleRequest Record Fields
Field Name Value Type Meaning
[[Specifier]] a String or a Module Source Record The module specifier string, or a Module Source Record when importing a module source directly
[[Phase]] source or evaluation The target import phase
[[Attributes]] a List of ImportAttribute Records The import attributes

16.1.1.1.1 ModuleRequestsEqual ( left, right )

The abstract operation ModuleRequestsEqual takes arguments left (a ModuleRequest Record or a LoadedModuleRequest Record) and right (a ModuleRequest Record or a LoadedModuleRequest Record) and returns a Boolean. It performs the following steps when called:

  1. If left.[[Specifier]] is not right.[[Specifier]], return false.
  2. If left.[[Specifier]] is a String, then
    1. If right.[[Specifier]] is not left.[[Specifier]], return false.
  3. Else,
    1. Assert: left.[[Specifier]] is a Module Source Record.
    2. If right.[[Specifier]] is not a Module Source Record, return false.
    3. If ModuleSourcesEqual(left.[[Specifier]], right.[[Specifier]]) is false, return false.
  4. Let leftAttrs be left.[[Attributes]].
  5. Let rightAttrs be right.[[Attributes]].
  6. Let leftAttrsCount be the number of elements in leftAttrs.
  7. Let rightAttrsCount be the number of elements in rightAttrs.
  8. If leftAttrsCountrightAttrsCount, return false.
  9. For each ImportAttribute Record l of leftAttrs, do
    1. If rightAttrs does not contain an ImportAttribute Record r such that l.[[Key]] is r.[[Key]] and l.[[Value]] is r.[[Value]], return false.
  10. Return true.

16.1.1.2 Abstract Module Records

Table 3: Abstract Methods of Module Records
Method Purpose
LoadRequestedModules( [ hostDefined ] )

Prepares the module for linking by recursively loading all its dependencies, and returns a promise.

GetExportedNames([exportStarSet])

Return a list of all names that are either directly or indirectly exported from this module.

LoadRequestedModules must have completed successfully prior to invoking this method.

ResolveExport(exportName [, resolveSet])

Return the binding of a name exported by this module. Bindings are represented by a ResolvedBinding Record, of the form { [[Module]]: Module Record, [[BindingName]]: String | namespace }. If the export is a Module Namespace Object without a direct binding in any module, [[BindingName]] will be set to namespace. Return null if the name cannot be resolved, or ambiguous if multiple bindings were found.

Each time this operation is called with a specific exportName, resolveSet pair as arguments it must return the same result.

LoadRequestedModules must have completed successfully prior to invoking this method.

Link()

Prepare the module for evaluation by transitively resolving all module dependencies and creating a Module Environment Record.

LoadRequestedModules must have completed successfully prior to invoking this method.

Evaluate()

Returns a promise for the evaluation of this module and its dependencies, resolving on successful evaluation or if it has already been evaluated successfully, and rejecting for an evaluation error or if it has already been evaluated unsuccessfully. If the promise is rejected, hosts are expected to handle the promise rejection and rethrow the evaluation error.

Link must have completed successfully prior to invoking this method.

A Module Source Record represents the host-defined identity data associated with a Module Record that is independent of its linking and evaluation state. Every Module Record has a [[SourceRecord]] field whose value is a Module Source Record.

Table 4: Module Source Record Fields
Field Name Value Type Meaning
[[HostDefined]] anything (default value is undefined) Field reserved for use by host environments that need to associate additional information with a module. This typically contains the canonical module specifier (e.g. the resolved URL) and other host-specific metadata.
[[SourceText]] ECMAScript source text or none The original source text for this module, if a Source Text Module Record.
[[ModuleSourceKind]] a String A constant string identifying the kind of module source, to be used as the return value of the %Symbol.toStringTag% getter on %AbstractModuleSource%.
[[ModuleSource]] an Object or empty The Module Source Object corresponding to this module source's source phase (28.1), or empty if it is not available for this module kind. When set, it must have a [[Prototype]] internal slot containing an object whose initial [[Prototype]] is %AbstractModuleSource%.

16.1.1.2.1 ModuleSourcesEqual ( left, right )

The abstract operation ModuleSourcesEqual takes arguments left (a Module Source Record) and right (a Module Source Record) and returns a Boolean.

It checks module source equality of two Module Source Records.

It performs the following steps when called:

  1. If left.[[SourceText]] is none or right.[[SourceText]] is none, return false.
  2. If left.[[HostDefined]] is not right.[[HostDefined]], return false.
  3. If left.[[SourceText]] is not right.[[SourceText]], return false.
  4. Return true.

16.1.1.3 Source Text Module Records

16.1.1.3.1 ParseModule ( sourceText, realm, hostDefined )

The abstract operation ParseModule takes arguments sourceText (ECMAScript source text), realm (a Realm Record), and hostDefined (anything) and returns a Source Text Module Record or a non-empty List of SyntaxError objects. It creates a Source Text Module Record based upon the result of parsing sourceText as a Module. It performs the following steps when called:

  1. Let body be ParseText(sourceText, Module).
  2. If body is a List of errors, return body.
  3. Let requestedModules be the ModuleRequests of body.
  4. Let importEntries be the ImportEntries of body.
  5. Let importedBoundNames be ImportedLocalNames(importEntries).
  6. Let indirectExportEntries be a new empty List.
  7. Let localExportEntries be a new empty List.
  8. Let starExportEntries be a new empty List.
  9. Let exportEntries be the ExportEntries of body.
  10. For each ExportEntry Record ee of exportEntries, do
    1. If ee.[[ModuleRequest]] is null, then
      1. If importedBoundNames does not contain ee.[[LocalName]], then
        1. Append ee to localExportEntries.
      2. Else,
        1. Let ie be the element of importEntries whose [[LocalName]] is ee.[[LocalName]].
        2. If ie.[[ImportName]] is namespace-object, then
          1. NOTE: This is a re-export of an imported module namespace object.
          2. Append ee to localExportEntries.
        3. Else,
          1. NOTE: This is a re-export of a single name.
          2. Append the ExportEntry Record { [[ModuleRequest]]: ie.[[ModuleRequest]], [[ImportName]]: ie.[[ImportName]], [[LocalName]]: null, [[ExportName]]: ee.[[ExportName]] } to indirectExportEntries.
    2. Else if ee.[[ImportName]] is all-but-default, then
      1. Assert: ee.[[ExportName]] is null.
      2. Append ee to starExportEntries.
    3. Else,
      1. Append ee to indirectExportEntries.
  11. Let async be body Contains await.
  12. Let moduleSourceObject be OrdinaryObjectCreate(%ModuleSource.prototype%, « [[ModuleSourceRecord]] »).
  13. Let moduleSourceRecord be the Module Source Record { [[HostDefined]]: hostDefined, [[SourceText]]: sourceText, [[ModuleSourceKind]]: "ModuleSource", [[ModuleSource]]: moduleSourceObject }.
  14. Set moduleSourceObject.[[ModuleSourceRecord]] to moduleSourceRecord.
  15. Return Source Text Module Record { [[Realm]]: realm, [[Environment]]: empty, [[Namespace]]: empty, [[CycleRoot]]: empty, [[HasTLA]]: async, [[AsyncEvaluation]]: false, [[TopLevelCapability]]: empty, [[AsyncParentModules]]: « », [[PendingAsyncDependencies]]: empty, [[Status]]: new, [[EvaluationError]]: empty, [[HostDefined]]: hostDefined, [[SourceRecord]]: moduleSourceRecord, [[ECMAScriptCode]]: body, [[Context]]: empty, [[ImportMeta]]: empty, [[ModuleSource]]: moduleSourceObject, [[RequestedModules]]: requestedModules, [[LoadedModules]]: « », [[ImportEntries]]: importEntries, [[LocalExportEntries]]: localExportEntries, [[IndirectExportEntries]]: indirectExportEntries, [[StarExportEntries]]: starExportEntries, [[DFSIndex]]: empty, [[DFSAncestorIndex]]: empty }.
Note

An implementation may parse module source text and analyse it for Early Error conditions prior to the evaluation of ParseModule for that module source text. However, the reporting of any errors must be deferred until the point where this specification actually performs ParseModule upon that source text.

16.1.1.3.2 InitializeEnvironment ( )

The InitializeEnvironment concrete method of a Source Text Module Record module takes no arguments and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

  1. For each ExportEntry Record e of module.[[IndirectExportEntries]], do
    1. Assert: e.[[ExportName]] is not null.
    2. Let resolution be module.ResolveExport(e.[[ExportName]]).
    3. If resolution is either null or ambiguous, throw a SyntaxError exception.
    4. Assert: resolution is a ResolvedBinding Record.
  2. Assert: All named exports from module are resolvable.
  3. Let realm be module.[[Realm]].
  4. Assert: realm is not undefined.
  5. Let env be NewModuleEnvironment(realm.[[GlobalEnv]]).
  6. Set module.[[Environment]] to env.
  7. For each ImportEntry Record in of module.[[ImportEntries]], do
    1. Let importedModule be GetImportedModule(module, in.[[ModuleRequest]]).
    2. If in.[[ImportName]] is namespace-object, then
      1. Let namespace be GetModuleNamespace(importedModule).
      2. Perform ! env.CreateImmutableBinding(in.[[LocalName]], true).
      3. Perform ! env.InitializeBinding(in.[[LocalName]], namespace).
    3. Else if in.[[ImportName]] is source, then
      1. Let moduleSourceObject be importedModule.[[ModuleSource]][[SourceRecord]].[[ModuleSource]].
      2. If moduleSourceObject is empty, throw a SyntaxError exception.
      3. Perform ! env.CreateImmutableBinding(in.[[LocalName]], true).
      4. Perform ! env.InitializeBinding(in.[[LocalName]], moduleSourceObject).
    4. Else,
      1. ...
  8. ...

16.1.1.4 HostLoadImportedModule ( referrer, moduleRequest, hostDefined, payload )

The host-defined abstract operation HostLoadImportedModule takes arguments referrer (a Script Record, a Cyclic Module Record, or a Realm Record), moduleRequest (a ModuleRequest Record), hostDefined (anything), and payload (a GraphLoadingState Record or a PromiseCapability Record) and returns unused.

Note 1

An example of when referrer can be a Realm Record is in a web browser host. There, if a user clicks on a control given by

<button type="button" onclick="import('./foo.mjs')">Click me</button>

there will be no active script or module at the time the import() expression runs. More generally, this can happen in any situation where the host pushes execution contexts with null ScriptOrModule components onto the execution context stack.

An implementation of HostLoadImportedModule must conform to the following requirements:

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.

Note 2

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.

16.1.1.5 FinishLoadingImportedModule ( referrer, moduleRequest, payload, result )

The abstract operation FinishLoadingImportedModule takes arguments referrer (a Script Record, a Cyclic Module Record, or a Realm Record), moduleRequest (a ModuleRequest Record), payload (a GraphLoadingState Record or a PromiseCapability Record), and result (either a normal completion containing a Module Record or a throw completion) and returns unused. It performs the following steps when called:

  1. If result is a normal completion and moduleRequest.[[Specifier]] is a String, then
    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.
    2. Else,
      1. Append the LoadedModuleRequest Record { [[Specifier]]: moduleRequest.[[Specifier]], [[Attributes]]: moduleRequest.[[Attributes]], [[Module]]: result.[[Value]] } to referrer.[[LoadedModules]].
  2. If payload is a GraphLoadingState Record, then
    1. Assert: moduleRequest.[[Specifier]] is a String.
    2. Perform ContinueModuleLoading(payload, moduleRequest.[[Phase]], result).
  3. Else,
    1. Perform ContinueDynamicImport(payload, moduleRequest.[[Phase]], result).
  4. Return unused.

16.1.1.6 Synthetic Module Records

16.1.1.6.1 CreateDefaultExportSyntheticModule ( defaultExport )

The abstract operation CreateDefaultExportSyntheticModule takes argument defaultExport (an ECMAScript language value) and returns a Synthetic Module Record. It creates a Synthetic Module Record whose default export is defaultExport. It performs the following steps when called:

  1. Let realm be the current Realm Record.
  2. Let moduleSourceRecord be the Module Source Record { [[HostDefined]]: undefined, [[SourceText]]: none, [[ModuleSourceKind]]: "SyntheticModule", [[ModuleSource]]: empty }.
  3. Let setDefaultExport be a new Abstract Closure with parameters (module) that captures defaultExport and performs the following steps when called:
    1. Perform SetSyntheticModuleExport(module, "default", defaultExport).
    2. Return NormalCompletion(unused).
  4. Return the Synthetic Module Record { [[Realm]]: realm, [[Environment]]: empty, [[Namespace]]: empty, [[HostDefined]]: undefined[[SourceRecord]]: moduleSourceRecord, [[ExportNames]]: « "default" », [[EvaluationSteps]]: setDefaultExport }.

16.1.1.7 GetModuleSourceRecord ( specifier )

The abstract operation GetModuleSourceRecord takes argument specifier (an Object) and returns either a Module Source Record or not-a-source.

It provides the Module Source Record for all Module Source Objects.

It performs the following steps when called:

  1. If specifier has a [[ModuleSourceRecord]] internal slot, then
    1. Return specifier.[[ModuleSourceRecord]].
  2. Else,
    1. Return HostGetModuleSourceRecord(specifier).

16.1.1.8 HostGetModuleSourceModuleRecord ( specifier )

The host-defined abstract operation HostGetModuleSourceModuleRecord takes argument specifier (an Object) and returns either a Module Record or not-a-source.

16.1.1.9 HostGetModuleSourceRecord ( specifier )

The host-defined abstract operation HostGetModuleSourceRecord takes argument specifier (an Object) and returns either a Module Source Record or not-a-source.

Allows hosts to provide the Module Source Record for a non-ECMA-262 module source object.

An implementation of HostGetModuleSourceRecord must conform to the following requirements:

  • Defines any host-specific module sources, by returning their Module Source Record.
  • For all other objects, returns not-a-source.

The default implementation of HostGetModuleSourceRecord is to return not-a-source.

Note

This host hook is only for module types implemented outside of ECMA-262. See GetModuleSourceRecord, where %ModuleSource% is handled before calling this hook.

28 Reflection

28.1 Module Source Objects

Module Source Objects represent the immutable data associated with a module record, distinct from linking, instantiation or execution state.modules in their source import phase, which are not linked, instantiated or executed.

A Module Source Object is an object for which HostGetModuleSourceModuleRecordGetModuleSourceRecord returns a Module Source Record.

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

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

28.1.1 Properties of the %AbstractModuleSource% Prototype Object

28.1.1.1 get %AbstractModuleSource%.prototype [ %Symbol.toStringTag% ]

%AbstractModuleSource%.prototype [%Symbol.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.
  2. If O is not an Object, return undefined.
  3. Let module be HostGetModuleSourceModuleRecordGetModuleSourceRecord(O).
  4. If module is not-a-source, return undefined.
  5. Let name be module.[[ModuleSourceKind]]GetModuleSourceKind().
  6. Assert: name is a String.
  7. 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]".

28.1.2 The ModuleSource Constructor

The ModuleSource constructor:

  • is %ModuleSource%.
  • does not have a global name or appear as a property of the global object.

28.1.2.1 ModuleSource ( )

This function performs the following steps when called:

  1. Throw a TypeError exception.

28.1.3 Properties of the %ModuleSource% Prototype Object

The %ModuleSource% prototype object:

  • has a [[Prototype]] internal slot whose value is %AbstractModuleSource.prototype%.
  • is %ModuleSource.prototype%.
  • is an ordinary object.
  • has the following properties:

28.1.3.1 %ModuleSource%.prototype.constructor

The initial value of %ModuleSource%.prototype.constructor is %ModuleSource%.

28.1.4 Properties of ModuleSource Instances

ModuleSource instances are ordinary objects that inherit properties from the %ModuleSource% prototype object.

ModuleSource instances have a [[ModuleSourceRecord]] internal slot.

Annex A (informative) Host Layering Points

A.1 Host-defined Fields

[[HostDefined]] on Module Source Records: See Table 38Table 4.

A.2 Host Hooks

HostCallJobCallback(...)

HostEnqueueFinalizationRegistryCleanupJob(...)

HostEnqueueGenericJob(...)

HostEnqueuePromiseJob(...)

HostEnqueueTimeoutJob(...)

HostEnsureCanCompileStrings(...)

HostFinalizeImportMeta(...)

HostGetImportMetaProperties(...)

HostGetModuleSourceModuleRecordHostGetModuleSourceRecord(...)

HostGrowSharedArrayBuffer(...)

HostHasSourceTextAvailable(...)

HostLoadImportedModule(...)

HostGetSupportedImportAttributes(...)

HostMakeJobCallback(...)

HostPromiseRejectionTracker(...)

HostResizeArrayBuffer(...)

InitializeHostDefinedRealm(...)

Copyright & Software License

Software License

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.