16 ECMAScript 언어: Scripts and Modules

16.1 Scripts

Syntax

Script : ScriptBodyopt ScriptBody : StatementList[~Yield, ~Await, ~Return]

16.1.1 Static Semantics: Early Errors

Script : ScriptBody ScriptBody : StatementList

16.1.2 Static Semantics: ScriptIsStrict

The syntax-directed operation ScriptIsStrict takes no arguments and returns a Boolean. It is defined piecewise over the following productions:

Script : ScriptBodyopt
  1. ScriptBody가 present하고 ScriptBodyDirective PrologueUse Strict Directive를 contain하면, true를 반환한다.
  2. false를 반환한다.

16.1.3 Runtime Semantics: Evaluation

Script : [empty]
  1. undefined를 반환한다.

16.1.4 Script Records

Script Record는 evaluating되고 있는 script에 대한 information을 encapsulate합니다. 각 script record는 Table 35에 listed된 field를 contain합니다.

Table 35: Script Record Fields
Field Name Value Type Meaning
[[Realm]] a Realm Record 이 script가 created된 realm입니다.
[[ECMAScriptCode]] a Script Parse Node 이 script의 source text를 parsing한 result입니다.
[[LoadedModules]] a List of LoadedModuleRequest Records 이 script에 의해 imported된 specifier string에서 resolved Module Record로의 map입니다. list는 ModuleRequestsEqual(r1, r2)이 true인 두 different Record r1r2를 contain하지 않습니다.
[[HostDefined]] anything (default value is empty) script와 additional information을 associate해야 하는 host environment가 use하기 위해 reserved된 field입니다.

16.1.5 ParseScript ( sourceText, realm, hostDefined )

The abstract operation ParseScript takes arguments sourceText (a String or a sequence of Unicode code points), realm (a Realm Record), and hostDefined (anything) and returns a Script Record or a non-empty List of SyntaxError objects. sourceTextScript로 parsing한 result를 기반으로 Script Record를 create합니다. It performs the following steps when called:

  1. scriptParseText(sourceText, Script)로 둔다.
  2. script가 error의 List이면, script를 반환한다.
  3. Script Record { [[Realm]]: realm, [[ECMAScriptCode]]: script, [[LoadedModules]]: « », [[HostDefined]]: hostDefined }를 반환한다.
Note

implementation은 해당 script source text에 대해 ParseScript를 evaluation하기 전에 script source text를 parse하고 Early Error condition에 대해 analyse할 수 있습니다. 그러나 any error의 reporting은 이 specification이 실제로 해당 source text에 대해 ParseScript를 수행하는 point까지 deferred되어야 합니다.

16.1.6 ScriptEvaluation ( scriptRecord )

The abstract operation ScriptEvaluation takes argument scriptRecord (a Script Record) and returns either a normal completion containing an ECMAScript language value or an abrupt completion. It performs the following steps when called:

  1. globalEnvscriptRecord.[[Realm]].[[GlobalEnv]]로 둔다.
  2. scriptContext를 새 ECMAScript code execution context로 둔다.
  3. scriptContext의 Function을 null로 설정한다.
  4. scriptContextRealmscriptRecord.[[Realm]]로 설정한다.
  5. scriptContext의 ScriptOrModule을 scriptRecord로 설정한다.
  6. scriptContext의 VariableEnvironment를 globalEnv로 설정한다.
  7. scriptContext의 LexicalEnvironment를 globalEnv로 설정한다.
  8. scriptContext의 PrivateEnvironment를 null로 설정한다.
  9. running execution context를 suspend한다.
  10. scriptContextexecution context stack에 push한다; scriptContext는 이제 running execution context이다.
  11. scriptNodescriptRecord.[[ECMAScriptCode]]로 둔다.
  12. resultCompletion(GlobalDeclarationInstantiation(scriptNode, globalEnv))로 둔다.
  13. resultnormal completion이면, 다음을 수행한다.
    1. resultCompletion(scriptNodeEvaluation)으로 설정한다.
    2. resultnormal completion이고 result.[[Value]]empty이면, 다음을 수행한다.
      1. resultNormalCompletion(undefined)로 설정한다.
  14. scriptContext를 suspend하고 execution context stack에서 remove한다.
  15. Assert: execution context stack은 empty가 아니다.
  16. execution context stack의 top에 now 있는 context를 running execution context로 resume한다.
  17. result를 반환한다.

16.1.7 GlobalDeclarationInstantiation ( script, envRecord )

The abstract operation GlobalDeclarationInstantiation takes arguments script (a Script Parse Node) and envRecord (a Global Environment Record) and returns either a normal completion containing unused or a throw completion. scriptexecution context가 established되고 있는 Script입니다. envRecord는 binding이 created될 global environment입니다.

Note 1

script를 evaluating하기 위해 execution context가 established될 때, declaration은 current global environment 안에서 instantiated됩니다. code 안에 declared된 각 global binding이 instantiated됩니다.

called될 때 다음 step을 수행합니다:

  1. lexicalNamesscriptLexicallyDeclaredNames라고 하자.
  2. variableNamesscriptVarDeclaredNames라고 하자.
  3. lexicalNames의 각 요소 name에 대해 다음을 수행한다.
    1. HasLexicalDeclaration(envRecord, name)이 true이면, SyntaxError 예외를 던진다.
    2. hasRestrictedGlobal을 ? HasRestrictedGlobalProperty(envRecord, name)라고 하자.
    3. NOTE: 전역 varfunction 바인딩은 non-strict direct eval에 의해 도입된 것을 제외하고는 non-configurable이므로 restricted global properties이다.
    4. hasRestrictedGlobaltrue이면, SyntaxError 예외를 던진다.
  4. variableNames의 각 요소 name에 대해 다음을 수행한다.
    1. HasLexicalDeclaration(envRecord, name)이 true이면, SyntaxError 예외를 던진다.
  5. variableDeclsscriptVarScopedDeclarations라고 하자.
  6. funcsToInitialize를 새로운 빈 List라고 하자.
  7. declaredFuncNames를 새로운 빈 List라고 하자.
  8. variableDecls의 각 요소 variableDecl에 대해, List의 역순으로 다음을 수행한다.
    1. variableDeclVariableDeclaration, ForBinding 또는 BindingIdentifier 중 어느 것도 아니면,
      1. Assert: variableDeclFunctionDeclaration, GeneratorDeclaration, AsyncFunctionDeclaration 또는 AsyncGeneratorDeclaration 중 하나이다.
      2. NOTE: 같은 이름에 대해 여러 함수 선언이 있으면, 마지막 선언이 사용된다.
      3. funcNamevariableDeclBoundNames의 유일한 요소라고 하자.
      4. declaredFuncNamesfuncName을 포함하지 않으면,
        1. funcDefinable을 ? CanDeclareGlobalFunction(envRecord, funcName)이라고 하자.
        2. funcDefinablefalse이면, TypeError 예외를 던진다.
        3. funcNamedeclaredFuncNames에 추가한다.
        4. variableDeclfuncsToInitialize의 첫 번째 요소로 삽입한다.
  9. declaredVariableNames를 새로운 빈 List라고 하자.
  10. variableDecls의 각 요소 variableDecl에 대해 다음을 수행한다.
    1. variableDeclVariableDeclaration, ForBinding 또는 BindingIdentifier 중 하나이면,
      1. variableDeclBoundNames의 각 String name에 대해 다음을 수행한다.
        1. declaredFuncNamesname을 포함하지 않으면,
          1. variableDefinable을 ? CanDeclareGlobalVar(envRecord, name)라고 하자.
          2. variableDefinablefalse이면, TypeError 예외를 던진다.
          3. declaredVariableNamesname을 포함하지 않으면,
            1. namedeclaredVariableNames에 추가한다.
  11. NOTE: 전역 객체가 ordinary object이면 이 알고리즘 단계 이후에는 abnormal termination이 발생하지 않는다. 하지만 전역 객체가 Proxy exotic object이면 다음 단계 중 일부에서 abnormal termination을 유발하는 동작을 보일 수 있다.
  12. host가 웹 브라우저이거나 그 밖에 Block-Level Function Declarations Web Legacy Compatibility Semantics를 지원하면,
    1. strictscriptScriptIsStrict라고 하자.
    2. strictfalse이면,
      1. declaredFuncOrVariableNamesdeclaredFuncNamesdeclaredVariableNameslist-concatenation이라고 하자.
      2. script Contains xtrueBlock, CaseClause 또는 DefaultClause xStatementList에 직접 포함된 각 FunctionDeclaration funcDecl에 대해 다음을 수행한다.
        1. funcNamefuncDeclBindingIdentifierStringValue라고 하자.
        2. FunctionDeclaration funcDeclfuncNameBindingIdentifier로 갖는 VariableStatement로 대체해도 script에 대한 Early Errors가 생성되지 않으면,
          1. HasLexicalDeclaration(envRecord, funcName)이 false이면,
            1. funcDefinable을 ? CanDeclareGlobalVar(envRecord, funcName)라고 하자.
            2. funcDefinabletrue이면,
              1. NOTE: funcName에 대한 var 바인딩은 그것이 VarDeclaredName도 아니고 다른 FunctionDeclaration의 이름도 아닐 때에만 여기서 인스턴스화된다.
              2. declaredFuncOrVariableNamesfuncName을 포함하지 않으면,
                1. CreateGlobalVarBinding(envRecord, funcName, false)를 수행한다.
                2. funcNamedeclaredFuncOrVariableNames에 추가한다.
              3. FunctionDeclaration funcDecl이 평가될 때, 15.2.6에 제공된 FunctionDeclaration Evaluation 알고리즘 대신 다음 단계를 수행한다.
                1. globalEnv를 실행 중인 실행 컨텍스트의 VariableEnvironment라고 하자.
                2. blockEnv를 실행 중인 실행 컨텍스트의 LexicalEnvironment라고 하자.
                3. funcObj를 ! blockEnv.GetBindingValue(funcName, false)라고 하자.
                4. globalEnv.SetMutableBinding(funcName, funcObj, false)를 수행한다.
                5. unused를 반환한다.
  13. lexicalDeclsscriptLexicallyScopedDeclarations라고 하자.
  14. privateEnvnull이라고 하자.
  15. lexicalDecls의 각 요소 lexicalDecl에 대해 다음을 수행한다.
    1. NOTE: Lexically declared name은 여기서 인스턴스화만 되고 초기화되지는 않는다.
    2. lexicalDeclBoundNames의 각 요소 name에 대해 다음을 수행한다.
      1. lexicalDeclIsConstantDeclarationtrue이면,
        1. envRecord.CreateImmutableBinding(name, true)를 수행한다.
      2. 그렇지 않으면,
        1. envRecord.CreateMutableBinding(name, false)를 수행한다.
  16. funcsToInitialize의 각 Parse Node funcDecl에 대해 다음을 수행한다.
    1. funcNamefuncDeclBoundNames의 유일한 요소라고 하자.
    2. funcObjfuncDeclInstantiateFunctionObject에 인수 envRecordprivateEnv를 전달한 결과라고 하자.
    3. CreateGlobalFunctionBinding(envRecord, funcName, funcObj, false)를 수행한다.
  17. declaredVariableNames의 각 String variableName에 대해 다음을 수행한다.
    1. CreateGlobalVarBinding(envRecord, variableName, false)를 수행한다.
  18. unused를 반환한다.
Note 2

16.1.1에 specified된 early error는 single Script 안에 contained된 declaration에 대해 function/var declaration과 let/const/class declaration 사이의 name conflict 및 let/const/class binding의 redeclaration을 prevent합니다. 그러나 둘 이상의 Script에 걸친 such conflict와 redeclaration은 GlobalDeclarationInstantiation 동안 runtime error로 detected됩니다. 그러한 error가 detected되면, script에 대해 어떤 binding도 instantiated되지 않습니다. 그러나 global objectProxy exotic object를 사용하여 defined된 경우 conflicting declaration에 대한 runtime test가 unreliable할 수 있으며, 그 결과 abrupt completion과 some global declaration이 instantiated되지 않을 수 있습니다. 이것이 occur하면 Script의 code는 evaluated되지 않습니다.

explicit var 또는 function declaration과 달리, global object에 directly created된 property는 let/const/class declaration에 의해 shadowed될 수 있는 global binding을 result합니다.

16.2 Modules

Syntax

Module : ModuleBodyopt ModuleBody : ModuleItemList ModuleItemList : ModuleItem ModuleItemList ModuleItem ModuleItem : ImportDeclaration ExportDeclaration StatementListItem[~Yield, +Await, ~Return] ModuleExportName : IdentifierName StringLiteral

16.2.1 Module Semantics

16.2.1.1 Static Semantics: Early Errors

ModuleBody : ModuleItemList Note

duplicate ExportedNames rule은 ModuleBody 안의 multiple export default ExportDeclaration item이 Syntax Error임을 imply합니다. conflicting 또는 duplicate declaration과 관련된 additional error condition은 Module의 evaluation 전에 module linking 중에 checked됩니다. 그러한 error가 detected되면 Module은 evaluated되지 않습니다.

ModuleExportName : StringLiteral

16.2.1.2 Static Semantics: ImportedLocalNames ( importEntries )

The abstract operation ImportedLocalNames takes argument importEntries (a List of ImportEntry Records) and returns a List of Strings. importEntries에 의해 defined된 모든 local name binding의 List를 create합니다. It performs the following steps when called:

  1. localNames를 새로운 빈 List라고 하자.
  2. importEntries의 각 ImportEntry Record importEntry에 대해 다음을 수행한다.
    1. importEntry.[[LocalName]]localNames에 추가한다.
  3. localNames를 반환한다.

16.2.1.3 ModuleRequest Records

ModuleRequest Record는 given import attribute와 함께 module을 import하려는 request를 represent합니다. 이는 다음 field로 구성됩니다:

Table 36: ModuleRequest Record Fields
Field Name Value Type Meaning
[[Specifier]] a String module specifier입니다.
[[Attributes]] a List of ImportAttribute Records import attribute입니다.

LoadedModuleRequest Record는 resulting Module Record와 함께 module을 import하려는 request를 represent합니다. 이는 Table 36 table에 defined된 같은 field와 [[Module]]의 addition으로 구성됩니다:

Table 37: LoadedModuleRequest Record Fields
Field Name Value Type Meaning
[[Specifier]] a String module specifier입니다.
[[Attributes]] a List of ImportAttribute Records import attribute입니다.
[[Module]] a Module Record 이 module request에 corresponding하는 loaded module입니다.

ImportAttribute Record는 다음 field로 구성됩니다:

Table 38: ImportAttribute Record Fields
Field Name Value Type Meaning
[[Key]] a String attribute key입니다.
[[Value]] a String attribute value입니다.

16.2.1.3.1 ModuleRequestsEqual ( x, y )

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

  1. x.[[Specifier]]y.[[Specifier]]가 아니면, false를 반환한다.
  2. xAttrsx.[[Attributes]]로 둔다.
  3. yAttrsy.[[Attributes]]로 둔다.
  4. xAttrsCountxAttrs 안의 element 수로 둔다.
  5. yAttrsCountyAttrs 안의 element 수로 둔다.
  6. xAttrsCountyAttrsCount이면, false를 반환한다.
  7. xAttrs의 각 ImportAttribute Record xAttr에 대해, 다음을 수행한다.
    1. yAttrsxAttr.[[Key]]yAttr.[[Key]]이고 xAttr.[[Value]]yAttr.[[Value]]ImportAttribute Record yAttr를 contain하지 않으면, false를 반환한다.
  8. true를 반환한다.

16.2.1.4 Static Semantics: ModuleRequests

