?
u
m
/
p
1-9
0
`
super
를 포함한 소스 텍스트가 직접 eval에 의해 처리되는 eval 코드가 아닌 한, super
를 포함하면 구문 오류이다. 직접 eval 내의 super
에 대한 추가 조기 오류 규칙은 The syntax-directed operation UNKNOWN takes UNPARSEABLE ARGUMENTS. It is defined piecewise over the following productions:
스크립트 레코드는 평가되는 스크립트에 대한 정보를 캡슐화한다. 각
필드 이름 | 값 타입 | 의미 |
---|---|---|
[[Realm]] |
|
이 스크립트가 생성된 영역. |
[[ECMAScriptCode]] |
|
이 스크립트의 소스 텍스트를 파싱한 결과. |
[[LoadedModules]] |
|
이 스크립트가 가져온 지정자 문자열에서 해결된 Module |
[[HostDefined]] |
anything (기본값은 |
스크립트와 추가 정보를 연결해야 하는 |
The abstract operation ParseScript takes arguments sourceText (ECMAScript 소스 텍스트), realm (
구현은 해당 스크립트 소스 텍스트에 대해 ParseScript를 평가하기 전에 스크립트 소스 텍스트를 파싱하고 조기 오류 조건을 분석할 수 있다. 그러나 오류 보고는 이 명세가 실제로 해당 소스 텍스트에 대해 ParseScript를 수행하는 시점까지 연기되어야 한다.
The abstract operation ScriptEvaluation takes argument scriptRecord (Script
The abstract operation GlobalDeclarationInstantiation takes arguments script (
스크립트 평가를 위한 실행 컨텍스트가 설정될 때, 선언은 현재 전역 환경에서 인스턴스화된다. 코드에서 선언된 각 전역 바인딩이 인스턴스화된다.
호출될 때 다음 단계를 수행한다:
var
와 function
바인딩(비-strict 직접 eval에 의해 도입된 것들을 제외하고)은 non-configurable이므로 제한된 전역 속성이다.명시적인 var 또는 function 선언과 달리,
super
를 포함하면 구문 오류이다.
중복된 ExportedNames 규칙은 export default
The abstract operation UNKNOWN takes UNPARSEABLE ARGUMENTS. It performs the following steps when called:
ModuleRequest 레코드는 주어진 가져오기 속성을 가진 모듈을 가져오는 요청을 나타낸다. 다음 필드들로 구성된다:
필드 이름 | 값 타입 | 의미 |
---|---|---|
[[Specifier]] | 문자열 | 모듈 지정자 |
[[Attributes]] |
|
가져오기 속성 |
LoadedModuleRequest 레코드는 모듈을 가져오는 요청과 결과 Module
필드 이름 | 값 타입 | 의미 |
---|---|---|
[[Specifier]] | 문자열 | 모듈 지정자 |
[[Attributes]] |
|
가져오기 속성 |
[[Module]] |
Module |
이 모듈 요청에 해당하는 로드된 모듈 |
ImportAttribute 레코드는 다음 필드들로 구성된다:
필드 이름 | 값 타입 | 의미 |
---|---|---|
[[Key]] | 문자열 | 속성 키 |
[[Value]] | 문자열 | 속성 값 |
The abstract operation ModuleRequestsEqual takes arguments left (ModuleRequest
The syntax-directed operation UNKNOWN takes UNPARSEABLE ARGUMENTS. It is defined piecewise over the following productions:
모듈 레코드는 단일 모듈의 가져오기와 내보내기에 대한 구조적 정보를 캡슐화한다. 이 정보는 연결된 모듈 집합의 가져오기와 내보내기를 링크하는 데 사용된다. 모듈 레코드는 모듈을 평가할 때만 사용되는 네 개의 필드를 포함한다.
명세 목적상 Module
Module
필드 이름 | 값 타입 | 의미 |
---|---|---|
[[Realm]] |
|
이 모듈이 생성된 |
[[Environment]] |
|
이 모듈의 최상위 바인딩을 포함하는 |
[[Namespace]] |
Object 또는 |
이 모듈에 대해 생성된 Module Namespace Object ( |
[[HostDefined]] |
anything (기본값은 |
모듈과 추가 정보를 연결해야 하는 |
메서드 | 목적 |
---|---|
LoadRequestedModules([hostDefined]) |
모든 의존성을 재귀적으로 로드하여 모듈을 링킹을 위해 준비하고 프로미스를 반환한다. |
GetExportedNames([exportStarSet]) |
이 모듈에서 직접 또는 간접적으로 내보내지는 모든 이름의 리스트를 반환한다. 이 메서드를 호출하기 전에 LoadRequestedModules가 성공적으로 완료되어야 한다. |
ResolveExport(exportName [, resolveSet]) |
이 모듈에서 내보낸 이름의 바인딩을 반환한다. 바인딩은 { [[Module]]: Module 특정 exportName, resolveSet 쌍을 인수로 이 연산을 호출할 때마다 동일한 결과를 반환해야 한다. 이 메서드를 호출하기 전에 LoadRequestedModules가 성공적으로 완료되어야 한다. |
Link() |
모든 모듈 의존성을 전이적으로 해결하고 이 메서드를 호출하기 전에 LoadRequestedModules가 성공적으로 완료되어야 한다. |
Evaluate() |
이 모듈과 그 의존성의 평가에 대한 프로미스를 반환하며, 성공적인 평가 시 또는 이미 성공적으로 평가된 경우 해결되고, 평가 오류 시 또는 이미 성공적이지 않게 평가된 경우 거부된다. 프로미스가 거부되면 이 메서드를 호출하기 전에 Link가 성공적으로 완료되어야 한다. |
The abstract operation EvaluateModuleSync takes argument module (Module
Cyclic Module Record는
필드 이름 | 값 타입 | 의미 |
---|---|---|
[[Status]] |
|
초기 값은 |
[[EvaluationError]] |
|
평가 중 발생한 예외를 나타내는 |
[[DFSAncestorIndex]] |
정수 또는 |
Link 및 Evaluate 동안에만 사용하는 보조 필드. [[Status]]가 |
[[RequestedModules]] |
ModuleRequest |
이 모듈의 import 들에 연관된 ModuleRequest |
[[LoadedModules]] |
LoadedModuleRequest |
이 |
[[CycleRoot]] |
|
순환의 최초 방문 모듈, 즉 SCC 의 루트 DFS 선조. 순환에 속하지 않는 모듈이면 자기 자신. Evaluate 완료 후 모듈의 [[DFSAncestorIndex]] 는 그 [[CycleRoot]] 의 DFS 인덱스가 된다. |
[[HasTLA]] | Boolean |
이 모듈이 개별적으로 비동기인지 여부(예: top-level await 를 포함하는 |
[[AsyncEvaluationOrder]] |
|
초기 |
[[TopLevelCapability]] |
|
이 모듈이 어떤 순환의 [[CycleRoot]] 이고 그 순환 내 어떤 모듈에 Evaluate() 가 호출되었다면, 그 전체 평가에 대한 |
[[AsyncParentModules]] |
|
이 모듈 또는 그 의존성이 [[HasTLA]] |
[[PendingAsyncDependencies]] |
정수 또는 |
비동기 의존성이 하나라도 있으면 남은 비동기 의존 모듈 수를 추적한다. 이 값이 0 이고 실행 오류가 없을 때 모듈이 실행된다. |
메서드 | 목적 |
---|---|
InitializeEnvironment() |
모든 import 된 바인딩을 해석하고 모듈의 |
ExecuteModule([promiseCapability]) |
모듈의 실행 컨텍스트 내에서 코드 평가. 이 모듈이 [[HasTLA]] 가 |
GraphLoadingState Record 는 모듈 그래프 로딩 과정에 대한 정보를 담는
필드 이름 | 값 타입 | 의미 |
---|---|---|
[[PromiseCapability]] |
|
로딩 프로세스 완료 시 resolve 해야 하는 Promise. |
[[IsLoading]] | Boolean |
로딩이 아직 성공/오류 어떤 형태로도 완료되지 않았으면 |
[[PendingModulesCount]] | 음이 아닌 정수 |
대기 중인 |
[[Visited]] |
|
현재 로딩 과정에서 이미 로드된 |
[[HostDefined]] |
anything (기본값 |
LoadRequestedModules 호출자에서 |
다음은
The LoadRequestedModules concrete method of
<link rel="preload" as="...">
태그에 대한 올바른 fetch destination 설정에 사용한다.
import()
표현식은 hostDefined 를 설정하지 않는다.
The abstract operation InnerModuleLoading takes arguments state (
The abstract operation ContinueModuleLoading takes arguments state (
The Link concrete method of
The abstract operation InnerModuleLinking takes arguments module (Module
The Evaluate concrete method of
The abstract operation InnerModuleEvaluation takes arguments module (Module
모듈은 InnerModuleEvaluation 이 순회 중이면
비동기 순환의 모듈에 의존하는 모듈은 순환이
The abstract operation ExecuteAsyncModule takes argument module (
The abstract operation GatherAvailableAncestors takes arguments module (
루트 module 의 비동기 실행이 fulfill 될 때, 이 함수는 동시에 동기 실행 가능한 모듈 목록을 결정하여 execList 에 채운다.
The abstract operation AsyncModuleExecutionFulfilled takes argument module (
The abstract operation AsyncModuleExecutionRejected takes arguments module (
비규범 섹션: 몇 가지 공통 모듈 그래프의 링크 및 평가 예시와 오류 발생 양상에 초점을 둔다.
먼저 다음 단순 모듈 그래프를 보자:
우선 오류 조건이 없다고 가정.
다음으로 링크 오류 사례: A.LoadRequestedModules() 성공 후
마지막으로 링크 성공 후 평가 오류:
이제 다른 오류 조건 유형:
이 시나리오에서 A 는 다른 모듈을 선언적 의존하지만 해당 Module
로딩 / 링크 / 평가 오류 차이는 다음 특징 때문:
이제 순환이 있는 그래프:
엔트리 포인트가 A 라 가정하고
그 후 A.Link() → A 에 대해
성공 사례에서 평가 단계도 유사.
A 에 링크 오류(예: C 에 존재하지 않는 바인딩 import) 인 경우 위 단계 진행 중 두 번째
유사하게 A 평가 오류(예: 코드 예외) 인 경우에도 평가 시퀀스는 비슷. 두 번째 await
를 가진 모듈 경유)
마지막으로 모든 모듈이 비동기 완료하는 순환 그래프:
로딩과 링크는 이전과 같고 모두 [[Status]] =
A.Evaluate() 는 A, B, D 에 대해
필드
|
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 완료.
필드
|
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 |
대안: C 가 B 완료 전 오류로 실패.
필드
|
A | C |
---|---|---|
[[DFSAncestorIndex]] | 0 | 0 |
[[Status]] | ||
[[AsyncEvaluationOrder]] | ||
[[AsyncParentModules]] | « » | « A » |
[[PendingAsyncDependencies]] | 1 (B) | 0 |
[[EvaluationError]] | C 의 평가 오류 |
C 가 A 에 대해
필드
|
A |
---|---|
[[DFSAncestorIndex]] | 0 |
[[Status]] | |
[[AsyncEvaluationOrder]] | |
[[AsyncParentModules]] | « » |
[[PendingAsyncDependencies]] | 0 |
[[EvaluationError]] | C 의 Evaluation Error |
이후 B 가 오류 없이 완료.
필드
|
A | B |
---|---|---|
[[DFSAncestorIndex]] | 0 | 0 |
[[Status]] | ||
[[AsyncEvaluationOrder]] | 4 | 1 |
[[AsyncParentModules]] | « » | « A » |
[[PendingAsyncDependencies]] | 0 | 0 |
[[EvaluationError]] | C 의 Evaluation Error |
Source Text Module Record 는
필드 이름 | 값 타입 | 의미 |
---|---|---|
[[ECMAScriptCode]] | Parse Node |
|
[[Context]] |
|
이 모듈에 연결된 실행 컨텍스트. 환경 초기화 전까지 |
[[ImportMeta]] |
Object 또는 |
import.meta 메타 프로퍼티로 노출되는 객체. ECMAScript 코드에서 접근 전까지 |
[[ImportEntries]] |
|
이 모듈 코드에서 도출된 ImportEntry 리스트. |
[[LocalExportEntries]] |
|
모듈 내 선언에 해당하는 export 에 대한 ExportEntry 리스트. |
[[IndirectExportEntries]] |
|
모듈 내 재export(import 재export 또는 export * as namespace ) 에 해당하는 ExportEntry 리스트.
|
[[StarExportEntries]] |
|
모듈 내 export * 선언(단, export * as namespace 제외)에 해당하는 ExportEntry 리스트.
|
ImportEntry Record 는 단일 선언적 import 에 대한 정보를 요약한
필드 이름 | 값 타입 | 의미 |
---|---|---|
[[ModuleRequest]] |
ModuleRequest |
|
[[ImportName]] |
String 또는 |
[[ModuleRequest]] 로 식별된 모듈이 해당 바인딩을 export 하는 이름. |
[[LocalName]] | String | 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 또는 |
모듈이 이 바인딩을 export 하는 이름. |
[[ModuleRequest]] |
ModuleRequest |
|
[[ImportName]] |
String, |
[[ModuleRequest]] 로 식별된 모듈이 해당 바인딩을 export 하는 이름. export * as ns from "mod" 는 export * from "mod" 는 |
[[LocalName]] |
String 또는 |
importer 모듈 내부에서 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 소스 텍스트), realm (
await
.구현은 ParseModule 평가 이전에 소스 텍스트를 파싱하고 Early Error 분석을 수행할 수 있으나 오류 보고는 실제 ParseModule 수행 시점까지 지연해야 한다.
The GetExportedNames concrete method of
export *
순환의 시작점 도달.GetExportedNames 는 모호한 star export 바인딩 이름을 필터링하거나 예외를 던지지 않는다.
The ResolveExport concrete method of
ResolveExport 는 import 된 바인딩을 실제 정의 모듈과 로컬 바인딩 이름으로 해석. 정의 모듈은 자신 또는 import 된 다른 모듈일 수 있음. resolveSet 은 순환 import/export 경로 탐지를 위해 사용. 동일 Module
정의 모듈 발견 시
It performs the following steps when called:
default
export 없음.export * from "mod"
는 default
export 제공 불가.*
import 가 하나 이상.The InitializeEnvironment concrete method of
The ExecuteModule concrete method of
Synthetic Module Record 는 명세가 정의하는 모듈 정보를 나타내며 export 이름은 생성 시 정적으로 정의되고 값은
필드 이름 | 값 타입 | 의미 |
---|---|---|
[[ExportNames]] | 문자열 리스트 | 모듈의 export 이름. 중복 없음. |
[[EvaluationSteps]] | 모듈 평가 시 수행할 초기화 로직 ( |
The abstract operation CreateDefaultExportSyntheticModule takes argument defaultExport (
The abstract operation ParseJSONModule takes argument source (String) and returns
The abstract operation SetSyntheticModuleExport takes arguments module (
The LoadRequestedModules concrete method of
The GetExportedNames concrete method of
The ResolveExport concrete method of
The Link concrete method of
The Evaluate concrete method of
The abstract operation GetImportedModule takes arguments referrer (
The host-defined abstract operation HostLoadImportedModule takes arguments referrer (Script
웹 브라우저
<button type="button" onclick="import('./foo.mjs')">Click me</button>
import()
표현식 실행 시 활성 스크립트나 모듈이 없을 수 있다. 더 일반적으로
HostLoadImportedModule 구현은 다음 요구사항을 따른다:
이 연산이 동일 referrer 와
moduleRequest.[[Attributes]] 에 entry.[[Key]] =
실제 과정은
위 텍스트는 type: "json"
으로 import 하면 (그리고 HostLoadImportedModule 이 정상 완료) type: "json"
없이 import 할 때 JSON 모듈 지원을 금지하지 않는다.
The abstract operation FinishLoadingImportedModule takes arguments referrer (Script
The abstract operation AllImportAttributesSupported takes argument attributes (
The host-defined abstract operation HostGetSupportedImportAttributes takes no arguments and returns 문자열 리스트.
HostGetSupportedImportAttributes의 구현은 다음 요구사항을 따라야 한다:
HostGetSupportedImportAttributes의 기본 구현은 새 빈 리스트를 반환하는 것이다.
The abstract operation GetModuleNamespace takes argument module (Module
GetModuleNamespace는 예외를 던지지 않는다. 대신 이 시점에서 해결할 수 없는 이름은 네임스페이스에서 제외된다. 그러한 이름들은 어딘가에서 명시적으로 요청되지 않은 모호한 star export 전부가 아닌 한 이후 실제 링크 오류로 이어진다.
The syntax-directed operation UNKNOWN takes UNPARSEABLE ARGUMENTS. It is defined piecewise over the following productions:
The syntax-directed operation UNKNOWN takes UNPARSEABLE ARGUMENTS. It is defined piecewise over the following productions:
The syntax-directed operation UNKNOWN takes UNPARSEABLE ARGUMENTS. It is defined piecewise over the following productions:
위 규칙은
The syntax-directed operation UNKNOWN takes UNPARSEABLE ARGUMENTS.
ExportedBindings 는
It is defined piecewise over the following productions:
The syntax-directed operation UNKNOWN takes UNPARSEABLE ARGUMENTS.
ExportedNames 는
It is defined piecewise over the following productions:
The syntax-directed operation UNKNOWN takes UNPARSEABLE ARGUMENTS. It is defined piecewise over the following productions:
The syntax-directed operation UNKNOWN takes UNPARSEABLE ARGUMENTS. It is defined piecewise over the following productions:
The syntax-directed operation UNKNOWN takes UNPARSEABLE ARGUMENTS. It is defined piecewise over the following productions: