?
u
/
This proposal builds on top of the Module Expressions proposal, which introduces the following production:
The
The
The
The
Unless explicitly specified otherwise, all nonterminals have an implicit definition for ContainsUndefinedModuleReference with argument declaredModules.The implicit definition applies ContainsUndefinedModuleReference with argument declaredModules to the nonterminal's inner nonterminals, and returns
The following productions have a different definition of ContainsUndefinedModuleReference:
The abstract operation ContainsUndefinedModuleReferenceInFunction takes arguments declaredModules (a
The
The
The
Unless explicitly specified otherwise, all nonterminals have an implicit definition for ParseInnerModules with argument declaredModules.The implicit definition applies ParseInnerModules with argument declaredModules to the nonterminal's inner nonterminals. For example,
The following productions have a different definition of
Environment Record is a specification type used to define the association of
Every Environment Record has an [[OuterEnv]] field, which is either
Environment Records are purely specification mechanisms and need not correspond to any specific artefact of an ECMAScript implementation. It is impossible for an ECMAScript program to directly access or manipulate such values.
Each Environment Record has the fields listed in
Field | Type | Purpose |
---|---|---|
[[OuterEnv]] |
an |
|
[[ModuleDeclarations]] |
a |
The following
The abstract operation AddModuleDeclaration takes arguments name (a String), module (a
The abstract operation ResolveModuleDeclaration takes arguments name (a String) and env (an
The abstract operation FunctionDeclarationInstantiation takes arguments func (a
eval
in eval
.The abstract operation BlockDeclarationInstantiation takes arguments code (a
It performs the following steps when called:
A Script Record encapsulates information about a script being evaluated. Each script record contains the fields listed in
Field Name | Value Type | Meaning |
---|---|---|
[[Realm]] |
a |
|
[[ECMAScriptCode]] |
a |
|
[[LoadedModules]] |
a |
|
[[HostDefined]] |
anything (default value is |
The abstract operation GlobalDeclarationInstantiation takes arguments script (a
Unlike explicit var or function declarations, properties that are directly created on the
The
Method | Purpose |
---|---|
GetExportedNames([exportStarSet]) | |
ResolveExport(exportName [, resolveSet]) | |
GetExportedModule(name) |
Return the Unless otherwise specified, the default implementation of this method is:
|
LoadRequestedModules( [ hostDefined ] ) | |
Link() | |
Evaluate() |
The abstract operation GetModuleObject takes argument moduleRecord (a
In addition to the fields defined in
Field Name | Value Type | Meaning |
---|---|---|
[[Status]] |
|
|
[[EvaluationError]] |
a |
|
[[DFSIndex]] |
an |
|
[[DFSAncestorIndex]] |
an |
|
[[RequestedModules]] |
a |
A |
[[LoadedModules]] |
a |
A map from the specifier strings used by the module represented by this record to request the importation of a module to the resolved |
[[CycleRoot]] |
a |
|
[[HasTLA]] | a Boolean | |
[[AsyncEvaluation]] | a Boolean | |
[[TopLevelCapability]] |
a |
|
[[AsyncParentModules]] |
a |
|
[[PendingAsyncDependencies]] |
an |
In addition to the methods defined in
Method | Purpose |
---|---|
LoadInternalModule( name ) |
Loads the internal module with the given name and returns a Unless otherwise specified, the default implementation of this method is:
|
InitializeEnvironment() | |
ExecuteModule( [ promiseCapability ] ) |
A ModuleSpecifier Record represents the request to import a module. Each
Field Name | Value Type | Meaning |
---|---|---|
[[Name]] | a String |
The name of the imported module. For example, it's the string "foo" in import "foo";
|
[[Type]] |
|
Whether the module is an internal module, that should be declared nested inside another module, or an external module, that should be loaded using the |
An ImportedModule Record represents a module which is imported from another module. Each
Field Name | Value Type | Meaning |
---|---|---|
[[Specifier]] |
a |
The specifier of the module this module is imported from. |
[[ImportName]] | a String | The name of the imported module. |
A GraphLoadingState Record is a
Field Name | Value Type | Meaning |
---|---|---|
[[PromiseCapability]] |
a |
The promise to resolve when the loading process finishes. |
[[IsLoading]] | a Boolean | It is true if the loading process has not finished yet, neither successfully nor with an error. |
[[PendingModulesCount]] |
a non-negative |
It tracks the number of pending |
[[Visited]] |
a |
It is a list of the |
[[HostDefined]] |
anything (default value is |
It contains |
A BlockedInternalImport Record represents an import from an internal module that cannot be handled, because the internal module is imported from another module that hasn't been loaded yet. Each
Field Name | Value Type | Meaning |
---|---|---|
[[BlockerReferrer]] |
a |
[[BlockerReferrer]] and [[BlockerSpecifier]] together indicate the module that is currently preventing the internal module from being imported. |
[[BlockedSpecifier]] |
a |
|
[[ImportName]] | a String | It is the name of the expected module exported by ([[BlockerReferrer]], [[BlockerSpecifier]]). |
[[BlockedReferrer]] |
a |
It is the module that is currently blocked from importing the internal module. |
[[LocalName]] | a String | It is the local alias, in [[BlockedReferrer]], of the imported module. |
To better understand the contents of
Module | Source |
---|---|
A |
|
B |
|
C |
|
Assume that the loading process of external modules is asynchronous. When loading the dependencies of A, module
cannot be resolved yet and it will be represented by the "mod"
, [[BlockedReferrer]]: A,[[LocalName]]: "module"
}.
When B is loaded, module
cannot be imported yet, because mod
is not defined in B but in one of its dependencies: the above "myModule"
, [[BlockedReferrer]]: A, [[LocalName]]: "module"
}.
Finally, after C has finished loading, it's possible to load the module
internal module. This logic is handled in the below
The LoadRequestedModules concrete method of
The abstract operation InnerModuleLoading takes arguments state (a
The abstract operation ContinueModuleLoading takes arguments state (a
The abstract operation ProcessBlockedInternalRequests takes arguments state (a
The abstract operation AbortModuleLoading takes arguments state (a
In addition to the fields defined in
Field Name | Value Type | Meaning |
---|---|---|
[[ECMAScriptCode]] |
a |
|
[[Context]] |
an ECMAScript |
|
[[ImportMeta]] | an Object | |
[[ImportEntries]] |
a |
|
[[LocalExportEntries]] |
a |
|
[[IndirectExportEntries]] |
a |
|
[[StarExportEntries]] |
a |
|
[[VisibleModuleDeclarations]] |
a |
All the |
An ImportEntry Record is a
Field Name | Value Type | Meaning |
---|---|---|
[[ModuleRequest]] |
|
|
[[ImportName]] |
a String or |
The name under which the desired binding is exported by the module identified by [[ModuleRequest]]. The value |
[[LocalName]] | a String | The name that is used to locally access the imported value from within the importing module. |
Import Statement Form | [[ModuleRequest]] | [[ImportName]] | [[LocalName]] |
---|---|---|---|
import v from "mod";
|
|
|
|
import * as ns from "mod";
|
|
|
|
import {x} from "mod";
|
|
|
|
import {x as v} from "mod";
|
|
|
|
import {x as v} from mod;
|
|
|
|
import "mod";
|
An |
An ExportEntry Record is a
Field Name | Value Type | Meaning |
---|---|---|
[[ExportName]] |
a String or |
The name used to export this binding by this module. |
[[ModuleRequest]] |
a |
The |
[[ImportName]] |
a String, |
The name under which the desired binding is exported by the module identified by [[ModuleRequest]]. export * as ns from "mod" declarations. export * from "mod" declarations.
|
[[LocalName]] |
a String or |
The name that is used to locally access the exported value from within the importing module. |
Export Statement Form | [[ExportName]] | [[ModuleRequest]] | [[ImportName]] | [[LocalName]] |
---|---|---|---|---|
export var v;
|
|
|
|
|
export default function f() {}
|
|
|
|
|
export default function () {}
|
|
|
|
|
export default 42;
|
|
|
|
|
export {x};
|
|
|
|
|
export {v as x};
|
|
|
|
|
export {x} from "mod";
|
|
|
|
|
export {v as x} from "mod";
|
|
|
|
|
export * from "mod";
|
|
|
|
|
export * as ns from "mod";
|
|
|
|
|
export {x} from mod;
|
|
|
|
|
The following definitions specify the required concrete methods and other
The abstract operation ParseModule takes arguments sourceText (
The abstract operation BuildSourceTextModuleRecord takes arguments body (a
await
.The abstract operation InstantiateModuleDeclarations takes arguments node (a
The InitializeEnvironment concrete method of a
The LoadInternalModule concrete method of a
The GetExportedModule concrete method of a
The abstract operation FinishLoadingImportedModule takes arguments referrer (a
The String
The String
© 2023 Daniel Ehrenberg, Nicolò Ribaudo
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:
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.