The syntax-directed operation ModuleRequests takes no arguments and returns a List of ModuleRequest Records. It is defined piecewise over the following productions:

Module : [empty]
  1. 새 empty List를 반환한다.
ModuleItemList : ModuleItem
  1. ModuleItemModuleRequests를 반환한다.
ModuleItemList : ModuleItemList ModuleItem
  1. requestsModuleItemListModuleRequests라고 하자.
  2. additionalRequestsModuleItemModuleRequests라고 하자.
  3. additionalRequests의 각 ModuleRequest Record moduleRequest에 대해 다음을 수행한다.
    1. requestsModuleRequestsEqual(moduleRequest, otherModuleRequest)이 trueModuleRequest Record otherModuleRequest를 포함하지 않으면,
      1. moduleRequestrequests에 추가한다.
  4. requests를 반환한다.
ModuleItem : StatementListItem
  1. 새 empty List를 반환한다.
ImportDeclaration : import ImportClause FromClause ;
  1. specifierFromClauseSV로 둔다.
  2. sole element가 ModuleRequest Record { [[Specifier]]: specifier, [[Attributes]]: « » }인 List를 반환한다.
ImportDeclaration : import ImportClause FromClause WithClause ;
  1. specifierFromClauseSV로 둔다.
  2. attrsWithClauseWithClauseToAttributes로 둔다.
  3. sole element가 ModuleRequest Record { [[Specifier]]: specifier, [[Attributes]]: attrs }인 List를 반환한다.
ImportDeclaration : import ModuleSpecifier ;
  1. specifierModuleSpecifierSV로 둔다.
  2. sole element가 ModuleRequest Record { [[Specifier]]: specifier, [[Attributes]]: « » }인 List를 반환한다.
ImportDeclaration : import ModuleSpecifier WithClause ;
  1. specifierModuleSpecifierSV로 둔다.
  2. attrsWithClauseWithClauseToAttributes로 둔다.
  3. sole element가 ModuleRequest Record { [[Specifier]]: specifier, [[Attributes]]: attrs }인 List를 반환한다.
ExportDeclaration : export ExportFromClause FromClause ;
  1. specifierFromClauseSV로 둔다.
  2. sole element가 ModuleRequest Record { [[Specifier]]: specifier, [[Attributes]]: « » }인 List를 반환한다.
ExportDeclaration : export ExportFromClause FromClause WithClause ;
  1. specifierFromClauseSV로 둔다.
  2. attrsWithClauseWithClauseToAttributes로 둔다.
  3. sole element가 ModuleRequest Record { [[Specifier]]: specifier, [[Attributes]]: attrs }인 List를 반환한다.
ExportDeclaration : export NamedExports ; export VariableStatement export Declaration export default HoistableDeclaration export default ClassDeclaration export default AssignmentExpression ;
  1. 새 empty List를 반환한다.

16.2.1.5 Abstract Module Records

Module Record는 single module의 import와 export에 대한 structural information을 encapsulate합니다. 이 information은 connected module의 set의 import와 export를 link하는 데 사용됩니다. Module Record는 module을 evaluating할 때만 사용되는 네 개의 field를 include합니다.

specification 목적상 Module Record value는 Record specification type의 value이며, Module Record가 abstract 및 concrete subclass를 모두 가진 abstract class인 simple object-oriented hierarchy 안에 existing한다고 생각할 수 있습니다. 이 specification은 Cyclic Module Record라는 abstract subclass와 그 concrete subclass인 Source Text Module Record를 define합니다. 다른 specification 및 implementation은 자신이 defined한 alternative module definition facility에 corresponding하는 additional Module Record subclass를 define할 수 있습니다.

Module Record는 Table 39에 listed된 field를 define합니다. 모든 Module Definition subclass는 적어도 those field를 include합니다. Module Record는 또한 Table 40의 abstract method list를 define합니다. 모든 Module definition subclass는 these abstract method의 concrete implementation을 provide해야 합니다.

Table 39: Module Record Fields
Field Name Value Type Meaning
[[Realm]] a Realm Record 이 module이 created된 Realm입니다.
[[Environment]] a Module Environment Record or empty 이 module의 top level binding을 contain하는 Environment Record입니다. 이 field는 module이 linked될 때 set됩니다.
[[Namespace]] an Object or empty 이 module에 대해 created된 경우의 Module Namespace Object(28.3)입니다.
[[HostDefined]] anything (default value is undefined) module과 additional information을 associate해야 하는 host environment가 use하기 위해 reserved된 field입니다.
Table 40: Abstract Methods of Module Records
Method Purpose Definitions
LoadRequestedModules ( [ hostDefined ] )

The abstract method LoadRequestedModules takes optional argument hostDefined (anything) and returns a Promise.

모든 dependency를 recursively loading하여 linking을 위해 module을 prepare합니다.

이 specification 안에서는 다음 type에 definition이 있습니다; host는 own definition을 가진 additional type을 provide할 수 있습니다:
GetExportedNames ( [ exportStarSet ] )

The abstract method GetExportedNames takes optional argument exportStarSet (a List of Source Text Module Records) and returns a List of Strings.

이 module에서 directly 또는 indirectly exported되는 모든 name의 list를 반환합니다.

이 method를 invoking하기 전에 LoadRequestedModules는 successfully completed되어야 합니다.

이 specification 안에서는 다음 type에 definition이 있습니다; host는 own definition을 가진 additional type을 provide할 수 있습니다:
ResolveExport ( exportName [ , resolveSet ] )

The abstract method ResolveExport takes argument exportName (a String) and optional argument resolveSet (a List of Records with fields [[Module]] (a Module Record) and [[ExportName]] (a String)) and returns a ResolvedBinding Record, null, or ambiguous.

이 module이 exported한 name의 binding을 반환합니다. Binding은 { [[Module]]: Module Record, [[BindingName]]: String | namespace } form의 ResolvedBinding Record로 represented됩니다. export가 any module 안의 direct binding 없이 Module Namespace Object인 경우, [[BindingName]]namespace로 set됩니다. name이 resolved될 수 없으면 null을 반환하고, multiple binding이 found되면 ambiguous를 반환합니다.

이 operation이 specific exportName, resolveSet pair를 argument로 하여 called될 때마다 same result를 반환해야 합니다.

이 method를 invoking하기 전에 LoadRequestedModules는 successfully completed되어야 합니다.

이 specification 안에서는 다음 type에 definition이 있습니다; host는 own definition을 가진 additional type을 provide할 수 있습니다:
Evaluate ( )

The abstract method Evaluate takes no arguments and returns a Promise.

이 module 및 그 dependency의 evaluation을 위한 promise를 반환하며, successful evaluation 또는 이미 successfully evaluated된 경우 resolve하고, evaluation error 또는 이미 unsuccessfully evaluated된 경우 reject합니다. promise가 rejected되면, host는 promise rejection을 handle하고 evaluation error를 rethrow할 것으로 expected됩니다. 이 module이 Cyclic Module Record가 아닌 한, returned promise는 already settled되어야 합니다.

이 method를 invoking하기 전에 Link는 successfully completed되어야 합니다.

이 specification 안에서는 다음 type에 definition이 있습니다; host는 own definition을 가진 additional type을 provide할 수 있습니다:

16.2.1.5.1 EvaluateModuleSync ( module )

The abstract operation EvaluateModuleSync takes argument module (a Module Record) and returns either a normal completion containing unused or a throw completion. caller가 module의 evaluation이 already settled promise를 return할 것임을 guarantee하는 경우, module을 synchronously evaluate합니다. It performs the following steps when called:

  1. Assert: moduleCyclic Module Record가 아니다.
  2. promisemodule.Evaluate()로 둔다.
  3. Assert: promise.[[PromiseState]]fulfilled 또는 rejected 중 하나이다.
  4. promise.[[PromiseState]]rejected이면, 다음을 수행한다.
    1. promise.[[PromiseIsHandled]]false이면, HostPromiseRejectionTracker(promise, "handle")를 수행한다.
    2. promise.[[PromiseIsHandled]]true로 설정한다.
    3. promise.[[PromiseResult]]를 Throw한다.
  5. unused를 반환한다.

16.2.1.6 Cyclic Module Records

Cyclic Module RecordCyclic Module Record type의 subclass인 다른 module과 dependency cycle에 participate할 수 있는 module에 대한 information을 represent하는 데 사용됩니다. Cyclic Module Record type의 subclass가 아닌 Module RecordSource Text Module Record와의 dependency cycle에 participate해서는 안 됩니다.

Table 39에 defined된 field에 addition하여 Cyclic Module RecordsTable 41에 listed된 additional field를 가집니다

Table 41: Additional Fields of Cyclic Module Records
Field Name Value Type Meaning
[[Status]] new, unlinked, linking, linked, evaluating, evaluating-async, or evaluated Initially new입니다. module이 lifecycle 전체에서 progress함에 따라 unlinked, linking, linked, evaluating, possibly evaluating-async, evaluated로(in that order) transition합니다. evaluating-async는 이 module이 asynchronous dependency의 completion 시 execute되도록 queued되어 있거나, [[HasTLA]] field가 true이고 executed되었으며 top-level completion을 pending 중인 module임을 indicate합니다.
[[EvaluationError]] a throw completion or empty evaluation 중에 occurred한 exception을 represent하는 throw completion입니다. exception이 occurred하지 않았거나 [[Status]]evaluated가 아니면 empty입니다.
[[DFSAncestorIndex]] an integer or empty LinkEvaluate 중에만 사용되는 auxiliary field입니다. [[Status]]linking 또는 evaluating 중 하나이면, 이것은 module의 depth-first traversal index이거나 same strongly connected component 안의 “earlier” module의 것입니다.
[[RequestedModules]] a List of ModuleRequest Records 이 module 안의 import와 associated된 ModuleRequest RecordList입니다. List는 import의 source text occurrence order입니다.
[[LoadedModules]] a List of LoadedModuleRequest Records 이 record가 represented하는 module이 relative import attribute와 함께 module importation을 request하기 위해 사용한 specifier string에서 resolved Module Record로의 map입니다. list는 ModuleRequestsEqual(r1, r2)이 true인 두 different Record r1r2를 contain하지 않습니다.
[[CycleRoot]] a Cyclic Module Record or empty cycle의 first visited module, strongly connected component의 root DFS ancestor입니다. cycle 안에 있지 않은 module의 경우, 이는 module 자체일 것입니다. Evaluate가 completed되면, module의 [[DFSAncestorIndex]]는 그 [[CycleRoot]]의 depth-first traversal index입니다.
[[HasTLA]] a Boolean 이 module이 individually asynchronous인지 여부입니다(예를 들어 top-level await를 contain하는 Source Text Module Record인 경우). asynchronous dependency를 가진다는 것이 이 field가 true임을 의미하지는 않습니다. 이 field는 module이 parsed된 후 change되어서는 안 됩니다.
[[AsyncEvaluationOrder]] unset, an integer, or done 이 field는 initially unset으로 set되며, fully synchronous module의 경우 unset으로 remain합니다. themselves asynchronous이거나 asynchronous dependency를 가진 module의 경우, 16.2.1.6.1.3.4에 의해 pending module의 execution이 queued되는 order를 determine하는 integer로 set됩니다. pending module이 successfully executed되면, field는 done으로 set됩니다.
[[TopLevelCapability]] a PromiseCapability Record or empty 이 module이 어떤 cycle의 [[CycleRoot]]이고, Evaluate()가 그 cycle 안의 어떤 module에 대해 called된 경우, 이 field는 entire evaluation에 대한 PromiseCapability Record를 contain합니다. 이는 Evaluate() abstract method에서 returned되는 Promise object를 settle하는 데 사용됩니다. 이 field는 그 module의 dependency에 대해서는 empty일 것이며, 단 those dependency 중 일부에 대해 top-level Evaluate()가 initiated된 경우는 제외합니다.
[[AsyncParentModules]] a List of Cyclic Module Records 이 module 또는 dependency가 [[HasTLA]] true를 가지고 execution이 in progress이면, top-level execution job에 대해 이 module의 parent importer를 track합니다. 이러한 parent module은 이 module이 successfully completed execution하기 전에 executing을 start하지 않습니다.
[[PendingAsyncDependencies]] an integer or empty 이 module이 asynchronous dependency를 가진 경우, 이 module을 위해 execute될 remaining asynchronous dependency module의 수를 track합니다. asynchronous dependency를 가진 module은 이 field가 0에 reach하고 execution error가 없을 때 executed됩니다.

Table 40에 defined된 method에 addition하여 Cyclic Module RecordsTable 42에 listed된 additional method를 가집니다:

Table 42: Additional Abstract Methods of Cyclic Module Records
Method Purpose Definitions
InitializeEnvironment ( )

The abstract method InitializeEnvironment takes no arguments and returns either a normal completion containing unused or a throw completion.

all imported binding을 resolving하는 것을 include하여 module의 Environment Record를 initialize하고, module의 execution context를 create합니다.
이 specification 안에서는 다음 type에 definition이 있습니다; host는 own definition을 가진 additional type을 provide할 수 있습니다:
ExecuteModule ( [ capability ] )

The abstract method ExecuteModule takes optional argument capability (a PromiseCapability Record) and returns either a normal completion containing unused or a throw completion.

module의 execution context 안에서 module의 code를 evaluate합니다. 이 module이 [[HasTLA]] 안에 true를 가지면, PromiseCapability Record가 argument로 passed되고, method는 given capability를 resolve하거나 reject할 것으로 expected됩니다. 이 경우 method는 exception을 throw해서는 안 되고, 필요하면 PromiseCapability Record를 reject해야 합니다.
이 specification 안에서는 다음 type에 definition이 있습니다; host는 own definition을 가진 additional type을 provide할 수 있습니다:

GraphLoadingState Record는 module graph의 loading process에 대한 information을 contain하는 Record입니다. HostLoadImportedModule call 이후 loading을 continue하는 데 사용됩니다. 각 GraphLoadingState RecordTable 43에 defined된 field를 가집니다:

Table 43: GraphLoadingState Record Fields
Field Name Value Type Meaning
[[PromiseCapability]] a PromiseCapability Record loading process가 finish될 때 resolve할 promise입니다.
[[IsLoading]] a Boolean loading process가 아직 successfully도 error로도 finish되지 않은 경우 true입니다.
[[PendingModulesCount]] a non-negative integer pending HostLoadImportedModule call의 수를 track합니다.
[[Visited]] a List of Cyclic Module Records circular dependency로 인한 infinite loop를 avoid하기 위해, current loading process에 의해 already loaded된 Cyclic Module Record의 list입니다.
[[HostDefined]] anything (default value is empty) LoadRequestedModules caller에서 HostLoadImportedModule로 pass할 host-defined data를 contain합니다.

16.2.1.6.1 Implementation of Module Record Abstract Methods

다음은 Table 40에 defined된 corresponding Module Record abstract method를 implement하는 Cyclic Module Record의 concrete method입니다.

16.2.1.6.1.1 LoadRequestedModules ( [ hostDefined ] )

The LoadRequestedModules concrete method of a Cyclic Module Record module takes optional argument hostDefined (anything) and returns a Promise. module의 dependency graph 안의 모든 Module Record[[LoadedModules]]를 populate합니다(work의 대부분은 auxiliary function InnerModuleLoading에 의해 done됩니다). HostLoadImportedModule hook에 passed되는 optional hostDefined parameter를 받습니다. It performs the following steps when called:

  1. hostDefined가 present하지 않으면, hostDefinedempty로 설정한다.
  2. promiseCapability를 ! NewPromiseCapability(%Promise%)로 둔다.
  3. stateGraphLoadingState Record { [[IsLoading]]: true, [[PendingModulesCount]]: 1, [[Visited]]: « », [[PromiseCapability]]: promiseCapability, [[HostDefined]]: hostDefined }로 둔다.
  4. InnerModuleLoading(state, module)을 수행한다.
  5. promiseCapability.[[Promise]]를 반환한다.
Note
hostDefined parameter는 imported module을 fetch하는 데 necessary한 additional information을 pass하는 데 사용될 수 있습니다. 예를 들어 HTML에서는 <link rel="preload" as="..."> tag에 대한 correct fetch destination을 set하는 데 사용됩니다. import() expression은 hostDefined parameter를 never set하지 않습니다.

16.2.1.6.1.1.1 InnerModuleLoading ( state, module )

The abstract operation InnerModuleLoading takes arguments state (a GraphLoadingState Record) and module (a Module Record) and returns unused. LoadRequestedModulesmodule의 dependency graph에 대한 actual loading process를 recursively 수행하는 데 사용됩니다. It performs the following steps when called:

  1. Assert: state.[[IsLoading]]true이다.
  2. moduleCyclic Module Record이고, module.[[Status]]new이며, state.[[Visited]]module을 contain하지 않으면, 다음을 수행한다.
    1. modulestate.[[Visited]]에 append한다.
    2. requestedModulesCountmodule.[[RequestedModules]] 안의 element 수로 둔다.
    3. state.[[PendingModulesCount]]state.[[PendingModulesCount]] + requestedModulesCount로 설정한다.
    4. module.[[RequestedModules]]의 각 ModuleRequest Record request에 대해, 다음을 수행한다.
      1. AllImportAttributesSupported(request.[[Attributes]])가 false이면, 다음을 수행한다.
        1. errorThrowCompletion(newly created SyntaxError object)로 둔다.
        2. ContinueModuleLoading(state, error)를 수행한다.
      2. 그렇지 않고 module.[[LoadedModules]]ModuleRequestsEqual(record, request)이 trueLoadedModuleRequest Record record를 contain하면, 다음을 수행한다.
        1. InnerModuleLoading(state, record.[[Module]])을 수행한다.
      3. 그렇지 않으면,
        1. HostLoadImportedModule(module, request, state.[[HostDefined]], state)를 수행한다.
        2. NOTE: HostLoadImportedModuleFinishLoadingImportedModule을 call하며, 이는 ContinueModuleLoading을 통해 graph loading process에 re-enter한다.
      4. state.[[IsLoading]]false이면, unused를 반환한다.
  3. Assert: state.[[PendingModulesCount]] ≥ 1이다.
  4. state.[[PendingModulesCount]]state.[[PendingModulesCount]] - 1로 설정한다.
  5. state.[[PendingModulesCount]] = 0이면, 다음을 수행한다.
    1. state.[[IsLoading]]false로 설정한다.
    2. state.[[Visited]]의 각 Cyclic Module Record loaded에 대해, 다음을 수행한다.
      1. loaded.[[Status]]new이면, loaded.[[Status]]unlinked로 설정한다.
    3. Call(state.[[PromiseCapability]].[[Resolve]], undefined, « undefined »)를 수행한다.
  6. unused를 반환한다.

16.2.1.6.1.1.2 ContinueModuleLoading ( state, moduleCompletion )

The abstract operation ContinueModuleLoading takes arguments state (a GraphLoadingState Record) and moduleCompletion (either a normal completion containing a Module Record or a throw completion) and returns unused. HostLoadImportedModule call 이후 loading process에 re-enter하는 데 사용됩니다. It performs the following steps when called:

  1. state.[[IsLoading]]false이면, unused를 반환한다.
  2. moduleCompletionnormal completion이면, 다음을 수행한다.
    1. InnerModuleLoading(state, moduleCompletion.[[Value]])을 수행한다.
  3. 그렇지 않으면,
    1. state.[[IsLoading]]false로 설정한다.
    2. Call(state.[[PromiseCapability]].[[Reject]], undefined, « moduleCompletion.[[Value]] »)를 수행한다.
  4. unused를 반환한다.

16.2.1.6.1.2 Link ( )

The Link concrete method of a Cyclic Module Record module takes no arguments and returns either a normal completion containing unused or a throw completion. success 시, Link는 이 module의 [[Status]]unlinked에서 linked로 transition합니다. failure 시, exception이 thrown되고 이 module의 [[Status]]unlinked로 remain합니다. (work의 대부분은 auxiliary function InnerModuleLinking에 의해 done됩니다.) It performs the following steps when called:

  1. Assert: module.[[Status]]unlinked, linked, evaluating-async 또는 evaluated 중 하나이다.
  2. stack을 새로운 빈 List라고 하자.
  3. resultCompletion(InnerModuleLinking(module, stack, 0))이라고 하자.
  4. resultabrupt completion이면,
    1. stack의 각 Cyclic Module Record requiredModule에 대해 다음을 수행한다.
      1. Assert: requiredModule.[[Status]]linking이다.
      2. requiredModule.[[Status]]unlinked로 설정한다.
    2. Assert: module.[[Status]]unlinked이다.
    3. result를 반환한다.
  5. Assert: module.[[Status]]linked, evaluating-async 또는 evaluated 중 하나이다.
  6. Assert: stack은 비어 있다.
  7. unused를 반환한다.

16.2.1.6.1.2.1 InnerModuleLinking ( module, stack, index )

The abstract operation InnerModuleLinking takes arguments module (a Module Record), stack (a List of Cyclic Module Records), and index (a non-negative integer) and returns either a normal completion containing a non-negative integer or a throw completion. Linkmodule에 대한 actual linking process를 수행하고, dependency graph 안의 모든 다른 module에 대해 recursively 수행하는 데 사용됩니다. stackindex parameter와 module의 [[DFSAncestorIndex]] field는 depth-first search (DFS) traversal을 keep track합니다. 특히 [[DFSAncestorIndex]]는 strongly connected component (SCC)를 discover하는 데 사용되어, SCC 안의 모든 module이 together linked로 transition하도록 합니다. It performs the following steps when called:

  1. moduleCyclic Module Record가 아니면, 다음을 수행한다.
    1. module.Link()를 수행한다.
    2. index를 반환한다.
  2. module.[[Status]]linking, linked, evaluating-async, 또는 evaluated 중 하나이면, 다음을 수행한다.
    1. index를 반환한다.
  3. Assert: module.[[Status]]unlinked이다.
  4. module.[[Status]]linking으로 설정한다.
  5. moduleIndexindex로 둔다.
  6. module.[[DFSAncestorIndex]]index로 설정한다.
  7. indexindex + 1로 설정한다.
  8. modulestack에 append한다.
  9. module.[[RequestedModules]]의 각 ModuleRequest Record request에 대해, 다음을 수행한다.
    1. requiredModuleGetImportedModule(module, request)로 둔다.
    2. index를 ? InnerModuleLinking(requiredModule, stack, index)로 설정한다.
    3. requiredModuleCyclic Module Record이면, 다음을 수행한다.
      1. Assert: requiredModule.[[Status]]linking, linked, evaluating-async, 또는 evaluated 중 하나이다.
      2. Assert: requiredModule.[[Status]]linking인 것은 stackrequiredModule을 contain하는 경우에만, 그리고 그 경우에만 true이다.
      3. requiredModule.[[Status]]linking이면, 다음을 수행한다.
        1. module.[[DFSAncestorIndex]]min(module.[[DFSAncestorIndex]], requiredModule.[[DFSAncestorIndex]])로 설정한다.
  10. module.InitializeEnvironment()를 수행한다.
  11. Assert: modulestack 안에 exactly once occur한다.
  12. Assert: module.[[DFSAncestorIndex]]moduleIndex이다.
  13. module.[[DFSAncestorIndex]] = moduleIndex이면, 다음을 수행한다.
    1. donefalse로 둔다.
    2. Repeat, donefalse인 동안,
      1. requiredModulestack의 last element로 둔다.
      2. stack의 last element를 remove한다.
      3. Assert: requiredModuleCyclic Module Record이다.
      4. requiredModule.[[Status]]linked로 설정한다.
      5. requiredModulemodule이 same Module Record이면, donetrue로 설정한다.
  14. index를 반환한다.

16.2.1.6.1.3 Evaluate ( )

The Evaluate concrete method of a Cyclic Module Record module takes no arguments and returns a Promise. Evaluate는 이 module의 [[Status]]linked에서 evaluating-async 또는 evaluated로 transition합니다. given strongly connected component 안의 module에서 first time called되면, Evaluate는 module이 evaluating을 finished할 때 resolve되는 Promise를 create하고 반환합니다. 이 Promise는 component의 [[CycleRoot]][[TopLevelCapability]] field에 stored됩니다. component 안의 any module에 대한 future invocation of Evaluate는 same Promise를 반환합니다. (work의 대부분은 auxiliary function InnerModuleEvaluation에 의해 done됩니다.) It performs the following steps when called:

  1. Assert: 이 Evaluate 호출은 주변 agent 내의 다른 Evaluate 호출과 동시에 발생하고 있지 않다.
  2. Assert: module.[[Status]]linked, evaluating-async 또는 evaluated 중 하나이다.
  3. module.[[Status]]evaluating-async 또는 evaluated 중 하나이면,
    1. module.[[CycleRoot]]empty가 아니면,
      1. modulemodule.[[CycleRoot]]로 설정한다.
    2. 그렇지 않으면,
      1. Assert: module.[[Status]]evaluated이고 module.[[EvaluationError]]throw completion이다.
  4. module.[[TopLevelCapability]]empty가 아니면,
    1. module.[[TopLevelCapability]].[[Promise]]를 반환한다.
  5. stack을 새로운 빈 List라고 하자.
  6. promiseCapability를 ! NewPromiseCapability(%Promise%)라고 하자.
  7. module.[[TopLevelCapability]]promiseCapability로 설정한다.
  8. resultCompletion(InnerModuleEvaluation(module, stack, 0))이라고 하자.
  9. resultabrupt completion이면,
    1. stack의 각 Cyclic Module Record requiredModule에 대해 다음을 수행한다.
      1. Assert: requiredModule.[[Status]]evaluating이다.
      2. requiredModule.[[Status]]evaluated로 설정한다.
      3. requiredModule.[[EvaluationError]]result로 설정한다.
    2. Assert: module.[[Status]]evaluated이다.
    3. Assert: module.[[EvaluationError]]result는 같은 Completion Record이다.
    4. Call(promiseCapability.[[Reject]], undefined, « result.[[Value]] »)를 수행한다.
  10. 그렇지 않으면,
    1. Assert: module.[[Status]]evaluating-async 또는 evaluated 중 하나이다.
    2. Assert: module.[[EvaluationError]]empty이다.
    3. module.[[Status]]evaluated이면,
      1. Assert: module.[[AsyncEvaluationOrder]]unset 또는 done 중 하나이다.
      2. NOTE: module.[[AsyncEvaluationOrder]]module이 이미 평가되었고 그 평가가 비동기였던 경우에만 done이다.
      3. Call(promiseCapability.[[Resolve]], undefined, « undefined »)를 수행한다.
    4. Assert: stack은 비어 있다.
  11. promiseCapability.[[Promise]]를 반환한다.

16.2.1.6.1.3.1 InnerModuleEvaluation ( module, stack, index )

The abstract operation InnerModuleEvaluation takes arguments module (a Module Record), stack (a List of Cyclic Module Records), and index (a non-negative integer) and returns either a normal completion containing a non-negative integer or a throw completion. Evaluatemodule에 대한 actual evaluation process를 수행하고, dependency graph 안의 모든 다른 module에 대해 recursively 수행하는 데 사용됩니다. stackindex parameter와 module[[DFSAncestorIndex]] field는 InnerModuleLinking에서와 same way로 사용됩니다. It performs the following steps when called:

  1. moduleCyclic Module Record가 아니면, 다음을 수행한다.
    1. EvaluateModuleSync(module)을 수행한다.
    2. index를 반환한다.
  2. module.[[Status]]evaluating-async 또는 evaluated 중 하나이면, 다음을 수행한다.
    1. module.[[EvaluationError]]empty이면, index를 반환한다.
    2. module.[[EvaluationError]]를 반환한다.
  3. module.[[Status]]evaluating이면, index를 반환한다.
  4. Assert: module.[[Status]]linked이다.
  5. module.[[Status]]evaluating으로 설정한다.
  6. moduleIndexindex로 둔다.
  7. module.[[DFSAncestorIndex]]index로 설정한다.
  8. module.[[PendingAsyncDependencies]]를 0으로 설정한다.
  9. indexindex + 1로 설정한다.
  10. modulestack에 append한다.
  11. module.[[RequestedModules]]의 각 ModuleRequest Record request에 대해, 다음을 수행한다.
    1. requiredModuleGetImportedModule(module, request)로 둔다.
    2. index를 ? InnerModuleEvaluation(requiredModule, stack, index)로 설정한다.
    3. requiredModuleCyclic Module Record이면, 다음을 수행한다.
      1. Assert: requiredModule.[[Status]]evaluating, evaluating-async, 또는 evaluated 중 하나이다.
      2. Assert: requiredModule.[[Status]]evaluating인 것은 stackrequiredModule을 contain하는 경우에만, 그리고 그 경우에만 true이다.
      3. requiredModule.[[Status]]evaluating이면, 다음을 수행한다.
        1. module.[[DFSAncestorIndex]]min(module.[[DFSAncestorIndex]], requiredModule.[[DFSAncestorIndex]])로 설정한다.
      4. 그렇지 않으면,
        1. requiredModulerequiredModule.[[CycleRoot]]로 설정한다.
        2. Assert: requiredModule.[[Status]]evaluating-async 또는 evaluated 중 하나이다.
        3. requiredModule.[[EvaluationError]]empty가 아니면, ? requiredModule.[[EvaluationError]]를 반환한다.
      5. requiredModule.[[AsyncEvaluationOrder]]integer이면, 다음을 수행한다.
        1. module.[[PendingAsyncDependencies]]module.[[PendingAsyncDependencies]] + 1로 설정한다.
        2. modulerequiredModule.[[AsyncParentModules]]에 append한다.
  12. module.[[PendingAsyncDependencies]] > 0 또는 module.[[HasTLA]]true이면, 다음을 수행한다.
    1. Assert: module.[[AsyncEvaluationOrder]]unset이다.
    2. module.[[AsyncEvaluationOrder]]IncrementModuleAsyncEvaluationCount()로 설정한다.
    3. module.[[PendingAsyncDependencies]] = 0이면, ExecuteAsyncModule(module)을 수행한다.
  13. 그렇지 않으면,
    1. module.ExecuteModule()를 수행한다.
  14. Assert: modulestack 안에 exactly once occur한다.
  15. Assert: module.[[DFSAncestorIndex]]moduleIndex이다.
  16. module.[[DFSAncestorIndex]] = moduleIndex이면, 다음을 수행한다.
    1. donefalse로 둔다.
    2. Repeat, donefalse인 동안,
      1. requiredModulestack의 last element로 둔다.
      2. stack의 last element를 remove한다.
      3. Assert: requiredModuleCyclic Module Record이다.
      4. Assert: requiredModule.[[AsyncEvaluationOrder]]integer 또는 unset 중 하나이다.
      5. requiredModule.[[AsyncEvaluationOrder]]unset이면, requiredModule.[[Status]]evaluated로 설정한다.
      6. 그렇지 않으면, requiredModule.[[Status]]evaluating-async로 설정한다.
      7. requiredModulemodule이 same Module Record이면, donetrue로 설정한다.
      8. requiredModule.[[CycleRoot]]module로 설정한다.
  17. index를 반환한다.
Note 1

