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 May 21, 2020
1 parent f57890b commit fa07fc6
Showing 1 changed file with 46 additions and 2 deletions.
48 changes: 46 additions & 2 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -2778,6 +2778,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-call">Call</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 @@ -2824,6 +2825,8 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-samevalue">SameValue</dfn> abstract operation</li>
<li>The <dfn data-x="js-ScriptEvaluation" data-x-href="https://tc39.es/ecma262/#sec-runtime-semantics-scriptevaluation">ScriptEvaluation</dfn> abstract operation</li>
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-set-immutable-prototype">SetImmutablePrototype</dfn> abstract operation</li>
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-setfunctionname">SetFunctionName</dfn> abstract operation</li>
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-setfunctionlength">SetFunctionLength</dfn> abstract operation</li>
<li>The <dfn data-x="js-ToBoolean" data-x-href="https://tc39.es/ecma262/#sec-toboolean">ToBoolean</dfn> abstract operation</li>
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-tostring">ToString</dfn> abstract operation</li>
<li>The <dfn data-x-href="https://tc39.es/ecma262/#sec-touint32">ToUint32</dfn> abstract operation</li>
Expand Down Expand Up @@ -88056,14 +88059,27 @@ document.querySelector("button").addEventListener("click", bound);
world, from the classic-script world.</p>
</dd>

<dt><var>url</var> = <code data-x="import.meta">import . meta </code><code data-x=""> . url</code></dt>
<dt><var>url</var> = <code data-x="import.meta">import . meta</code><code data-x=""> . </code><code data-x="import-meta-url">url</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><var>url</var> = <code data-x="import.meta">import . meta</code><code data-x=""> . </code><code data-x="import-meta-resolve">resolve(<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>This will throw an 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> of <span
Expand Down Expand Up @@ -88336,7 +88352,35 @@ import "https://example.com/foo/../module2.mjs";</code></pre>
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>module script</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>,
« », the <span>current Realm Record</span>).</p></li>

<li><p>Perform ! <span>SetFunctionName</span>(<var>resolveFunction</var>, "<code
data-x="">resolve</code>").</p></li>

<li><p>Perform ! <span>SetFunctionLength</span>(<var>resolveFunction</var>, 1).</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>

</div>
Expand Down

0 comments on commit fa07fc6

Please sign in to comment.