?um/p1-90`super를 포함하는 소스 텍스트가 super이면 구문 오류이다. super에 대한 추가 The syntax-directed operation ScriptIsStrict takes no arguments and returns 불리언. It is defined piecewise over the following productions:
Script Record는 평가 중인 스크립트에 대한 정보를 캡슐화한다. 각 script record는
| 필드 이름 | 값 타입 | 의미 |
|---|---|---|
| [[Realm]] |
|
이 스크립트가 생성된 |
| [[ECMAScriptCode]] |
|
이 스크립트의 소스 텍스트를 파싱한 결과. |
| [[LoadedModules]] |
|
이 스크립트가 import한 지정자 문자열에서 해석된 Module |
| [[HostDefined]] |
아무 값(기본값은 |
스크립트와 추가 정보를 연결해야 하는 |
The abstract operation ParseScript takes arguments sourceText (
구현체는 해당 스크립트 소스 텍스트에 대해 ParseScript를 평가하기 전에 스크립트 소스 텍스트를 파싱하고
The abstract operation ScriptEvaluation takes argument scriptRecord (
The abstract operation GlobalDeclarationInstantiation takes arguments script (
스크립트를 평가하기 위해 실행 컨텍스트가 설정될 때, 선언은 현재 전역 환경에서 인스턴스화된다. 코드에서 선언된 각 전역 바인딩이 인스턴스화된다.
호출될 때 다음 단계를 수행한다:
var와 function 바인딩(비엄격 명시적인 var 또는 function 선언과 달리,
super이면 구문 오류이다.
중복 export default
The abstract operation ImportedLocalNames takes argument importEntries (
ModuleRequest Record는 주어진 import 속성과 함께 모듈을 가져오기 위한 요청을 나타낸다. 다음 필드로 구성된다:
| 필드 이름 | 값 타입 | 의미 |
|---|---|---|
| [[Specifier]] | String | 모듈 지정자 |
| [[Attributes]] |
|
import 속성들 |
LoadedModuleRequest Record는 모듈 요청과 해당 결과 Module
| 필드 이름 | 값 타입 | 의미 |
|---|---|---|
| [[Specifier]] | String | 모듈 지정자 |
| [[Attributes]] |
|
import 속성들 |
| [[Module]] |
Module |
이 모듈 요청에 해당하는 로드된 모듈 |
ImportAttribute Record는 다음 필드로 구성된다:
| 필드 이름 | 값 타입 | 의미 |
|---|---|---|
| [[Key]] | String | 속성 키 |
| [[Value]] | String | 속성 값 |
The abstract operation ModuleRequestsEqual takes arguments left (
The syntax-directed operation ModuleRequests takes no arguments and returns
모듈 레코드는 단일 모듈의 import/export에 대한 구조적 정보를 캡슐화합니다. 이 정보는 연결된 모듈 집합의 import/export 연결에 사용됩니다. 모듈 레코드에는 모듈 평가 시에만 사용되는 네 개의 필드가 포함되어 있습니다.
명세 목적상, 모듈 레코드는
모듈 레코드는
| 필드 이름 | 값 타입 | 의미 |
|---|---|---|
| [[Realm]] |
영역( |
이 모듈이 생성된 영역( |
| [[Environment]] |
모듈 환경 레코드 또는 |
이 모듈의 최상위 바인딩을 포함하는 환경 레코드. 이 필드는 모듈이 링크될 때 설정됩니다. |
| [[Namespace]] |
객체 또는 |
만약 이 모듈에 대해 생성된 경우,
모듈 네임스페이스 객체
( |
| [[HostDefined]] |
임의 (기본값은 |
|
| 메서드 | 목적 | 정의 |
|---|---|---|
| LoadRequestedModules ( [ hostDefined ] ) | The abstract method LoadRequestedModules takes optional argument hostDefined (anything) and returns 프라미스(Promise). 모든 의존성을 재귀적으로 로드하여 모듈을 링크 준비 상태로 만든다. |
이 명세에서는 다음 타입에 정의되어 있으며,
|
| GetExportedNames ( [ exportStarSet ] ) | The abstract method GetExportedNames takes optional argument exportStarSet (a 이 모듈에서 직접 또는 간접적으로 내보내는 모든 이름의 목록을 반환한다.
이 메서드를 호출하기 전에
|
이 명세에서는 다음 타입에 정의되어 있으며,
|
| ResolveExport ( exportName [ , resolveSet ] ) | The abstract method ResolveExport takes argument exportName (a String) and optional argument resolveSet (a
이 모듈이 내보내는 이름의 바인딩을 반환한다.
바인딩은 {[[Module]]: 이 연산은 같은 exportName, resolveSet 쌍에 대해 호출할 때마다 동일한 결과를 반환해야 한다.
이 메서드를 호출하기 전에 |
이 명세에서는 다음 타입에 정의되어 있으며,
|
| Link ( ) | The abstract method Link takes no arguments and returns 모든 모듈 의존성을 전이적으로 해결하고 모듈 환경 레코드를 생성하여 평가 준비를 마친다.
이 메서드를 호출하기 전에 |
이 명세에서는 다음 타입에 정의되어 있으며,
|
| Evaluate ( ) | The abstract method Evaluate takes no arguments and returns 프라미스(Promise).
이 모듈과 그 의존성의 평가에 대한
프라미스를 반환하며,
성공하면 resolve 되고
이미 성공한 경우에도 resolve 되고,
평가 오류이거나 이전에 실패했다면 reject.
reject 시 이 메서드 호출 전 |
이 명세에서는 다음 타입에 정의되어 있으며,
|
The abstract operation EvaluateModuleSync takes argument module (a Module
Cyclic Module Record는 다른
| Field Name | Value Type | Meaning |
|---|---|---|
| [[Status]] |
|
초기값은 |
| [[EvaluationError]] |
|
평가 중 발생한 예외를 나타내는 |
| [[DFSAncestorIndex]] |
|
|
| [[RequestedModules]] |
|
이 모듈의 import와 관련된 |
| [[LoadedModules]] |
|
이 레코드가 나타내는 모듈이 상대적 import 속성과 함께 모듈을 요청할 때 사용한 specifier 문자열을, 해결된 Module |
| [[CycleRoot]] |
|
순환의 최초 방문 모듈이며, 강결합 컴포넌트의 루트 DFS 조상이다. 순환에 속하지 않은 모듈의 경우 자기 자신이 된다. |
| [[HasTLA]] | Boolean |
이 모듈이 개별적으로 비동기인지 여부를 나타낸다(예: top-level await을 포함하는 |
| [[AsyncEvaluationOrder]] |
|
초기값은 |
| [[TopLevelCapability]] |
PromiseCapability |
이 모듈이 어떤 순환의 [[CycleRoot]]이고, 해당 순환 내 모듈 중 하나에서 |
| [[AsyncParentModules]] |
|
이 모듈 또는 의존성 중 하나가 [[HasTLA]]가 |
| [[PendingAsyncDependencies]] |
|
이 모듈이 비동기 의존성을 가지는 경우, 아직 실행되지 않은 비동기 의존 모듈의 개수를 추적한다. 이 값이 0이 되고 실행 오류가 없을 때 모듈이 실행된다. |
| Method | Purpose | Definitions |
|---|---|---|
| InitializeEnvironment ( ) | The abstract method InitializeEnvironment takes no arguments and returns |
이 명세에서는 다음 타입들에 정의가 존재하며, |
| ExecuteModule ( [ capability ] ) | The abstract method ExecuteModule takes optional argument capability (PromiseCapability |
이 명세에서는 다음 타입들에 정의가 존재하며, |
GraphLoadingState Record는 모듈 그래프의 로딩 과정에 대한 정보를 포함하는
| Field Name | Value Type | Meaning |
|---|---|---|
| [[PromiseCapability]] |
PromiseCapability |
로딩 프로세스가 완료되면 resolve될 promise이다. |
| [[IsLoading]] | Boolean | 로딩 프로세스가 아직 완료되지 않았고, 성공도 실패도 아닌 상태일 때 true이다. |
| [[PendingModulesCount]] |
0 이상의 |
대기 중인 |
| [[Visited]] |
|
현재 로딩 과정에서 이미 로드된 |
| [[HostDefined]] |
아무 값 (기본값은 |
|
다음은
The
<link rel="preload" as="..."> 태그에 대한 올바른 fetch destination을 설정하는 데 사용된다.
import() 표현식은 절대로 hostDefined 매개변수를 설정하지 않는다.
The abstract operation InnerModuleLoading takes arguments state (a
The abstract operation ContinueModuleLoading takes arguments state (a
The
The abstract operation InnerModuleLinking takes arguments module (a Module
The
The abstract operation InnerModuleEvaluation takes arguments module (a Module
모듈은 InnerModuleEvaluation에 의해 순회되는 동안
비동기 cycle의 모듈에 의존하는 모든 모듈은, 그 cycle이
The abstract operation ExecuteAsyncModule takes argument module (a
The abstract operation GatherAvailableAncestors takes arguments module (a
루트 module에 대한 비동기 실행이 fulfilled되면, 이 함수는 이 완료에서 함께 동기적으로 실행할 수 있는 모듈들의 목록을 결정하여 execList에 채운다.
The abstract operation AsyncModuleExecutionFulfilled takes argument module (a
The abstract operation AsyncModuleExecutionRejected takes arguments module (a
이 비규범 절은 몇 가지 일반적인 모듈 그래프의 링킹 및 평가 예시를, 오류가 어떻게 발생할 수 있는지에 특히 초점을 맞추어 제시한다.
먼저 다음의 단순한 모듈 그래프를 생각해 보자.
먼저 오류 조건이 없다고 가정하자.
그다음 A.
마지막으로,
이제 다른 유형의 오류 조건을 생각해 보자.
이 시나리오에서 모듈 A는 어떤 다른 모듈에 대한 의존성을 선언하지만, 그 모듈에 대한 Module
여기서 로딩, 링킹, 평가 오류 사이의 차이는 다음 특성 때문이다.
이제 cycle이 있는 모듈 그래프를 생각해 보자.
여기서는 진입점이 모듈 A라고 가정하므로,
그다음
순환 모듈 그래프의 평가 단계에서도 성공 사례에서는 이와 유사한 이야기가 발생한다.
이제 A에 링킹 오류가 있는 경우를 생각해 보자. 예를 들어 C에 존재하지 않는 binding을 import하려 한다고 하자. 이 경우에도 A에 대한 두 번째
또는 A에 평가 오류가 있는 경우를 생각해 보자. 예를 들어 그 소스 코드가 예외를 던진다고 하자. 이 경우에도 A에 대한 두 번째 await를 포함하거나 이에 의존하는 모듈들을 위한 체인을 형성한다. 따라서 A와 B는 모두
마지막으로, 모든 모듈이 비동기적으로 완료되는 cycle이 있는 모듈 그래프를 생각해 보자.
로딩과 링킹은 이전과 같이 발생하며, 모든 모듈은 [[Status]]가
A.
|
필드
|
A | B | C | D | E |
|---|---|---|---|---|---|
| [[DFSAncestorIndex]] | 0 | 0 | 0 | 0 | 4 |
| [[Status]] | |||||
| [[AsyncEvaluationOrder]] | 4 | 1 | 3 | 0 | 2 |
| [[AsyncParentModules]] | « » | « A » | « A » | « B, C » | « C » |
| [[PendingAsyncDependencies]] | 2 (B 및 C) | 1 (D) | 2 (D 및 E) | 0 | 0 |
E가 먼저 실행을 마친다고 가정하자. 그 일이 발생하면
|
필드
|
C | E |
|---|---|---|
| [[DFSAncestorIndex]] | 0 | 4 |
| [[Status]] | ||
| [[AsyncEvaluationOrder]] | 3 | |
| [[AsyncParentModules]] | « A » | « C » |
| [[PendingAsyncDependencies]] | 1 (D) | 0 |
다음으로 D가 완료된다(아직 실행 중이던 유일한 모듈이었기 때문이다). 그 일이 발생하면 await를 포함한다면 B와 병렬로 실행될 수도 있다). 갱신된 모듈들의 필드는
|
필드
|
B | C | D |
|---|---|---|---|
| [[DFSAncestorIndex]] | 0 | 0 | 0 |
| [[Status]] | |||
| [[AsyncEvaluationOrder]] | 1 | 3 | |
| [[AsyncParentModules]] | « A » | « A » | « B, C » |
| [[PendingAsyncDependencies]] | 0 | 0 | 0 |
C가 다음으로 실행을 마친다고 가정하자. 그 일이 발생하면
|
필드
|
A | C |
|---|---|---|
| [[DFSAncestorIndex]] | 0 | 0 |
| [[Status]] | ||
| [[AsyncEvaluationOrder]] | 4 | |
| [[AsyncParentModules]] | « » | « A » |
| [[PendingAsyncDependencies]] | 1 (B) | 0 |
그런 다음 B가 실행을 마친다. 그 일이 발생하면
|
필드
|
A | B |
|---|---|---|
| [[DFSAncestorIndex]] | 0 | 0 |
| [[Status]] | ||
| [[AsyncEvaluationOrder]] | 4 | |
| [[AsyncParentModules]] | « » | « A » |
| [[PendingAsyncDependencies]] | 0 | 0 |
마지막으로 A가 실행을 마친다. 그 일이 발생하면
|
필드
|
A |
|---|---|
| [[DFSAncestorIndex]] | 0 |
| [[Status]] | |
| [[AsyncEvaluationOrder]] | |
| [[AsyncParentModules]] | « » |
| [[PendingAsyncDependencies]] | 0 |
또는 B가 실행을 마치기 전에 C가 실행에 실패하고 오류를 반환하는 실패 사례를 생각해 보자. 그 일이 발생하면
|
필드
|
A | C |
|---|---|---|
| [[DFSAncestorIndex]] | 0 | 0 |
| [[Status]] | ||
| [[AsyncEvaluationOrder]] | ||
| [[AsyncParentModules]] | « » | « A » |
| [[PendingAsyncDependencies]] | 1 (B) | 0 |
| [[EvaluationError]] | C의 평가 오류 |
C가 C의 오류로 A에 대해
|
필드
|
A |
|---|---|
| [[DFSAncestorIndex]] | 0 |
| [[Status]] | |
| [[AsyncEvaluationOrder]] | |
| [[AsyncParentModules]] | « » |
| [[PendingAsyncDependencies]] | 0 |
| [[EvaluationError]] | C의 |
그런 다음 B가 오류 없이 실행을 마친다. 그 일이 발생하면
|
필드
|
A | B |
|---|---|---|
| [[DFSAncestorIndex]] | 0 | 0 |
| [[Status]] | ||
| [[AsyncEvaluationOrder]] | 4 | 1 |
| [[AsyncParentModules]] | « » | « A » |
| [[PendingAsyncDependencies]] | 0 | 0 |
| [[EvaluationError]] | C의 |
Source Text Module Record는
| 필드 이름 | 값 타입 | 의미 |
|---|---|---|
| [[ECMAScriptCode]] | Parse Node |
이 모듈의 소스 텍스트를 |
| [[Context]] |
|
이 모듈과 관련된 실행 컨텍스트. 모듈의 환경이 초기화될 때까지 |
| [[ImportMeta]] |
Object 또는 |
import.meta meta property를 통해 노출되는 객체. ECMAScript 코드에 의해 접근될 때까지 |
| [[ImportEntries]] |
|
이 모듈의 코드에서 파생된 ImportEntry record의 |
| [[LocalExportEntries]] |
|
모듈 안에서 발생하는 선언에 대응하는, 이 모듈의 코드에서 파생된 ExportEntry record의 |
| [[IndirectExportEntries]] |
|
모듈 안에서 발생하는 재export된 import 또는 export * as namespace 선언의 export에 대응하는, 이 모듈의 코드에서 파생된 ExportEntry record의 |
| [[StarExportEntries]] |
|
모듈 안에서 발생하는 export * 선언에 대응하는, 이 모듈의 코드에서 파생된 ExportEntry record의 export * as namespace 선언은 포함하지 않는다.
|
ImportEntry Record는 단일 선언적 import에 관한 정보를 요약하는
| 필드 이름 | 값 타입 | 의미 |
|---|---|---|
| [[ModuleRequest]] |
|
|
| [[ImportName]] |
String 또는 |
원하는 binding이 [[ModuleRequest]]로 식별되는 모듈에 의해 export되는 이름. 값 |
| [[LocalName]] | String | import하는 모듈 안에서 import된 값을 로컬로 접근하는 데 사용되는 이름. |
| Import 문 형식 | [[ModuleRequest]] | [[ImportName]] | [[LocalName]] |
|---|---|---|---|
import v from "mod";
|
|
|
|
import * as ns from "mod";
|
|
|
|
import {x} from "mod";
|
|
|
|
import {x as v} from "mod";
|
|
|
|
import "mod";
|
|
||
ExportEntry Record는 단일 선언적 export에 관한 정보를 요약하는
| 필드 이름 | 값 타입 | 의미 |
|---|---|---|
| [[ExportName]] |
String 또는 |
이 모듈이 이 binding을 export하는 데 사용하는 이름. |
| [[ModuleRequest]] |
|
|
| [[ImportName]] |
String, |
원하는 binding이 [[ModuleRequest]]로 식별되는 모듈에 의해 export되는 이름. export * as ns from "mod" 선언에 사용된다. export * from "mod" 선언에 사용된다.
|
| [[LocalName]] |
String 또는 |
import하는 모듈 안에서 export된 값에 로컬로 접근하는 데 사용되는 이름. export된 값이 모듈 안에서 로컬로 접근 가능하지 않으면 |
| Export 문 형식 | [[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";
|
|
|
|
|
다음 정의들은
The abstract operation ParseModule takes arguments sourceText (ECMAScript source text), realm (a
export * from을 통해 같은 이름 아래 같은 binding 또는 namespace를 두 번 export하여 생기는 충돌을 await로 둔다.구현은 해당 모듈 소스 텍스트에 대해 ParseModule을 평가하기 전에 모듈 소스 텍스트를 파싱하고 Early Error 조건을 분석할 수 있다. 그러나 모든 오류 보고는 이 명세가 실제로 해당 소스 텍스트에 대해 ParseModule을 수행하는 시점까지 지연되어야 한다.
다음은
The
The
정의 모듈이 발견되면 ResolvedBinding
It performs the following steps when called:
다음은
The
The
Synthetic Module Record는 명세에 의해 정의된 모듈에 대한 정보를 나타내는 데 사용된다. 그 export된 이름들은 생성 시 정적으로 정의되지만, 해당 값들은
| 필드 이름 | 값 타입 | 의미 |
|---|---|---|
| [[ExportNames]] | String의 |
모듈의 export 이름들. 이 리스트에는 중복이 없다. |
| [[EvaluationSteps]] | 모듈 평가 시 수행할 초기화 로직으로, |
The abstract operation CreateDefaultExportSyntheticModule takes argument defaultExport (an ECMAScript language value) and returns a
The abstract operation ParseJSONModule takes argument source (a String) and returns either a
The abstract operation SetSyntheticModuleExport takes arguments module (a
다음은
The
The
The
The
The
The abstract operation GetImportedModule takes arguments referrer (a
The host-defined abstract operation HostLoadImportedModule takes arguments referrer (a
referrer가
<button type="button" onclick="import('./foo.mjs')">Click me</button>
import()
HostLoadImportedModule의 구현은 다음 요구 사항을 준수해야 한다:
이 연산이 두 (referrer, moduleRequest) 쌍에 대해 여러 번 호출될 때, 다음 조건을 만족하고:
result가
moduleRequest.[[Attributes]]에 entry.[[Key]]가
실제 수행되는 과정은
위의 텍스트는 type: "json"으로 import될 때 JSON 모듈을 지원해야 함을 요구하지만(HostLoadImportedModule이 정상적으로 완료되는 경우), type: "json" 없이 import될 때 JSON 모듈을 지원하는 것을 금지하지는 않는다.
The abstract operation FinishLoadingImportedModule takes arguments referrer (a
The abstract operation AllImportAttributesSupported takes argument attributes (a
The host-defined abstract operation HostGetSupportedImportAttributes takes no arguments and returns a
HostGetSupportedImportAttributes의 구현은 다음 요구 사항을 준수해야 한다:
HostGetSupportedImportAttributes의 기본 구현은 새로운 빈
The abstract operation GetModuleNamespace takes argument module (an instance of a concrete subclass of Module
GetModuleNamespace는 절대 예외를 던지지 않는다. 대신 해소할 수 없는 이름은 이 시점에서 단순히 namespace에서 제외된다. 이러한 이름들은 나중에 실제 링크 오류로 이어지지만, 어디에서도 명시적으로 요청되지 않는 ambiguous star export인 경우에는 예외가 발생하지 않을 수 있다.
The syntax-directed operation ImportEntries takes no arguments and returns a
The syntax-directed operation ImportEntriesForModule takes argument module (a
The syntax-directed operation WithClauseToAttributes takes no arguments and returns a
위 규칙은
The syntax-directed operation ExportedBindings takes no arguments and returns a
ExportedBindings는
It is defined piecewise over the following productions:
The syntax-directed operation ExportedNames takes no arguments and returns a
ExportedNames는
It is defined piecewise over the following productions:
The syntax-directed operation ExportEntries takes no arguments and returns a
The syntax-directed operation ExportEntriesForModule takes argument module (a
The syntax-directed operation ReferencedBindings takes no arguments and returns a