module은 InnerModuleEvaluation에 의해 traversed되는 동안 evaluating입니다. module은 execution completion 시 evaluated가 되거나, [[HasTLA]] field가 true이거나 asynchronous dependency를 가진 경우 execution 중 evaluating-async가 됩니다.

Note 2

asynchronous cycle의 module에 depending하는 any module은 that cycle이 evaluating이 아닐 때, 대신 [[CycleRoot]]를 통해 cycle root의 execution에 depend합니다. 이는 cycle state가 root module state를 통해 single strongly connected component로 treated될 수 있음을 ensure합니다.

16.2.1.6.1.3.2 ExecuteAsyncModule ( module )

The abstract operation ExecuteAsyncModule takes argument module (a Cyclic Module Record) and returns unused. It performs the following steps when called:

  1. Assert: module.[[Status]]evaluating 또는 evaluating-async 중 하나이다.
  2. Assert: module.[[HasTLA]]true이다.
  3. promiseCapability를 ! NewPromiseCapability(%Promise%)로 둔다.
  4. module을 capture하고 called될 때 다음 step을 수행하는 parameter가 없는 새 Abstract Closure fulfilledClosure를 둔다:
    1. AsyncModuleExecutionFulfilled(module)을 수행한다.
    2. NormalCompletion(undefined)를 반환한다.
  5. onFulfilledCreateBuiltinFunction(fulfilledClosure, 0, "", « »)로 둔다.
  6. module을 capture하고 called될 때 다음 step을 수행하는 parameter (error)를 가진 새 Abstract Closure rejectedClosure를 둔다:
    1. AsyncModuleExecutionRejected(module, error)를 수행한다.
    2. NormalCompletion(undefined)를 반환한다.
  7. onRejectedCreateBuiltinFunction(rejectedClosure, 0, "", « »)로 둔다.
  8. PerformPromiseThen(promiseCapability.[[Promise]], onFulfilled, onRejected)를 수행한다.
  9. module.ExecuteModule(promiseCapability)를 수행한다.
  10. unused를 반환한다.

16.2.1.6.1.3.3 GatherAvailableAncestors ( module, execList )

The abstract operation GatherAvailableAncestors takes arguments module (a Cyclic Module Record) and execList (a List of Cyclic Module Records) and returns unused. It performs the following steps when called:

  1. module.[[AsyncParentModules]]의 각 Cyclic Module Record ancestorModule에 대해, 다음을 수행한다.
    1. execListancestorModule을 contain하지 않고 ancestorModule.[[CycleRoot]].[[EvaluationError]]empty이면, 다음을 수행한다.
      1. Assert: ancestorModule.[[Status]]evaluating-async이다.
      2. Assert: ancestorModule.[[EvaluationError]]empty이다.
      3. Assert: ancestorModule.[[AsyncEvaluationOrder]]integer이다.
      4. Assert: ancestorModule.[[PendingAsyncDependencies]] > 0이다.
      5. ancestorModule.[[PendingAsyncDependencies]]ancestorModule.[[PendingAsyncDependencies]] - 1로 설정한다.
      6. ancestorModule.[[PendingAsyncDependencies]] = 0이면, 다음을 수행한다.
        1. ancestorModuleexecList에 append한다.
        2. ancestorModule.[[HasTLA]]false이면, GatherAvailableAncestors(ancestorModule, execList)를 수행한다.
  2. unused를 반환한다.
Note

root module에 대한 asynchronous execution이 fulfilled될 때, 이 function은 이 completion에서 synchronously execute together할 수 있는 module의 list를 determine하여 execList에 populate합니다.

16.2.1.6.1.3.4 AsyncModuleExecutionFulfilled ( module )

The abstract operation AsyncModuleExecutionFulfilled takes argument module (a Cyclic Module Record) and returns unused. It performs the following steps when called:

  1. module.[[Status]]evaluated이면, 다음을 수행한다.
    1. Assert: module.[[EvaluationError]]empty가 아니다.
    2. unused를 반환한다.
  2. Assert: module.[[Status]]evaluating-async이다.
  3. Assert: module.[[AsyncEvaluationOrder]]integer이다.
  4. Assert: module.[[EvaluationError]]empty이다.
  5. module.[[AsyncEvaluationOrder]]done으로 설정한다.
  6. module.[[Status]]evaluated로 설정한다.
  7. module.[[TopLevelCapability]]empty가 아니면, 다음을 수행한다.
    1. Assert: module.[[CycleRoot]]module은 same Module Record이다.
    2. Call(module.[[TopLevelCapability]].[[Resolve]], undefined, « undefined »)를 수행한다.
  8. execList를 새 empty List로 둔다.
  9. GatherAvailableAncestors(module, execList)를 수행한다.
  10. Assert: execList의 모든 element는 [[AsyncEvaluationOrder]] field가 integer로 set되고, [[PendingAsyncDependencies]] field가 0으로 set되며, [[EvaluationError]] field가 empty로 set되어 있다.
  11. sortedExecListexecList의 element를 element로 가지고 그 [[AsyncEvaluationOrder]] field의 ascending order로 sorted된 List로 둔다.
  12. sortedExecList의 각 Cyclic Module Record ancestorModule에 대해, 다음을 수행한다.
    1. ancestorModule.[[Status]]evaluated이면, 다음을 수행한다.
      1. Assert: ancestorModule.[[EvaluationError]]empty가 아니다.
    2. 그렇지 않고 ancestorModule.[[HasTLA]]true이면, 다음을 수행한다.
      1. ExecuteAsyncModule(ancestorModule)을 수행한다.
    3. 그렇지 않으면,
      1. resultCompletion(ancestorModule.ExecuteModule())으로 둔다.
      2. resultabrupt completion이면, 다음을 수행한다.
        1. AsyncModuleExecutionRejected(ancestorModule, result.[[Value]])를 수행한다.
      3. 그렇지 않으면,
        1. ancestorModule.[[AsyncEvaluationOrder]]done으로 설정한다.
        2. ancestorModule.[[Status]]evaluated로 설정한다.
        3. ancestorModule.[[TopLevelCapability]]empty가 아니면, 다음을 수행한다.
          1. Assert: ancestorModule.[[CycleRoot]]ancestorModule은 same Module Record이다.
          2. Call(ancestorModule.[[TopLevelCapability]].[[Resolve]], undefined, « undefined »)를 수행한다.
  13. unused를 반환한다.

16.2.1.6.1.3.5 AsyncModuleExecutionRejected ( module, error )

The abstract operation AsyncModuleExecutionRejected takes arguments module (a Cyclic Module Record) and error (an ECMAScript language value) and returns unused. It performs the following steps when called:

  1. module.[[Status]]evaluated이면, 다음을 수행한다.
    1. Assert: module.[[EvaluationError]]empty가 아니다.
    2. unused를 반환한다.
  2. Assert: module.[[Status]]evaluating-async이다.
  3. Assert: module.[[AsyncEvaluationOrder]]integer이다.
  4. Assert: module.[[EvaluationError]]empty이다.
  5. module.[[EvaluationError]]ThrowCompletion(error)로 설정한다.
  6. module.[[Status]]evaluated로 설정한다.
  7. module.[[AsyncEvaluationOrder]]done으로 설정한다.
  8. NOTE: module.[[AsyncEvaluationOrder]]AsyncModuleExecutionFulfilled와의 symmetry를 위해 done으로 set된다. InnerModuleEvaluation에서 module의 [[AsyncEvaluationOrder]] internal slot의 value는 그 [[EvaluationError]] internal slot이 empty가 아닐 때 unused이다.
  9. module.[[TopLevelCapability]]empty가 아니면, 다음을 수행한다.
    1. Assert: module.[[CycleRoot]]module은 same Module Record이다.
    2. Call(module.[[TopLevelCapability]].[[Reject]], undefined, « error »)를 수행한다.
  10. module.[[AsyncParentModules]]의 각 Cyclic Module Record ancestorModule에 대해, 다음을 수행한다.
    1. AsyncModuleExecutionRejected(ancestorModule, error)를 수행한다.
  11. unused를 반환한다.

16.2.1.6.2 Example Cyclic Module Record Graphs

이 non-normative section은 몇 가지 common module graph의 linking 및 evaluation 예제를, error가 어떻게 occur할 수 있는지에 specific focus를 두고 제공합니다.

먼저 다음 simple module graph를 consider하십시오:

Figure 2: A simple module graph
module A가 module B에 depend하고, module B가 module C에 depend하는 module graph

먼저 error condition이 없다고 assume합시다. host가 first A.LoadRequestedModules()를 call하면, 이는 assumption에 따라 successfully complete하고, BC의 dependency도 respectively recursively load하며(각각 C와 none), 그런 다음 A.[[Status]] = B.[[Status]] = C.[[Status]] = unlinked로 set합니다. 그 다음 hostA.Link()를 call하면, 이는 (again by assumption) successfully complete하여 A.[[Status]] = B.[[Status]] = C.[[Status]] = linked가 됩니다. 이러한 preparatory step은 any time에 performed될 수 있습니다. Later, host가 module의 any possible side effect를 incur할 준비가 되면 A.Evaluate()를 call할 수 있으며, 이는 successfully complete하고 undefined로 resolving되는 Promise를 반환하며(again by assumption), recursively first C then B를 evaluated하게 됩니다. 이 point에서 각 module의 [[Status]]evaluated가 됩니다.

그 다음 A.LoadRequestedModules()의 successful call 이후 linking error가 involving된 case를 consider하십시오. CInnerModuleLinking이 succeeds하지만, thereafter B에 대해 fails하면, 예를 들어 C가 provide하지 않는 something을 import하기 때문이면, original A.Link()는 fail하고 AB[[Status]]unlinked로 remain합니다. 그러나 C[[Status]]linked가 되었습니다.

Finally, Link()의 successful call 이후 evaluation error가 involving된 case를 consider하십시오. CInnerModuleEvaluation이 succeeds하지만, thereafter B에 대해 fails하면, 예를 들어 B가 exception을 throw하는 code를 contain하기 때문이면, original A.Evaluate()는 fail하고 rejected Promise를 return합니다. resulting exception은 AB[[EvaluationError]] field 둘 다에 recorded되고, 그 [[Status]]evaluated가 됩니다. C 역시 evaluated가 되지만, AB와 달리 evaluation을 successfully completed했으므로 [[EvaluationError]] 없이 remain합니다. exception을 storing하면 host가 their Evaluate() method를 calling하여 A 또는 B를 reuse하려 할 때마다 same exception을 encounter하도록 ensure합니다. (HostCyclic Module Record를 reuse할 필요가 없습니다; similarly, host는 이러한 method에 의해 thrown된 exception object를 expose할 필요도 없습니다. 그러나 specification은 such use를 enable합니다.)

이제 다른 type의 error condition을 consider하십시오:

Figure 3: A module graph with an unresolvable module
module A가 missing(unresolvable) module에 depend하고, 그것이 ???로 represented된 module graph

이 scenario에서 module A는 어떤 다른 module에 대한 dependency를 declare하지만, 그 module에 대한 Module Record가 존재하지 않습니다. 즉, HostLoadImportedModule은 그것을 요청받았을 때 exception과 함께 FinishLoadingImportedModule을 call합니다. 이는 corresponding resource가 존재하지 않거나, resource는 존재하지만 resulting source text를 parse하려고 할 때 ParseModule이 some errors를 return하는 등 다양한 reason으로 occur할 수 있습니다. HostFinishLoadingImportedModule에 pass하는 completion을 통해 failure의 cause를 expose하도록 choose할 수 있습니다. 어떤 경우든, 이 exception은 loading failure를 cause하고, 그 결과 A[[Status]]new로 remain합니다.

여기서 loading, linking 및 evaluation error 사이의 difference는 다음 characteristic 때문입니다:

  • Evaluation은 side effect를 cause할 수 있으므로 only once performed되어야 합니다; 따라서 evaluation이 already performed되었는지, even unsuccessfully라도 remember하는 것이 important합니다. (error case에서는 subsequent Evaluate() call이 new one을 synthesize해야 하지 않도록 exception도 remember하는 것이 makes sense합니다.)
  • 반면 Linking은 side-effect-free이므로, fail하더라도 later time에 issue 없이 retried될 수 있습니다.
  • Loading은 host와 closely interact하며, 일부 host는 failed load를 retry하도록 users에게 allow하는 것이 desirable할 수 있습니다(예를 들어 failure가 temporarily bad network condition에 의해 caused된 경우).

이제 cycle을 가진 module graph를 consider하십시오:

Figure 4: A cyclic module graph
module A가 module B와 C에 depend하지만, module B도 module A에 depend하는 module graph

여기서는 entry point가 module A라고 assume하므로, hostA.LoadRequestedModules()를 calling하여 proceed하고, 이는 A에 대해 InnerModuleLoading을 수행합니다. 이것은 다시 BC에 대해 InnerModuleLoading을 call합니다. cycle 때문에, 이는 다시 A에 대해 InnerModuleLoading을 trigger하지만, 이 point에서는 A의 dependency loading이 이 LoadRequestedModules process 중에 already triggered되었으므로 no-op입니다. graph 안의 모든 module이 successfully loaded되면, their [[Status]]는 same time에 new에서 unlinked로 transition합니다.

Then hostA.Link()를 calling하여 proceed하고, 이는 A에 대해 InnerModuleLinking을 수행합니다. 이것은 다시 B에 대해 InnerModuleLinking을 call합니다. cycle 때문에, 이는 다시 A에 대해 InnerModuleLinking을 trigger하지만, 이 point에서는 A.[[Status]]가 already linking이므로 no-op입니다. control이 A로 돌아오고 InnerModuleLinkingC에 대해 triggered될 때 B.[[Status]] 자체는 linking으로 remain합니다. 이것이 return하여 C.[[Status]]linked가 된 후, AB는 together linking에서 linked로 transition합니다; 이것은 by design이며, they form a strongly connected component이기 때문입니다. 이 phase 중에는 module graph가 depth-first search로 traversed되므로 same SCC 안의 module status를 same time에 transition하는 것이 possible합니다.

cyclic module graph의 evaluation phase에 대해서도 success case에서는 analogous story가 occur합니다.

이제 A에 linking error가 있는 case를 consider하십시오; 예를 들어, it tries to import a binding from C that does not exist. 이 경우, above step은 still occur하며, InnerModuleLinking on A의 second call로부터 early return도 include합니다. 그러나 original InnerModuleLinking on A로 unwind back하면, InitializeEnvironment 중에, namely C.ResolveExport() right after에 fail합니다. thrown SyntaxError exception은 A.Link로 propagate되고, 이는 currently its stack에 있는 모든 module을 reset합니다(these are always exactly the modules that are still linking). 따라서 AB 둘 다 unlinked가 됩니다. Clinked로 left됨에 note하십시오.

Alternatively, A에 evaluation error가 있는 case를 consider하십시오; 예를 들어, 그 source code가 exception을 throw합니다. 이 경우, evaluation-time analogue of the above step은 still occur하며, InnerModuleEvaluation on A의 second call로부터 early return도 include합니다. 그러나 original InnerModuleEvaluation on A로 unwind back하면, assumption에 따라 fail합니다. thrown exception은 A.Evaluate()로 propagate되고, 이는 currently its stack에 있는 모든 module(즉, still evaluating인 module)에 error를 record할 뿐 아니라, top-level await를 contain하거나 depend하는 module을 위해 whole dependency graph를 통해 chain을 form하는 [[AsyncParentModules]]를 통해서도 record합니다. 이는 AsyncModuleExecutionRejected algorithm을 통해 이루어집니다. 따라서 AB 둘 다 evaluated가 되고 exception은 AB[[EvaluationError]] field 둘 다에 recorded되며, C[[EvaluationError]] 없이 evaluated로 left됩니다.

