Skip to content

Commit

Permalink
Add import.meta.resolve()
Browse files Browse the repository at this point in the history
Closes #3871.
  • Loading branch information
domenic committed Jun 30, 2022
1 parent 2edc808 commit b235571
Showing 1 changed file with 43 additions and 6 deletions.
49 changes: 43 additions & 6 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -2879,6 +2879,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-cleanup-finalization-registry">CleanupFinalizationRegistry</dfn> abstract operation</li>
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-construct">Construct</dfn> abstract operation</li>
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-copydatablockbytes">CopyDataBlockBytes</dfn> abstract operation</li>
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-createbuiltinfunction">CreateBuiltinFunction</dfn> abstract operation</li>
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-createbytedatablock">CreateByteDataBlock</dfn> abstract operation</li>
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-createdataproperty">CreateDataProperty</dfn> abstract operation</li>
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-detacharraybuffer">DetachArrayBuffer</dfn> abstract operation</li>
Expand Down Expand Up @@ -95898,14 +95899,27 @@ dictionary <dfn dictionary>PromiseRejectionEventInit</dfn> : <span>EventInit</sp
world, from the classic-script world.</p>
</dd>

<dt><code data-x=""><var>url</var> = <span data-x="import.meta">import.meta </span><span data-x="">.url</span></code></dt>
<dt><code data-x=""><var>url</var> = <span data-x="import.meta">import.meta</span>.<span data-x="import-meta-url">url</span></code></dt>

<dd>
<p>Returns the <span data-x="active script">active module script</span>'s <span
data-x="concept-script-base-url">base URL</span>.</p>

<p>This syntax can only be used inside <span data-x="module script">module scripts</span>.</p>
</dd>

<dt><code data-x=""><var>url</var> = <span data-x="import.meta">import.meta</span>.<span data-x="import-meta-resolve">resolve</span>(<var>specifier</var>)</code></dt>

<dd>
<p>Returns <var>specifier</var>, <span data-x="resolve a module specifier">resolved</span>
relative to the <span>active script</span>'s <span data-x="concept-script-base-url">base
URL</span>. That is, this returns the URL that would be imported by using <code
data-x="import()">import(<var>specifier</var>)</code>.</p>

<p>Throws a <code>TypeError</code> exception if an invalid specifier is given.</p>

<p>This syntax can only be used inside <span data-x="module script">module scripts</span>.</p>
</dd>
</dl>

<p><span w-nodev>A <dfn>module map</dfn> is a <span data-x="ordered map">map</span> keyed by <span
Expand Down Expand Up @@ -96089,17 +96103,40 @@ import "https://example.com/foo/../module2.mjs";</code></pre>
User agents must use the following implementation: <ref spec=JAVASCRIPT></p>

<ol>
<li><p>Let <var>module script</var> be <var>moduleRecord</var>.[[HostDefined]].</p></li>
<li><p>Let <var>moduleScript</var> be <var>moduleRecord</var>.[[HostDefined]].</p></li>

<li><p>Assert: <var>module script</var>'s <span data-x="concept-script-base-url">base
URL</span> is not null, as <var>module script</var> is a <span>JavaScript module
<li><p>Assert: <var>moduleScript</var>'s <span data-x="concept-script-base-url">base
URL</span> is not null, as <var>moduleScript</var> is a <span>JavaScript module
script</span>.</p></li>

<li><p>Let <var>urlString</var> be <var>module script</var>'s <span
<li><p>Let <var>urlString</var> be <var>moduleScript</var>'s <span
data-x="concept-script-base-url">base URL</span>, <span
data-x="concept-url-serializer">serialized</span>.</p></li>

<li><p>Return « Record { [[Key]]: "url", [[Value]]: <var>urlString</var> } ».</p></li>
<li>
<p>Let <var>steps</var> be the following steps, given the argument <var>specifier</var>:</p>

<ol>
<li><p>Set <var>specifier</var> to ? <span>ToString</span>(<var>specifier</var>).</p></li>

<li><p>Let <var>url</var> be the result of <span data-x="resolve a module specifier">resolving
a module specifier</span> given <var>moduleScript</var>'s <span
data-x="concept-script-base-url">base URL</span> and <var>specifier</var>.</p></li>

<li><p>If <var>url</var> is failure, then throw a <code>TypeError</code> exception.</p></li>

<li><p>Return the <span data-x="concept-url-serializer">serialization</span> of
<var>url</var>.</p></li>
</ol>
</li>

<li><p>Let <var>resolveFunction</var> be ! <span>CreateBuiltinFunction</span>(<var>steps</var>, 1,
"<code data-x="">resolve</code>", « »).</p></li>

<li><p>Return « Record { [[Key]]: "<dfn><code data-x="import-meta-url">url</code></dfn>",
[[Value]]: <var>urlString</var> }, Record { [[Key]]: "<dfn><code
data-x="import-meta-resolve">resolve</code></dfn>", [[Value]]: <var>resolveFunction</var> }
».</p></li>
</ol>

<h6><dfn>HostImportModuleDynamically</dfn>(<var>referencingScriptOrModule</var>,
Expand Down

0 comments on commit b235571

Please sign in to comment.