You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: spec.html
+192
Original file line number
Diff line number
Diff line change
@@ -28621,6 +28621,191 @@ <h1>
28621
28621
</emu-clause>
28622
28622
</emu-clause>
28623
28623
28624
+
<emu-clause id="sec-synthetic-module-records">
28625
+
<h1>Synthetic Module Records</h1>
28626
+
28627
+
<p>A <dfn variants="Synthetic Module Records">Synthetic Module Record</dfn> is used to represent information about a module that is defined by specifications. Its exported names are statically defined at creation, while their corresponding values can change over time using SetSyntheticModuleExport. It has no imports or dependencies.</p>
28628
+
28629
+
<emu-note>A Synthetic Module Record could be used for defining a variety of module types: for example, JSON modules or CSS modules.</emu-note>
28630
+
28631
+
<p>In addition to the fields defined in <emu-xref href="#table-module-record-fields"></emu-xref> Synthetic Module Records have the additional fields listed in <emu-xref href="#table-synthetic-module-record-fields"></emu-xref>.</p>
28632
+
28633
+
<emu-table id="table-synthetic-module-record-fields" caption="Additional Fields of Synthetic Module Records">
28634
+
<table>
28635
+
<thead>
28636
+
<tr>
28637
+
<th>Field Name</th>
28638
+
<th>Value Type</th>
28639
+
<th>Meaning</th>
28640
+
</tr>
28641
+
</thead>
28642
+
<tr>
28643
+
<td>[[ExportNames]]</td>
28644
+
<td>a List of Strings</td>
28645
+
<td>The names of the exports of the module. This list does not contain duplicates.</td>
28646
+
</tr>
28647
+
<tr>
28648
+
<td>[[EvaluationSteps]]</td>
28649
+
<td>an Abstract Closure</td>
28650
+
<td>The initialization logic to perform upon evaluation of the module, taking the Synthetic Module Record as its sole argument. It must not modify [[ExportNames]]. It may return an abrupt completion.</td>
<dd>It creates a Synthetic Module Record whose default export is _defaultExport_.</dd>
28664
+
</dl>
28665
+
<emu-alg>
28666
+
1. Let _realm_ be the current Realm Record.
28667
+
1. Let _setDefaultExport_ be a new Abstract Closure with parameters (_module_) that captures _defaultExport_ and performs the following steps when called:
<h1>Implementation of Module Record Abstract Methods</h1>
28714
+
28715
+
<p>The following are the concrete methods for Synthetic Module Record that implement the corresponding Module Record abstract methods defined in <emu-xref href="#table-abstract-methods-of-module-records"></emu-xref>.</p>
<p>and it performs FinishLoadingImportedModule(_referrer_, _moduleRequest_, _payload_, _result_) where _result_ is a normal completion, then it must perform FinishLoadingImportedModule(_referrer_, _moduleRequest_, _payload_, _result_) with the same _result_ each time.</p>
28678
28863
</li>
28864
+
<li>
28865
+
<p>If _moduleRequest_.[[Attributes]] has an entry _entry_ such that _entry_.[[Key]] is *"type"* and _entry_.[[Value]] is *"json"*, when the host environment performs FinishLoadingImportedModule(_referrer_, _moduleRequest_, _payload_, _result_), _result_ must either be the Completion Record returned by an invocation of ParseJSONModule or a throw completion.</p>
28866
+
</li>
28679
28867
<li>
28680
28868
The operation must treat _payload_ as an opaque value to be passed through to FinishLoadingImportedModule.
28681
28869
</li>
28682
28870
</ul>
28683
28871
28684
28872
<p>The actual process performed is host-defined, but typically consists of performing whatever I/O operations are necessary to load the appropriate Module Record. Multiple different (_referrer_, _moduleRequest_.[[Specifier]], _moduleRequest_.[[Attributes]]) triples may map to the same Module Record instance. The actual mapping semantics is host-defined but typically a normalization process is applied to _specifier_ as part of the mapping process. A typical normalization process would include actions such as expansion of relative and abbreviated path specifiers.</p>
28873
+
28874
+
<emu-note>
28875
+
<p>The above text requires that hosts support JSON modules when imported with `type: "json"` (and HostLoadImportedModule completes normally), but it does not prohibit hosts from supporting JSON modules when imported without `type: "json"`.</p>
0 commit comments