마지막으로, 모든 module이 asynchronously complete하는 cycle을 가진 module graph를 consider하십시오:

Figure 5: An asynchronous cyclic module graph
module A가 module B와 C에 depend하고, module B가 module D에 depend하며, module C가 module D와 E에 depend하고, module D가 module A에 depend하는 module graph

Loading 및 linking은 before와 같이 happen하며, 모든 module은 [[Status]]linked로 set되어 end up합니다.

A.Evaluate()를 calling하면 A, B, 및 D에 대해 InnerModuleEvaluation을 call하며, 이들은 모두 evaluating으로 transition합니다. Then InnerModuleEvaluationA에 대해 다시 called되며, it is already evaluating이므로 no-op입니다. 이 point에서 D.[[PendingAsyncDependencies]]는 0이므로 ExecuteAsyncModule(D)가 called되고, D의 asynchronous execution을 tracking하는 new PromiseCapability와 함께 D.ExecuteModule을 call합니다. B에 대한 InnerModuleEvaluation으로 unwind back하여 B.[[PendingAsyncDependencies]]를 1로 set하고 B.[[AsyncEvaluationOrder]]를 1로 set합니다. original InnerModuleEvaluation on A로 unwind back하여 A.[[PendingAsyncDependencies]]를 1로 set합니다. A의 dependency에 대한 loop의 next iteration에서, C 그리고 thus D(again no-op)와 E에 대해 InnerModuleEvaluation을 call합니다. E는 dependency가 없고 cycle의 part가 아니므로, D와 same manner로 ExecuteAsyncModule(E)을 call하고 E는 immediately stack에서 removed됩니다. 다시 한 번 C에 대한 InnerModuleEvaluation으로 unwind하여 C.[[AsyncEvaluationOrder]]를 3으로 set합니다. 이제 A의 dependency에 대한 loop를 finish하고, A.[[AsyncEvaluationOrder]]를 4로 set하며, entire strongly connected component를 stack에서 remove하여 모든 module을 at once evaluating-async로 transition합니다. 이 point에서 module의 field는 Table 44에 given된 것과 같습니다.

Table 44: Module fields after the initial Evaluate() call
Field
Module
A B C D E
[[DFSAncestorIndex]] 0 0 0 0 4
[[Status]] evaluating-async evaluating-async evaluating-async evaluating-async evaluating-async
[[AsyncEvaluationOrder]] 4 1 3 0 2
[[AsyncParentModules]] « » « A » « A » « B, C » « C »
[[PendingAsyncDependencies]] 2 (B and C) 1 (D) 2 (D and E) 0 0

E가 first로 executing을 finish한다고 assume합시다. 그것이 happen하면, AsyncModuleExecutionFulfilled가 called되고, E.[[Status]]evaluated로 set되며 C.[[PendingAsyncDependencies]]는 decremented되어 1이 됩니다. updated module의 field는 Table 45에 given된 것과 같습니다.

Table 45: Module fields after module E finishes executing
Field
Module
C E
[[DFSAncestorIndex]] 0 4
[[Status]] evaluating-async evaluated
[[AsyncEvaluationOrder]] 3 done
[[AsyncParentModules]] « A » « C »
[[PendingAsyncDependencies]] 1 (D) 0

D가 next로 finish합니다(아직 executing 중인 only module이었으므로). 그것이 happen하면, AsyncModuleExecutionFulfilled가 again called되고 D.[[Status]]evaluated로 set됩니다. execution에 available한 its ancestor는 B([[AsyncEvaluationOrder]]가 1)와 C([[AsyncEvaluationOrder]]가 3)이므로, B가 first handled됩니다: B.[[PendingAsyncDependencies]]는 decremented되어 0이 되고, ExecuteAsyncModuleB에 대해 called되며, it starts executing. C.[[PendingAsyncDependencies]]도 decremented되어 0이 되고, C가 executing을 start합니다(Bawait를 contain하면 potentially in parallel to B). updated module의 field는 Table 46에 given된 것과 같습니다.

Table 46: Module fields after module D finishes executing
Field
Module
B C D
[[DFSAncestorIndex]] 0 0 0
[[Status]] evaluating-async evaluating-async evaluated
[[AsyncEvaluationOrder]] 1 3 done
[[AsyncParentModules]] « A » « A » « B, C »
[[PendingAsyncDependencies]] 0 0 0

C가 next로 executing을 finish한다고 assume합시다. 그것이 happen하면, AsyncModuleExecutionFulfilled가 again called되고, C.[[Status]]evaluated로 set되며 A.[[PendingAsyncDependencies]]는 decremented되어 1이 됩니다. updated module의 field는 Table 47에 given된 것과 같습니다.

Table 47: Module fields after module C finishes executing
Field
Module
A C
[[DFSAncestorIndex]] 0 0
[[Status]] evaluating-async evaluated
[[AsyncEvaluationOrder]] 4 done
[[AsyncParentModules]] « » « A »
[[PendingAsyncDependencies]] 1 (B) 0

Then, B가 executing을 finish합니다. 그것이 happen하면, AsyncModuleExecutionFulfilled가 again called되고 B.[[Status]]evaluated로 set됩니다. A.[[PendingAsyncDependencies]]는 decremented되어 0이 되므로, ExecuteAsyncModule이 called되고 it starts executing. updated module의 field는 Table 48에 given된 것과 같습니다.

Table 48: Module fields after module B finishes executing
Field
Module
A B
[[DFSAncestorIndex]] 0 0
[[Status]] evaluating-async evaluated
[[AsyncEvaluationOrder]] 4 done
[[AsyncParentModules]] « » « A »
[[PendingAsyncDependencies]] 0 0

Finally, A가 executing을 finish합니다. 그것이 happen하면, AsyncModuleExecutionFulfilled가 again called되고 A.[[Status]]evaluated로 set됩니다. 이 point에서 A.[[TopLevelCapability]] 안의 Promise(A.Evaluate()에서 returned된 것)가 resolved되고, 이것으로 이 module graph의 handling이 conclude됩니다. updated module의 field는 Table 49에 given된 것과 같습니다.

Table 49: Module fields after module A finishes executing
Field
Module
A
[[DFSAncestorIndex]] 0
[[Status]] evaluated
[[AsyncEvaluationOrder]] done
[[AsyncParentModules]] « »
[[PendingAsyncDependencies]] 0

Alternatively, CB가 executing을 finished하기 전에 execution에 fail하고 error를 return하는 failure case를 consider하십시오. 그것이 happen하면, AsyncModuleExecutionRejected가 called되고, 이는 C.[[Status]]evaluated로 set하고 C.[[EvaluationError]]를 error로 set합니다. 그런 다음 각 AsyncParentModules에 대해 AsyncModuleExecutionRejected를 수행하여 이 error를 all AsyncParentModules에 propagate합니다. updated module의 field는 Table 50에 given된 것과 같습니다.

Table 50: Module fields after module C finishes with an error
Field
Module
A C
[[DFSAncestorIndex]] 0 0
[[Status]] evaluated evaluated
[[AsyncEvaluationOrder]] done done
[[AsyncParentModules]] « » « A »
[[PendingAsyncDependencies]] 1 (B) 0
[[EvaluationError]] empty C의 evaluation error

CC의 error와 함께 A에 대해 AsyncModuleExecutionRejected를 call하므로, AC와 same error로 rejected될 것입니다. A.[[Status]]evaluated로 set됩니다. 이 point에서 A.[[TopLevelCapability]] 안의 Promise(A.Evaluate()에서 returned된 것)가 rejected됩니다. updated module의 field는 Table 51에 given된 것과 같습니다.

Table 51: Module fields after module A is rejected
Field
Module
A
[[DFSAncestorIndex]] 0
[[Status]] evaluated
[[AsyncEvaluationOrder]] done
[[AsyncParentModules]] « »
[[PendingAsyncDependencies]] 0
[[EvaluationError]] CEvaluation Error

Then, B가 error 없이 executing을 finish합니다. 그것이 happen하면, AsyncModuleExecutionFulfilled가 again called되고 B.[[Status]]evaluated로 set됩니다. GatherAvailableAncestorsB에 대해 called됩니다. 그러나 A.[[CycleRoot]]는 evaluation error를 가진 A이므로, returned sortedExecList에 added되지 않고 AsyncModuleExecutionFulfilled는 further processing 없이 return합니다. B의 any future importer는 cycle root A에 set된 C의 evaluation error에서 B.[[CycleRoot]].[[EvaluationError]]의 rejection을 resolve할 것입니다. updated module의 field는 Table 52에 given된 것과 같습니다.

Table 52: Module fields after module B finishes executing in an erroring graph
Field
Module
A B
[[DFSAncestorIndex]] 0 0
[[Status]] evaluated evaluated
[[AsyncEvaluationOrder]] 4 1
[[AsyncParentModules]] « » « A »
[[PendingAsyncDependencies]] 0 0
[[EvaluationError]] CEvaluation Error empty

16.2.1.7 Source Text Module Records

Source Text Module Recordgoal symbol Module을 사용하여 parsed된 ECMAScript source text(11)에서 defined된 module에 대한 information을 represent하는 데 사용됩니다. 그 field는 module에 의해 imported 및 exported되는 name에 대한 digested information을 contain하며, 그 concrete method는 these digest를 사용하여 module을 link하고 evaluate합니다.

Source Text Module Record는 abstract Module Record type의 다른 subclass와 함께 module graph 안에 exist할 수 있고, Cyclic Module Record type의 다른 subclass와 함께 cycle에 participate할 수 있습니다.

Table 41에 defined된 field에 addition하여, Source Text Module RecordsTable 53에 listed된 additional field를 가집니다. 이러한 각 field는 initially ParseModule에서 set됩니다.

Table 53: Additional Fields of Source Text Module Records
Field Name Value Type Meaning
[[ECMAScriptCode]] a Parse Node Modulegoal symbol로 사용하여 이 module의 source text를 parsing한 result입니다.
[[Context]] an ECMAScript code execution context or empty 이 module과 associated된 execution context입니다. module의 environment가 initialized될 때까지 empty입니다.
[[ImportMeta]] an Object or empty import.meta meta property를 통해 exposed되는 object입니다. ECMAScript code에 의해 accessed될 때까지 empty입니다.
[[ImportEntries]] a List of ImportEntry Records 이 module의 code에서 derived된 ImportEntry record의 List입니다.
[[LocalExportEntries]] a List of ExportEntry Records module 안에서 occur하는 declaration에 corresponding하는, 이 module의 code에서 derived된 ExportEntry record의 List입니다.
[[IndirectExportEntries]] a List of ExportEntry Records module 안에서 occur하는 reexported import 또는 export * as namespace declaration에서의 export에 corresponding하는, 이 module의 code에서 derived된 ExportEntry record의 List입니다.
[[StarExportEntries]] a List of ExportEntry Records module 안에서 occur하는 export * declaration에 corresponding하는, 이 module의 code에서 derived된 ExportEntry record의 List이며, export * as namespace declaration은 include하지 않습니다.

ImportEntry Record는 single declarative import에 대한 information을 digest하는 Record입니다. 각 ImportEntry RecordTable 54에 defined된 field를 가집니다:

Table 54: ImportEntry Record Fields
Field Name Value Type Meaning
[[ModuleRequest]] a ModuleRequest Record ImportDeclarationModuleSpecifier와 import attribute를 represent하는 ModuleRequest Record입니다.
[[ImportName]] a String or namespace [[ModuleRequest]]가 identified하는 module에 의해 desired binding이 exported되는 name입니다. value namespace는 import request가 target module의 namespace object에 대한 것임을 indicate합니다.
[[LocalName]] a String importing module 안에서 imported value에 locally access하는 데 사용되는 name입니다.
Note 1

Table 55는 syntactic import form을 represent하는 데 사용되는 ImportEntry record field의 example을 제공합니다:

Table 55 (Informative): Import Forms Mappings to ImportEntry Records
Import Statement Form [[ModuleRequest]] [[ImportName]] [[LocalName]]
import v from "mod"; "mod" "default" "v"
import * as ns from "mod"; "mod" namespace "ns"
import {x} from "mod"; "mod" "x" "x"
import {x as v} from "mod"; "mod" "x" "v"
import "mod"; ImportEntry Record는 created되지 않습니다.

ExportEntry Record는 single declarative export에 대한 information을 digest하는 Record입니다. 각 ExportEntry RecordTable 56에 defined된 field를 가집니다:

Table 56: ExportEntry Record Fields
Field Name Value Type Meaning
[[ExportName]] a String or null 이 module이 이 binding을 export하는 데 사용하는 name입니다.
[[ModuleRequest]] a ModuleRequest Record or null ExportDeclarationModuleSpecifier와 import attribute를 represent하는 ModuleRequest Record입니다. ExportDeclarationModuleSpecifier를 가지지 않으면 null입니다.
[[ImportName]] a String, null, namespace, or all-but-default [[ModuleRequest]]가 identified하는 module에 의해 desired binding이 exported되는 name입니다. ExportDeclarationModuleSpecifier를 가지지 않으면 null입니다. namespaceexport * as ns from "mod" declaration에 사용됩니다. all-but-defaultexport * from "mod" declaration에 사용됩니다.
[[LocalName]] a String or null importing module 안에서 exported value에 locally access하는 데 사용되는 name입니다. exported value가 module 안에서 locally accessible하지 않으면 null입니다.
Note 2

Table 57는 syntactic export form을 represent하는 데 사용되는 ExportEntry record field의 example을 제공합니다:

Table 57 (Informative): Export Forms Mappings to ExportEntry Records
Export Statement Form [[ExportName]] [[ModuleRequest]] [[ImportName]] [[LocalName]]
export var v; "v" null null "v"
export default function f() {} "default" null null "f"
export default function () {} "default" null null "*default*"
export default 42; "default" null null "*default*"
export {x}; "x" null null "x"
export {v as x}; "x" null null "v"
export {x} from "mod"; "x" "mod" "x" null
export {v as x} from "mod"; "x" "mod" "v" null
export * from "mod"; null "mod" all-but-default null
export * as ns from "mod"; "ns" "mod" namespace null

다음 definition은 Source Text Module Records에 필요한 concrete method 및 other abstract operation을 specify합니다

16.2.1.7.1 ParseModule ( sourceText, realm, hostDefined )

The abstract operation ParseModule takes arguments sourceText (a String or a sequence of Unicode code points), realm (a Realm Record), and hostDefined (anything) and returns a Source Text Module Record or a non-empty List of SyntaxError objects. sourceTextModule로 parsing한 result를 기반으로 Source Text Module Record를 create합니다. It performs the following steps when called:

  1. bodyParseText(sourceText, Module)라고 하자.
  2. body가 errors의 List이면, body를 반환한다.
  3. requestedModulesbodyModuleRequests라고 하자.
  4. importEntriesbodyImportEntries라고 하자.
  5. importedBoundNamesImportedLocalNames(importEntries)라고 하자.
  6. indirectExportEntries를 새로운 빈 List라고 하자.
  7. localExportEntries를 새로운 빈 List라고 하자.
  8. starExportEntries를 새로운 빈 List라고 하자.
  9. exportEntriesbodyExportEntries라고 하자.
  10. exportEntries의 각 ExportEntry Record exportEntry에 대해 다음을 수행한다.
    1. exportEntry.[[ModuleRequest]]null이면,
      1. importedBoundNamesexportEntry.[[LocalName]]을 포함하지 않으면,
        1. exportEntrylocalExportEntries에 추가한다.
      2. 그렇지 않으면,
        1. NOTE: 원래 다른 모듈에서 가져온 바인딩 또는 namespace 객체를 내보낼 때, ExportEntry Record는 바인딩 또는 namespace 객체가 가져온 뒤 내보내진 것이 아니라 원래 모듈에서 직접 다시 내보내졌다면 가졌을 형식과 일치하도록 다시 작성된다. 이를 통해 export * from을 통해 같은 이름으로 같은 바인딩 또는 namespace를 두 번 내보내면서 발생하는 충돌이 Source Text Module Records의 ResolveExport 구체 메서드9.e.iii 단계에서 모호한 것으로 처리되지 않고 무시될 수 있다.
        2. importEntry[[LocalName]]exportEntry.[[LocalName]]importEntries의 요소라고 하자.
        3. ExportEntry Record { [[ModuleRequest]]: importEntry.[[ModuleRequest]], [[ImportName]]: importEntry.[[ImportName]], [[LocalName]]: null, [[ExportName]]: exportEntry.[[ExportName]] }를 indirectExportEntries에 추가한다.
    2. 그렇지 않고 exportEntry.[[ImportName]]all-but-default이면,
      1. Assert: exportEntry.[[ExportName]]null이다.
      2. exportEntrystarExportEntries에 추가한다.
    3. 그렇지 않으면,
      1. exportEntryindirectExportEntries에 추가한다.
  11. asyncbody Contains await라고 하자.
  12. Source Text Module Record { [[Realm]]: realm, [[Environment]]: empty, [[Namespace]]: empty, [[CycleRoot]]: empty, [[HasTLA]]: async, [[AsyncEvaluationOrder]]: unset, [[TopLevelCapability]]: empty, [[AsyncParentModules]]: « », [[PendingAsyncDependencies]]: empty, [[Status]]: new, [[EvaluationError]]: empty, [[HostDefined]]: hostDefined, [[ECMAScriptCode]]: body, [[Context]]: empty, [[ImportMeta]]: empty, [[RequestedModules]]: requestedModules, [[LoadedModules]]: « », [[ImportEntries]]: importEntries, [[LocalExportEntries]]: localExportEntries, [[IndirectExportEntries]]: indirectExportEntries, [[StarExportEntries]]: starExportEntries, [[DFSAncestorIndex]]: empty }를 반환한다.
Note

implementation은 해당 module source text에 대한 ParseModule의 evaluation 전에 module source text를 parse하고 Early Error condition에 대해 analyse할 수 있습니다. 그러나 any error의 reporting은 이 specification이 실제로 해당 source text에 대해 ParseModule을 수행하는 point까지 deferred되어야 합니다.

16.2.1.7.2 Implementation of Module Record Abstract Methods

다음은 Table 40에 defined된 corresponding Module Record abstract method를 implement하는 Source Text Module Record의 concrete method입니다.

16.2.1.7.2.1 GetExportedNames ( [ exportStarSet ] )

The GetExportedNames concrete method of a Source Text Module Record module takes optional argument exportStarSet (a List of Source Text Module Records) and returns a List of Strings. It performs the following steps when called:

  1. Assert: module.[[Status]]new가 아니다.
  2. exportStarSet이 없으면, exportStarSet을 새로운 빈 List로 설정한다.
  3. exportStarSetmodule을 포함하면,
    1. Assert: export * 순환성의 시작점에 도달했다.
    2. 새로운 빈 List를 반환한다.
  4. moduleexportStarSet에 추가한다.
  5. exportedNames를 새로운 빈 List라고 하자.
  6. module.[[LocalExportEntries]]의 각 ExportEntry Record exportEntry에 대해 다음을 수행한다.
    1. Assert: module은 이 export에 대한 direct binding을 제공한다.
    2. Assert: exportEntry.[[ExportName]]null이 아니다.
    3. exportEntry.[[ExportName]]exportedNames에 추가한다.
  7. module.[[IndirectExportEntries]]의 각 ExportEntry Record exportEntry에 대해 다음을 수행한다.
    1. Assert: module은 이 export에 대한 특정 binding을 가져온다.
    2. Assert: exportEntry.[[ExportName]]null이 아니다.
    3. exportEntry.[[ExportName]]exportedNames에 추가한다.
  8. module.[[StarExportEntries]]의 각 ExportEntry Record exportEntry에 대해 다음을 수행한다.
    1. Assert: exportEntry.[[ModuleRequest]]null이 아니다.
    2. requestedModuleGetImportedModule(module, exportEntry.[[ModuleRequest]])라고 하자.
    3. starNamesrequestedModule.GetExportedNames(exportStarSet)라고 하자.
    4. starNames의 각 요소 name에 대해 다음을 수행한다.
      1. name"default"가 아니면,
        1. exportedNamesname을 포함하지 않으면,
          1. nameexportedNames에 추가한다.
  9. exportedNames를 반환한다.
Note

GetExportedNames는 ambiguous star export binding을 가진 name에 대해 filter out하거나 exception을 throw하지 않습니다.

16.2.1.7.2.2 ResolveExport ( exportName [ , resolveSet ] )

The ResolveExport concrete method of a Source Text Module Record module takes argument exportName (a String) and optional argument resolveSet (a List of Records with fields [[Module]] (a Module Record) and [[ExportName]] (a String)) and returns a ResolvedBinding Record, null, or ambiguous.

ResolveExport는 imported binding을 actual defining module 및 local binding name으로 resolve하려 시도합니다. defining module은 이 method가 invoked된 Module Record가 represented하는 module일 수도 있고, 그 module에 의해 imported된 다른 module일 수도 있습니다. parameter resolveSet은 unresolved circular import/export path를 detect하는 데 사용됩니다. specific Module RecordexportName으로 구성된 pair가 resolveSet 안에 already 있으면, import circularity가 encountered된 것입니다. ResolveExport를 recursively calling하기 전에, moduleexportName으로 구성된 pair가 resolveSet에 added됩니다.

defining module이 found되면, ResolvedBinding Record { [[Module]], [[BindingName]] }이 returned됩니다. 이 record는 originally requested export의 resolved binding을 identify합니다. 단, this is the export of a namespace with no local binding인 경우 [[BindingName]]namespace로 set됩니다. definition이 found되지 않았거나 request가 circular로 found되면 null이 returned됩니다. request가 ambiguous로 found되면 ambiguous가 returned됩니다.

It performs the following steps when called:

  1. Assert: module.[[Status]]new가 아니다.
  2. resolveSet이 없으면, resolveSet을 새로운 빈 List로 설정한다.
  3. resolveSet의 각 Record { [[Module]], [[ExportName]] } record에 대해 다음을 수행한다.
    1. modulerecord.[[Module]]이 같은 Module Record이고 exportNamerecord.[[ExportName]]이면,
      1. Assert: 이것은 순환 import 요청이다.
      2. null을 반환한다.
  4. Record { [[Module]]: module, [[ExportName]]: exportName }를 resolveSet에 추가한다.
  5. module.[[LocalExportEntries]]의 각 ExportEntry Record exportEntry에 대해 다음을 수행한다.
    1. exportEntry.[[ExportName]]exportName이면,
      1. Assert: module은 이 export에 대한 direct binding을 제공한다.
      2. ResolvedBinding Record { [[Module]]: module, [[BindingName]]: exportEntry.[[LocalName]] }를 반환한다.
  6. module.[[IndirectExportEntries]]의 각 ExportEntry Record exportEntry에 대해 다음을 수행한다.
    1. exportEntry.[[ExportName]]exportName이면,
      1. Assert: exportEntry.[[ModuleRequest]]null이 아니다.
      2. importedModuleGetImportedModule(module, exportEntry.[[ModuleRequest]])라고 하자.
      3. exportEntry.[[ImportName]]namespace이면,
        1. Assert: module은 이 export에 대한 direct binding을 제공하지 않는다.
        2. ResolvedBinding Record { [[Module]]: importedModule, [[BindingName]]: namespace }를 반환한다.
      4. Assert: module은 이 export에 대한 특정 binding을 가져온다.
      5. Assert: exportEntry.[[ImportName]]은 String이다.
      6. importedModule.ResolveExport(exportEntry.[[ImportName]], resolveSet)를 반환한다.
  7. exportName"default"이면,
    1. Assert: default export는 이 모듈에 의해 명시적으로 정의되지 않았다.
    2. null을 반환한다.
    3. NOTE: default export는 export * from "mod" 선언에 의해 제공될 수 없다.
  8. starResolutionnull이라고 하자.
  9. module.[[StarExportEntries]]의 각 ExportEntry Record exportEntry에 대해 다음을 수행한다.
    1. Assert: exportEntry.[[ModuleRequest]]null이 아니다.
    2. importedModuleGetImportedModule(module, exportEntry.[[ModuleRequest]])라고 하자.
    3. resolutionimportedModule.ResolveExport(exportName, resolveSet)라고 하자.
    4. resolutionambiguous이면, ambiguous를 반환한다.
    5. resolutionnull이 아니면,
      1. Assert: resolutionResolvedBinding Record이다.
      2. starResolutionnull이면,
        1. starResolutionresolution으로 설정한다.
      3. 그렇지 않으면,
        1. Assert: 요청된 이름을 포함하는 * export가 둘 이상 있다.
        2. resolution.[[Module]]starResolution.[[Module]]이 같은 Module Record가 아니면, ambiguous를 반환한다.
        3. resolution.[[BindingName]]starResolution.[[BindingName]]이 아니면, ambiguous를 반환한다.
  10. starResolution을 반환한다.

16.2.1.7.3 Implementation of Cyclic Module Record Abstract Methods

다음은 Table 42에 defined된 corresponding Cyclic Module Record abstract method를 implement하는 Source Text Module Record의 concrete method입니다.

16.2.1.7.3.1 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. module.[[IndirectExportEntries]]의 각 ExportEntry Record exportEntry에 대해 다음을 수행한다.
    1. Assert: exportEntry.[[ExportName]]null이 아니다.
    2. resolutionmodule.ResolveExport(exportEntry.[[ExportName]])라고 하자.
    3. resolutionnull 또는 ambiguous 중 하나이면, SyntaxError 예외를 던진다.
    4. Assert: resolutionResolvedBinding Record이다.
  2. Assert: module의 모든 named export는 resolve 가능하다.
  3. realmmodule.[[Realm]]이라고 하자.
  4. Assert: realmundefined가 아니다.
  5. envRecordNewModuleEnvironment(realm.[[GlobalEnv]])라고 하자.
  6. module.[[Environment]]envRecord로 설정한다.
  7. module.[[ImportEntries]]의 각 ImportEntry Record importEntry에 대해 다음을 수행한다.
    1. importedModuleGetImportedModule(module, importEntry.[[ModuleRequest]])라고 하자.
    2. importEntry.[[ImportName]]namespace이면,
      1. namespaceGetModuleNamespace(importedModule)라고 하자.
      2. envRecord.CreateImmutableBinding(importEntry.[[LocalName]], true)를 수행한다.
      3. envRecord.InitializeBinding(importEntry.[[LocalName]], namespace)를 수행한다.
    3. 그렇지 않으면,
      1. Assert: importEntry.[[ImportName]]은 String이다.
      2. resolutionimportedModule.ResolveExport(importEntry.[[ImportName]])라고 하자.
      3. resolutionnull 또는 ambiguous 중 하나이면, SyntaxError 예외를 던진다.
      4. resolution.[[BindingName]]namespace이면,
        1. namespaceGetModuleNamespace(resolution.[[Module]])라고 하자.
        2. envRecord.CreateImmutableBinding(importEntry.[[LocalName]], true)를 수행한다.
        3. envRecord.InitializeBinding(importEntry.[[LocalName]], namespace)를 수행한다.
      5. 그렇지 않으면,
        1. CreateImportBinding(envRecord, importEntry.[[LocalName]], resolution.[[Module]], resolution.[[BindingName]])을 수행한다.
  8. moduleContext를 새로운 ECMAScript code execution context라고 하자.
  9. moduleContext의 Function을 null로 설정한다.
  10. Assert: module.[[Realm]]undefined가 아니다.
  11. moduleContextRealmmodule.[[Realm]]으로 설정한다.
  12. moduleContext의 ScriptOrModule을 module로 설정한다.
  13. moduleContext의 VariableEnvironment를 module.[[Environment]]로 설정한다.
  14. moduleContext의 LexicalEnvironment를 module.[[Environment]]로 설정한다.
  15. moduleContext의 PrivateEnvironment를 null로 설정한다.
  16. module.[[Context]]moduleContext로 설정한다.
  17. moduleContextexecution context stack에 push한다. moduleContext는 이제 실행 중인 실행 컨텍스트이다.
  18. codemodule.[[ECMAScriptCode]]라고 하자.
  19. variableDeclscodeVarScopedDeclarations라고 하자.
  20. declaredVariableNames를 새로운 빈 List라고 하자.
  21. variableDecls의 각 요소 variableDecl에 대해 다음을 수행한다.
    1. variableDeclBoundNames의 각 요소 name에 대해 다음을 수행한다.
      1. declaredVariableNamesname을 포함하지 않으면,
        1. envRecord.CreateMutableBinding(name, false)를 수행한다.
        2. envRecord.InitializeBinding(name, undefined)를 수행한다.
        3. namedeclaredVariableNames에 추가한다.
  22. lexicalDeclscodeLexicallyScopedDeclarations라고 하자.
  23. privateEnvnull이라고 하자.
  24. lexicalDecls의 각 요소 lexicalDecl에 대해 다음을 수행한다.
    1. lexicalDeclBoundNames의 각 요소 name에 대해 다음을 수행한다.
      1. lexicalDeclIsConstantDeclarationtrue이면,
        1. envRecord.CreateImmutableBinding(name, true)를 수행한다.
      2. 그렇지 않으면,
        1. envRecord.CreateMutableBinding(name, false)를 수행한다.
      3. lexicalDeclFunctionDeclaration, GeneratorDeclaration, AsyncFunctionDeclaration 또는 AsyncGeneratorDeclaration 중 하나이면,
        1. funcObjlexicalDeclInstantiateFunctionObject에 인수 envRecordprivateEnv를 전달한 결과라고 하자.
        2. envRecord.InitializeBinding(name, funcObj)를 수행한다.
  25. moduleContextexecution context stack에서 제거한다.
  26. unused를 반환한다.

16.2.1.7.3.2 ExecuteModule ( [ capability ] )

The ExecuteModule concrete method of a Source Text Module Record module takes optional argument capability (a PromiseCapability Record) and returns either a normal completion containing unused or a throw completion. It performs the following steps when called:

  1. 단언: module은 링크되었고 그 module environment의 선언들은 인스턴스화되었다.
  2. moduleContextmodule.[[Context]]로 둔다.
  3. module.[[HasTLA]]false이면,
    1. 단언: capability는 존재하지 않는다.
    2. envmodule.[[Environment]]로 둔다.
    3. 실행 중인 실행 컨텍스트를 일시 중단한다.
    4. moduleContext를 실행 컨텍스트 스택에 push한다. moduleContext는 이제 실행 중인 실행 컨텍스트이다.
    5. resultmodule.[[ECMAScriptCode]]EvaluationCompletion으로 둔다.
    6. resultCompletion(DisposeResources(env.[[DisposableResourceStack]], result))로 설정한다.
    7. moduleContext를 일시 중단하고 실행 컨텍스트 스택에서 제거한다.
    8. 이제 실행 컨텍스트 스택의 맨 위에 있는 컨텍스트를 실행 중인 실행 컨텍스트로 재개한다.
    9. result가 abrupt 완료이면,
      1. result를 반환한다.
  4. 그렇지 않으면,
    1. 단언: capabilityPromiseCapability Record이다.
    2. AsyncBlockStart(capability, module.[[ECMAScriptCode]], moduleContext)를 수행한다.
  5. unused를 반환한다.

16.2.1.8 Synthetic Module Records

Synthetic Module Record는 specification에 의해 defined된 module에 대한 information을 represent하는 데 사용됩니다. 그 exported name은 creation 시 statically defined되며, 그 corresponding value는 SetSyntheticModuleExport를 사용하여 시간이 지나며 change될 수 있습니다. import나 dependency는 없습니다.

Note
Synthetic Module Record는 다양한 module type을 defining하는 데 사용될 수 있습니다: 예를 들어 JSON modules 또는 CSS modules.

Table 39에 defined된 field에 addition하여 Synthetic Module Records는 Table 58에 listed된 additional field를 가집니다.

Table 58: Additional Fields of Synthetic Module Records
Field Name Value Type Meaning
[[ExportNames]] a List of Strings module의 export name입니다. 이 list는 duplicate를 contain하지 않습니다.
[[EvaluationSteps]] an Abstract Closure module의 evaluation 시 수행할 initialization logic이며, Synthetic Module Record를 its sole argument로 받습니다. 이는 [[ExportNames]]를 modify해서는 안 됩니다. abrupt completion을 return할 수 있습니다.

16.2.1.8.1 CreateDefaultExportSyntheticModule ( defaultExport )

The abstract operation CreateDefaultExportSyntheticModule takes argument defaultExport (an ECMAScript language value) and returns a Synthetic Module Record. default export가 defaultExportSynthetic Module Record를 create합니다. It performs the following steps when called:

  1. realm을 current Realm Record로 둔다.
  2. defaultExport를 capture하고 called될 때 다음 step을 수행하는 parameter (module)를 가진 새 Abstract Closure setDefaultExport를 둔다:
    1. SetSyntheticModuleExport(module, "default", defaultExport)를 수행한다.
    2. NormalCompletion(unused)를 반환한다.
  3. Synthetic Module Record { [[Realm]]: realm, [[Environment]]: empty, [[Namespace]]: empty, [[HostDefined]]: undefined, [[ExportNames]]: « "default" », [[EvaluationSteps]]: setDefaultExport }를 반환한다.

16.2.1.8.2 ParseJSONModule ( source )

The abstract operation ParseJSONModule takes argument source (a String) and returns either a normal completion containing a Synthetic Module Record, or a throw completion. It performs the following steps when called:

  1. parseResult를 ? ParseJSON(source)로 둔다.
  2. CreateDefaultExportSyntheticModule(parseResult.[[Value]])를 반환한다.

16.2.1.8.3 SetSyntheticModuleExport ( module, exportName, exportValue )

The abstract operation SetSyntheticModuleExport takes arguments module (a Synthetic Module Record), exportName (a String), and exportValue (an ECMAScript language value) and returns unused. Synthetic Module Record의 existing export에 대한 exported value를 set하거나 change하는 데 사용될 수 있습니다. It performs the following steps when called:

  1. Assert: module.[[ExportNames]]exportName을 contain한다.
  2. envRecordmodule.[[Environment]]로 둔다.
  3. Assert: envRecordempty가 아니다.
  4. envRecord.SetMutableBinding(exportName, exportValue, true)를 수행한다.
  5. unused를 반환한다.

16.2.1.8.4 Implementation of Module Record Abstract Methods

다음은 Table 40에 defined된 corresponding Module Record abstract method를 implement하는 Synthetic Module Record의 concrete method입니다.

16.2.1.8.4.1 LoadRequestedModules ( [ hostDefined ] )

The LoadRequestedModules concrete method of a Synthetic Module Record module takes optional argument hostDefined (anything) and returns a Promise. It performs the following steps when called:

  1. NOTE: LoadRequestedModules의 이 implementation은 hostDefined를 사용하지 않는다.
  2. PromiseResolve(%Promise%, undefined)를 반환한다.
Note
Synthetic Module Records는 dependency를 가지지 않습니다.

16.2.1.8.4.2 GetExportedNames ( [ exportStarSet ] )

The GetExportedNames concrete method of a Synthetic Module Record module takes optional argument exportStarSet (a List of Source Text Module Records) and returns a List of Strings. It performs the following steps when called:

  1. NOTE: GetExportedNames의 이 implementation은 exportStarSet을 사용하지 않는다.
  2. module.[[ExportNames]]를 반환한다.

16.2.1.8.4.3 ResolveExport ( exportName [ , resolveSet ] )

The ResolveExport concrete method of a Synthetic Module Record module takes argument exportName (a String) and optional argument resolveSet (a List of Records with fields [[Module]] (a Module Record) and [[ExportName]] (a String)) and returns a ResolvedBinding Record, null, or ambiguous. It performs the following steps when called:

  1. NOTE: ResolveExport의 이 implementation은 resolveSet을 사용하지 않는다.
  2. module.[[ExportNames]]exportName을 contain하지 않으면, null을 반환한다.
  3. ResolvedBinding Record { [[Module]]: module, [[BindingName]]: exportName }을 반환한다.

16.2.1.8.4.4 Link ( )

The Link concrete method of a Synthetic Module Record module takes no arguments and returns a normal completion containing unused. It performs the following steps when called:

  1. realmmodule.[[Realm]]로 둔다.
  2. envRecordNewModuleEnvironment(realm.[[GlobalEnv]])로 둔다.
  3. module.[[Environment]]envRecord로 설정한다.
  4. module.[[ExportNames]]의 각 String exportName에 대해, 다음을 수행한다.
    1. envRecord.CreateMutableBinding(exportName, false)를 수행한다.
    2. envRecord.InitializeBinding(exportName, undefined)를 수행한다.
  5. NormalCompletion(unused)를 반환한다.

16.2.1.8.4.5 Evaluate ( )

The Evaluate concrete method of a Synthetic Module Record module takes no arguments and returns a Promise. It performs the following steps when called:

  1. moduleContext를 새 ECMAScript code execution context로 둔다.
  2. moduleContext의 Function을 null로 설정한다.
  3. moduleContextRealmmodule.[[Realm]]로 설정한다.
  4. moduleContext의 ScriptOrModule을 module로 설정한다.
  5. moduleContext의 VariableEnvironment를 module.[[Environment]]로 설정한다.
  6. moduleContext의 LexicalEnvironment를 module.[[Environment]]로 설정한다.
  7. running execution context를 suspend한다.
  8. moduleContextexecution context stack에 push한다; moduleContext는 이제 running execution context이다.
  9. stepsmodule.[[EvaluationSteps]]로 둔다.
  10. resultCompletion(steps(module))로 둔다.
  11. moduleContext를 suspend하고 execution context stack에서 remove한다.
  12. execution context stack의 top에 now 있는 context를 running execution context로 resume한다.
  13. promiseCapability를 ! NewPromiseCapability(%Promise%)로 둔다.
  14. IfAbruptRejectPromise(result, promiseCapability)를 수행한다.
  15. Call(promiseCapability.[[Resolve]], undefined, « undefined »)를 수행한다.
  16. promiseCapability.[[Promise]]를 반환한다.

16.2.1.9 GetImportedModule ( referrer, request )

The abstract operation GetImportedModule takes arguments referrer (a Cyclic Module Record) and request (a ModuleRequest Record) and returns a Module Record. It performs the following steps when called:

  1. recordsModuleRequestsEqual(r, request)이 truereferrer.[[LoadedModules]]의 각 LoadedModuleRequest Record r로 구성된 List로 둔다.
  2. Assert: this abstract operation을 invoking하기 전에 LoadRequestedModulesreferrer에서 successfully completed되었으므로, records는 exactly one element를 가진다.
  3. recordrecords의 sole element로 둔다.
  4. record.[[Module]]을 반환한다.

16.2.1.10 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

referrerRealm Record일 수 있는 경우의 example은 web browser host입니다. 거기서 user가 다음에 의해 given된 control을 click하면

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

import() expression이 run되는 time에는 active script 또는 module이 없을 것입니다. More generally, 이는 hostnull ScriptOrModule component를 가진 execution contextexecution context stack에 push하는 any situation에서 happen할 수 있습니다.

HostLoadImportedModule의 implementation은 다음 requirements에 conform해야 합니다:

performed되는 actual process는 host-defined이지만, typically appropriate Module Record를 load하는 데 necessary한 whatever I/O operation을 performing하는 것으로 구성됩니다. Multiple different (referrer, moduleRequest.[[Specifier]], moduleRequest.[[Attributes]]) triple이 same Module Record instance에 map될 수 있습니다. actual mapping semantics는 host-defined이지만 typically normalization process가 mapping process의 part로 specifier에 applied됩니다. typical normalization process는 relative 및 abbreviated path specifier의 expansion과 같은 action을 include할 것입니다.

Note 2

above text는 hosttype: "json"으로 imported된 JSON module을 support할 것을 require하지만(그리고 HostLoadImportedModule이 normally complete하는 경우), type: "json" 없이 imported된 JSON module을 host가 supporting하는 것을 prohibit하지 않습니다.

16.2.1.11 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. resultnormal completion이면, 다음을 수행한다.
    1. referrer.[[LoadedModules]]ModuleRequestsEqual(record, moduleRequest)이 trueLoadedModuleRequest Record record를 contain하면, 다음을 수행한다.
      1. Assert: record.[[Module]]result.[[Value]]는 same Module Record이다.
    2. 그렇지 않으면,
      1. LoadedModuleRequest Record { [[Specifier]]: moduleRequest.[[Specifier]], [[Attributes]]: moduleRequest.[[Attributes]], [[Module]]: result.[[Value]] }를 referrer.[[LoadedModules]]에 append한다.
  2. payloadGraphLoadingState Record이면, 다음을 수행한다.
    1. ContinueModuleLoading(payload, result)를 수행한다.
  3. 그렇지 않으면,
    1. ContinueDynamicImport(payload, result)를 수행한다.
  4. unused를 반환한다.

16.2.1.12 AllImportAttributesSupported ( attrs )

The abstract operation AllImportAttributesSupported takes argument attrs (a List of ImportAttribute Records) and returns a Boolean. It performs the following steps when called:

  1. supportedHostGetSupportedImportAttributes()로 둔다.
  2. attrs의 각 ImportAttribute Record attr에 대해, 다음을 수행한다.
    1. supportedattr.[[Key]]를 contain하지 않으면, false를 반환한다.
  3. true를 반환한다.

16.2.1.12.1 HostGetSupportedImportAttributes ( )

The host-defined abstract operation HostGetSupportedImportAttributes takes no arguments and returns a List of Strings. host environment가 support하는 import attribute를 specify할 수 있게 합니다. supported key를 가진 attribute만 host에 provided됩니다.

HostGetSupportedImportAttributes의 implementation은 다음 requirements에 conform해야 합니다:

  • supported attribute를 각각 indicate하는 String의 List를 반환해야 합니다.
  • 이 operation이 called될 때마다, same contents를 same order로 가진 same List를 반환해야 합니다.

HostGetSupportedImportAttributes의 default implementation은 새 empty List를 반환하는 것입니다.

Note
host가 support하는 import attribute를 specify하도록 require하는 목적은, 모든 attribute를 host에 pass하고 host가 then 처리하려는 것을 choose하게 하는 대신, unsupported attribute가 different host across consistent way로 handled되도록 ensure하기 위한 것입니다.

16.2.1.13 GetModuleNamespace ( module )

The abstract operation GetModuleNamespace takes argument module (an instance of a concrete subclass of Module Record) and returns a Module Namespace Object. module의 export를 represent하는 Module Namespace Object를 retrieve하며, first time requested되었을 때 lazily creating하고 future retrieval을 위해 module.[[Namespace]]에 storing합니다. It performs the following steps when called:

  1. Assert: moduleCyclic Module Record이면, module.[[Status]]new 또는 unlinked가 아니다.
  2. namespacemodule.[[Namespace]]로 둔다.
  3. namespaceempty이면, 다음을 수행한다.
    1. exportedNamesmodule.GetExportedNames()로 둔다.
    2. unambiguousNames를 새 empty List로 둔다.
    3. exportedNames의 각 element name에 대해, 다음을 수행한다.
      1. resolutionmodule.ResolveExport(name)으로 둔다.
      2. resolutionResolvedBinding Record이면, nameunambiguousNames에 append한다.
    4. namespaceModuleNamespaceCreate(module, unambiguousNames)로 설정한다.
  4. namespace를 반환한다.
Note

GetModuleNamespace는 never throws. 대신 unresolvable name은 이 point에서 simply namespace에서 excluded됩니다. 그것들이 explicitly requested되지 않는 ambiguous star export뿐인 경우가 아니면, later에 real linking error로 이어질 것입니다.

16.2.1.14 Runtime Semantics: Evaluation

Module : [empty]
  1. undefined를 반환한다.
ModuleBody : ModuleItemList
  1. resultCompletion(ModuleItemListEvaluation)으로 둔다.
  2. resultnormal completion이고 result.[[Value]]empty이면, 다음을 수행한다.
    1. undefined를 반환한다.
  3. result를 반환한다.
ModuleItemList : ModuleItemList ModuleItem
  1. slModuleItemListEvaluation으로 ? 둔다.
  2. sModuleItemEvaluationCompletion으로 둔다.
  3. UpdateEmpty(s, sl)를 반환한다.
Note

ModuleItemList의 value는 ModuleItemList 안의 last value-producing item의 value입니다.

ModuleItem : ImportDeclaration
  1. empty를 반환한다.

16.2.2 Imports

Syntax

ImportDeclaration : import ImportClause FromClause WithClauseopt ; import ModuleSpecifier WithClauseopt ; ImportClause : ImportedDefaultBinding NameSpaceImport NamedImports ImportedDefaultBinding , NameSpaceImport ImportedDefaultBinding , NamedImports ImportedDefaultBinding : ImportedBinding NameSpaceImport : * as ImportedBinding NamedImports : { } { ImportsList } { ImportsList , } FromClause : from ModuleSpecifier ImportsList : ImportSpecifier ImportsList , ImportSpecifier ImportSpecifier : ImportedBinding ModuleExportName as ImportedBinding ModuleSpecifier : StringLiteral ImportedBinding : BindingIdentifier[~Yield, +Await] WithClause : with { } with { WithEntries ,opt } WithEntries : AttributeKey : StringLiteral AttributeKey : StringLiteral , WithEntries AttributeKey : IdentifierName StringLiteral

16.2.2.1 Static Semantics: Early Errors

ModuleItem : ImportDeclaration WithClause : with { WithEntries ,opt }

16.2.2.2 Static Semantics: ImportEntries

The syntax-directed operation ImportEntries takes no arguments and returns a List of ImportEntry Records. It is defined piecewise over the following productions:

Module : [empty]
  1. 새 empty List를 반환한다.
ModuleItemList : ModuleItemList ModuleItem
  1. entries1ModuleItemListImportEntries로 둔다.
  2. entries2ModuleItemImportEntries로 둔다.
  3. entries1entries2list-concatenation을 반환한다.
ModuleItem : ExportDeclaration StatementListItem
  1. 새 empty List를 반환한다.
ImportDeclaration : import ImportClause FromClause WithClauseopt ;
  1. moduleImportDeclarationModuleRequests의 sole element로 둔다.
  2. argument module을 가진 ImportClauseImportEntriesForModule을 반환한다.
ImportDeclaration : import ModuleSpecifier WithClauseopt ;
  1. 새 empty List를 반환한다.

16.2.2.3 Static Semantics: ImportEntriesForModule

The syntax-directed operation ImportEntriesForModule takes argument module (a ModuleRequest Record) and returns a List of ImportEntry Records. It is defined piecewise over the following productions:

ImportClause : ImportedDefaultBinding , NameSpaceImport
  1. entries1을 argument module을 가진 ImportedDefaultBindingImportEntriesForModule로 둔다.
  2. entries2를 argument module을 가진 NameSpaceImportImportEntriesForModule로 둔다.
  3. entries1entries2list-concatenation을 반환한다.
ImportClause : ImportedDefaultBinding , NamedImports
  1. entries1을 argument module을 가진 ImportedDefaultBindingImportEntriesForModule로 둔다.
  2. entries2를 argument module을 가진 NamedImportsImportEntriesForModule로 둔다.
  3. entries1entries2list-concatenation을 반환한다.
ImportedDefaultBinding : ImportedBinding
  1. localNameImportedBindingBoundNames의 sole element로 둔다.
  2. defaultEntryImportEntry Record { [[ModuleRequest]]: module, [[ImportName]]: "default", [[LocalName]]: localName }로 둔다.
  3. « defaultEntry »를 반환한다.
NameSpaceImport : * as ImportedBinding
  1. localNameImportedBindingStringValue로 둔다.
  2. entryImportEntry Record { [[ModuleRequest]]: module, [[ImportName]]: namespace, [[LocalName]]: localName }로 둔다.
  3. « entry »를 반환한다.
NamedImports : { }
  1. 새 empty List를 반환한다.
ImportsList : ImportsList , ImportSpecifier
  1. specs1을 argument module을 가진 ImportsListImportEntriesForModule로 둔다.
  2. specs2를 argument module을 가진 ImportSpecifierImportEntriesForModule로 둔다.
  3. specs1specs2list-concatenation을 반환한다.
ImportSpecifier : ImportedBinding
  1. localNameImportedBindingBoundNames의 sole element로 둔다.
  2. entryImportEntry Record { [[ModuleRequest]]: module, [[ImportName]]: localName, [[LocalName]]: localName }로 둔다.
  3. « entry »를 반환한다.
ImportSpecifier : ModuleExportName as ImportedBinding
  1. importNameModuleExportNameStringValue로 둔다.
  2. localNameImportedBindingStringValue로 둔다.
  3. entryImportEntry Record { [[ModuleRequest]]: module, [[ImportName]]: importName, [[LocalName]]: localName }로 둔다.
  4. « entry »를 반환한다.

16.2.2.4 Static Semantics: WithClauseToAttributes

The syntax-directed operation WithClauseToAttributes takes no arguments and returns a List of ImportAttribute Records. It is defined piecewise over the following productions:

WithClause : with { }
  1. 새 empty List를 반환한다.
WithClause : with { WithEntries ,opt }
  1. attrsWithEntriesWithClauseToAttributes로 둔다.
  2. attrs를 각 such field의 value를 UTF-16 code unit value의 sequence로 treating하여 그 [[Key]] field의 lexicographic order에 따라 sort한다. NOTE: 이 sorting은 host가 attribute가 enumerated되는 order에 따라 behaviour를 changing하는 것이 prohibited된다는 점에서만 observable하다.
  3. attrs를 반환한다.
WithEntries : AttributeKey : StringLiteral
  1. keyAttributeKeyPropName으로 둔다.
  2. entryImportAttribute Record { [[Key]]: key, [[Value]]: StringLiteralSV }로 둔다.
  3. « entry »를 반환한다.
WithEntries : AttributeKey : StringLiteral , WithEntries
  1. keyAttributeKeyPropName으로 둔다.
  2. entryImportAttribute Record { [[Key]]: key, [[Value]]: StringLiteralSV }로 둔다.
  3. restWithEntriesWithClauseToAttributes로 둔다.
  4. « entry »와 restlist-concatenation을 반환한다.

16.2.3 Exports

Syntax

ExportDeclaration : export ExportFromClause FromClause WithClauseopt ; export NamedExports ; export VariableStatement[~Yield, +Await] export [lookahead ∉ { using, await }] Declaration[~Yield, +Await] export default HoistableDeclaration[~Yield, +Await, +Default] export default ClassDeclaration[~Yield, +Await, +Default] export default [lookahead ∉ { function, async [no LineTerminator here] function, class }] AssignmentExpression[+In, ~Yield, +Await] ; ExportFromClause : * * as ModuleExportName NamedExports NamedExports : { } { ExportsList } { ExportsList , } ExportsList : ExportSpecifier ExportsList , ExportSpecifier ExportSpecifier : ModuleExportName ModuleExportName as ModuleExportName

16.2.3.1 Static Semantics: Early Errors

ExportDeclaration : export NamedExports ; Note

above rule은 NamedExports의 각 ReferencedBindingsIdentifierReference로 treated됨을 의미합니다.

16.2.3.2 Static Semantics: ExportedBindings

The syntax-directed operation ExportedBindings takes no arguments and returns a List of Strings.

Note

ExportedBindings는 ModuleExportedNames와 explicitly associated된 locally bound name입니다.

It is defined piecewise over the following productions:

ModuleItemList : ModuleItemList ModuleItem
  1. names1ModuleItemListExportedBindings로 둔다.
  2. names2ModuleItemExportedBindings로 둔다.
  3. names1names2list-concatenation을 반환한다.
ModuleItem : ImportDeclaration StatementListItem
  1. 새 empty List를 반환한다.
ExportDeclaration : export ExportFromClause FromClause WithClauseopt ;
  1. 새 empty List를 반환한다.
ExportDeclaration : export NamedExports ;
  1. NamedExportsExportedBindings를 반환한다.
ExportDeclaration : export VariableStatement
  1. VariableStatementBoundNames를 반환한다.
ExportDeclaration : export Declaration
  1. DeclarationBoundNames를 반환한다.
ExportDeclaration : export default HoistableDeclaration export default ClassDeclaration export default AssignmentExpression ;
  1. this ExportDeclarationBoundNames를 반환한다.
NamedExports : { }
  1. 새 empty List를 반환한다.
ExportsList : ExportsList , ExportSpecifier
  1. names1ExportsListExportedBindings로 둔다.
  2. names2ExportSpecifierExportedBindings로 둔다.
  3. names1names2list-concatenation을 반환한다.
ExportSpecifier : ModuleExportName
  1. sole element가 ModuleExportNameStringValueList를 반환한다.
ExportSpecifier : ModuleExportName as ModuleExportName
  1. sole element가 first ModuleExportNameStringValueList를 반환한다.

16.2.3.3 Static Semantics: ExportedNames

The syntax-directed operation ExportedNames takes no arguments and returns a List of Strings.

Note

ExportedNames는 Module이 explicitly 그 local name binding 중 하나에 map하는 externally visible name입니다.

It is defined piecewise over the following productions:

ModuleItemList : ModuleItemList ModuleItem
  1. names1ModuleItemListExportedNames로 둔다.
  2. names2ModuleItemExportedNames로 둔다.
  3. names1names2list-concatenation을 반환한다.
ModuleItem : ExportDeclaration
  1. ExportDeclarationExportedNames를 반환한다.
ModuleItem : ImportDeclaration StatementListItem
  1. 새 empty List를 반환한다.
ExportDeclaration : export ExportFromClause FromClause WithClauseopt ;
  1. ExportFromClauseExportedNames를 반환한다.
ExportFromClause : *
  1. 새 empty List를 반환한다.
ExportFromClause : * as ModuleExportName
  1. sole element가 ModuleExportNameStringValueList를 반환한다.
ExportFromClause : NamedExports
  1. NamedExportsExportedNames를 반환한다.
ExportDeclaration : export VariableStatement
  1. VariableStatementBoundNames를 반환한다.
ExportDeclaration : export Declaration
  1. DeclarationBoundNames를 반환한다.
ExportDeclaration : export default HoistableDeclaration export default ClassDeclaration export default AssignmentExpression ;
  1. « "default" »를 반환한다.
NamedExports : { }
  1. 새 empty List를 반환한다.
ExportsList : ExportsList , ExportSpecifier
  1. names1ExportsListExportedNames로 둔다.
  2. names2ExportSpecifierExportedNames로 둔다.
  3. names1names2list-concatenation을 반환한다.
ExportSpecifier : ModuleExportName
  1. sole element가 ModuleExportNameStringValueList를 반환한다.
ExportSpecifier : ModuleExportName as ModuleExportName
  1. sole element가 second ModuleExportNameStringValueList를 반환한다.

16.2.3.4 Static Semantics: ExportEntries

The syntax-directed operation ExportEntries takes no arguments and returns a List of ExportEntry Records. It is defined piecewise over the following productions:

Module : [empty]
  1. 새 empty List를 반환한다.
ModuleItemList : ModuleItemList ModuleItem
  1. entries1ModuleItemListExportEntries로 둔다.
  2. entries2ModuleItemExportEntries로 둔다.
  3. entries1entries2list-concatenation을 반환한다.
ModuleItem : ImportDeclaration StatementListItem
  1. 새 empty List를 반환한다.
ExportDeclaration : export ExportFromClause FromClause WithClauseopt ;
  1. moduleExportDeclarationModuleRequests의 sole element로 둔다.
  2. argument module을 가진 ExportFromClauseExportEntriesForModule을 반환한다.
ExportDeclaration : export NamedExports ;
  1. argument null을 가진 NamedExportsExportEntriesForModule을 반환한다.
ExportDeclaration : export VariableStatement
  1. entries를 새 empty List로 둔다.
  2. namesVariableStatementBoundNames로 둔다.
  3. names의 각 element name에 대해, 다음을 수행한다.
    1. ExportEntry Record { [[ModuleRequest]]: null, [[ImportName]]: null, [[LocalName]]: name, [[ExportName]]: name }을 entries에 append한다.
  4. entries를 반환한다.
ExportDeclaration : export Declaration
  1. entries를 새 empty List로 둔다.
  2. namesDeclarationBoundNames로 둔다.
  3. names의 각 element name에 대해, 다음을 수행한다.
    1. ExportEntry Record { [[ModuleRequest]]: null, [[ImportName]]: null, [[LocalName]]: name, [[ExportName]]: name }을 entries에 append한다.
  4. entries를 반환한다.
ExportDeclaration : export default HoistableDeclaration
  1. namesHoistableDeclarationBoundNames로 둔다.
  2. localNamenames의 sole element로 둔다.
  3. sole element가 new ExportEntry Record { [[ModuleRequest]]: null, [[ImportName]]: null, [[LocalName]]: localName, [[ExportName]]: "default" }인 List를 반환한다.
ExportDeclaration : export default ClassDeclaration
  1. namesClassDeclarationBoundNames로 둔다.
  2. localNamenames의 sole element로 둔다.
  3. sole element가 new ExportEntry Record { [[ModuleRequest]]: null, [[ImportName]]: null, [[LocalName]]: localName, [[ExportName]]: "default" }인 List를 반환한다.
ExportDeclaration : export default AssignmentExpression ;
  1. entryExportEntry Record { [[ModuleRequest]]: null, [[ImportName]]: null, [[LocalName]]: "*default*", [[ExportName]]: "default" }로 둔다.
  2. « entry »를 반환한다.
Note

"*default*"는 anonymous default export value를 위한 synthetic name으로 이 specification 안에서 사용됩니다. more details는 this note를 참조하십시오.

16.2.3.5 Static Semantics: ExportEntriesForModule

The syntax-directed operation ExportEntriesForModule takes argument module (a ModuleRequest Record or null) and returns a List of ExportEntry Records. It is defined piecewise over the following productions:

ExportFromClause : *
  1. entryExportEntry Record { [[ModuleRequest]]: module, [[ImportName]]: all-but-default, [[LocalName]]: null, [[ExportName]]: null }로 둔다.
  2. « entry »를 반환한다.
ExportFromClause : * as ModuleExportName
  1. exportNameModuleExportNameStringValue로 둔다.
  2. entryExportEntry Record { [[ModuleRequest]]: module, [[ImportName]]: namespace, [[LocalName]]: null, [[ExportName]]: exportName }로 둔다.
  3. « entry »를 반환한다.
NamedExports : { }
  1. 새 empty List를 반환한다.
ExportsList : ExportsList , ExportSpecifier
  1. specs1을 argument module을 가진 ExportsListExportEntriesForModule로 둔다.
  2. specs2를 argument module을 가진 ExportSpecifierExportEntriesForModule로 둔다.
  3. specs1specs2list-concatenation을 반환한다.
ExportSpecifier : ModuleExportName
  1. sourceNameModuleExportNameStringValue로 둔다.
  2. modulenull이면, 다음을 수행한다.
    1. localNamesourceName으로 둔다.
    2. importNamenull로 둔다.
  3. 그렇지 않으면,
    1. localNamenull로 둔다.
    2. importNamesourceName으로 둔다.
  4. sole element가 new ExportEntry Record { [[ModuleRequest]]: module, [[ImportName]]: importName, [[LocalName]]: localName, [[ExportName]]: sourceName }인 List를 반환한다.
ExportSpecifier : ModuleExportName as ModuleExportName
  1. sourceName을 first ModuleExportNameStringValue로 둔다.
  2. exportName을 second ModuleExportNameStringValue로 둔다.
  3. modulenull이면, 다음을 수행한다.
    1. localNamesourceName으로 둔다.
    2. importNamenull로 둔다.
  4. 그렇지 않으면,
    1. localNamenull로 둔다.
    2. importNamesourceName으로 둔다.
  5. sole element가 new ExportEntry Record { [[ModuleRequest]]: module, [[ImportName]]: importName, [[LocalName]]: localName, [[ExportName]]: exportName }인 List를 반환한다.

16.2.3.6 Static Semantics: ReferencedBindings

The syntax-directed operation ReferencedBindings takes no arguments and returns a List of Parse Nodes. It is defined piecewise over the following productions:

NamedExports : { }
  1. 새 empty List를 반환한다.
ExportsList : ExportsList , ExportSpecifier
  1. names1ExportsListReferencedBindings로 둔다.
  2. names2ExportSpecifierReferencedBindings로 둔다.
  3. names1names2list-concatenation을 반환한다.
ExportSpecifier : ModuleExportName as ModuleExportName
  1. first ModuleExportNameReferencedBindings를 반환한다.
ModuleExportName : IdentifierName
  1. sole element가 IdentifierNameList를 반환한다.
ModuleExportName : StringLiteral
  1. sole element가 StringLiteralList를 반환한다.

16.2.3.7 Runtime Semantics: Evaluation

ExportDeclaration : export ExportFromClause FromClause WithClauseopt ; export NamedExports ;
  1. empty를 반환한다.
ExportDeclaration : export VariableStatement
  1. VariableStatementEvaluation을 ? 반환한다.
ExportDeclaration : export Declaration
  1. DeclarationEvaluation을 ? 반환한다.
ExportDeclaration : export default HoistableDeclaration
  1. HoistableDeclarationEvaluation을 ? 반환한다.
ExportDeclaration : export default ClassDeclaration
  1. valueClassDeclarationBindingClassDeclarationEvaluation으로 ? 둔다.
  2. classNameClassDeclarationBoundNames의 sole element로 둔다.
  3. className"*default*"이면, 다음을 수행한다.
    1. envRecordrunning execution context의 LexicalEnvironment로 둔다.
    2. InitializeBoundName("*default*", value, envRecord)를 수행한다.
  4. empty를 반환한다.
ExportDeclaration : export default AssignmentExpression ;
  1. IsAnonymousFunctionDefinition(AssignmentExpression)이 true이면, 다음을 수행한다.
    1. value를 argument "default"를 가진 AssignmentExpressionNamedEvaluation으로 ? 둔다.
  2. 그렇지 않으면,
    1. rhsAssignmentExpressionEvaluation으로 ? 둔다.
    2. value를 ? GetValue(rhs)로 둔다.
  3. envRecordrunning execution context의 LexicalEnvironment로 둔다.
  4. InitializeBoundName("*default*", value, envRecord)를 수행한다.
  5. empty를 반환한다.