Permalink
Browse files

Integrate dynamic import()

Closes #2315.
  • Loading branch information...
domenic committed Sep 14, 2017
1 parent 5458513 commit d4d1704f9c0efbeed78b885d566af17545b8b5fe
Showing with 101 additions and 20 deletions.
  1. +101 −20 source
View
121 source
@@ -3027,6 +3027,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<li>The <dfn data-x-href="https://tc39.github.io/ecma262/#sec-isdetachedbuffer">IsDetachedBuffer</dfn> abstract operation</li>
<li>The <dfn data-x-href="https://tc39.github.io/ecma262/#sec-issharedarraybuffer">IsSharedArrayBuffer</dfn> abstract operation</li>
<li>The <dfn data-x="js-NewObjectEnvironment" data-x-href="https://tc39.github.io/ecma262/#sec-newobjectenvironment">NewObjectEnvironment</dfn> abstract operation</li>
<li>The <dfn data-x-href="https://tc39.github.io/ecma262/#sec-normalcompletion">NormalCompletion</dfn> abstract operation</li>
<!-- the next set of Ordinary* abstract operations are in order of appearance -->
<li>The <dfn data-x-href="https://tc39.github.io/ecma262/#sec-ordinarygetprototypeof">OrdinaryGetPrototypeOf</dfn> abstract operation</li>
<li>The <dfn data-x-href="https://tc39.github.io/ecma262/#sec-ordinarysetprototypeof">OrdinarySetPrototypeOf</dfn> abstract operation</li>
@@ -3063,14 +3064,12 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
<p>Users agents that support JavaScript must also implement the <cite>import()</cite> proposal.
The following terms are defined there, and used in this specification: <ref spec=JSIMPORT></p>
<ul>
<ul class="brief">
<li><dfn data-x-href="https://tc39.github.io/proposal-dynamic-import/#sec-import-calls"><code>import()</code></dfn></li>
<li>The <dfn data-x="js-HostImportModuleDynamically" data-x-href="https://tc39.github.io/proposal-dynamic-import/#sec-hostimportmoduledynamically">HostImportModuleDynamically</dfn> abstract operation</li>
<li>The <dfn data-x-href="https://tc39.github.io/proposal-dynamic-import/#sec-finishdynamicimport">FinishDynamicImport</dfn> abstract operation</li>
</ul>
<p class="&#x0058;&#x0058;&#x0058;">This feature is not quite integrated yet, but will be
shortly. In the meantime there are some parts of the script processing model that have been
updated to support it, which might appear pointless until that integration is complete.</p>
</dd>
@@ -87248,9 +87247,11 @@ interface <dfn>NavigatorOnLine</dfn> {
</ol>
<p>To <dfn data-export="">run a module script</dfn> given a <span>module script</span>
<var>script</var>:</p>
<var>script</var>, with an optional <var>rethrow errors</var> boolean:</p>
<ol>
<li><p>If <var>rethrow errors</var> is not given, let it be false.</p></li>
<li><p>Let <var>settings</var> be the <span>settings object</span> of <var>script</var>.</p></li>
<li><p><span>Check if we can run script</span> with <var>settings</var>. If this returns "do
@@ -87287,8 +87288,17 @@ interface <dfn>NavigatorOnLine</dfn> {
</ol>
</li>
<li><p>If <var>evaluationStatus</var> is an abrupt completion, then <span>report the
exception</span> given by <var>evaluationStatus</var>.[[Value]] for <var>script</var>.</p></li>
<li>
<p>If <var>evaluationStatus</var> is an abrupt completion, then:</p>
<ol>
<li><p>If <var>rethrow errors</var> is true, rethrow the exception given by
<var>evaluationStatus</var>.[[Value]].</p></li>
<li><p>Otherwise, <span>report the exception</span> given by
<var>evaluationStatus</var>.[[Value]] for <var>script</var>.</p></li>
</ol>
</li>
<li><p><span>Clean up after running script</span> with <var>settings</var>.</p></li>
</ol>
@@ -88045,9 +88055,9 @@ import "https://example.com/foo/../module2.js";</pre>
data-x="concept-SharedWorkerGlobalScope-constructor-url">constructor url</span>.</p>
</div>
<p>To <dfn>resolve a module specifier</dfn> given a <span>module script</span> <var>script</var>
and a string <var>specifier</var>, perform the following steps. It will return either a <span>URL
record</span> or failure.</p>
<p>To <dfn>resolve a module specifier</dfn> given a <span>script</span> <var>script</var> and a
<span>JavaScript string</span> <var>specifier</var>, perform the following steps. It will return
either a <span>URL record</span> or failure.</p>
<ol>
<li><p>Apply the <span>URL parser</span> to <var>specifier</var>. If the result is not failure,
@@ -88121,22 +88131,23 @@ import "https://example.com/foo/../module2.js";</pre>
</ul>
</div>
<h6><dfn>HostResolveImportedModule</dfn>(<var>referencingModule</var>, <var>specifier</var>)</h6>
<h6><dfn>HostResolveImportedModule</dfn>(<var>referencingScriptOrModule</var>,
<var>specifier</var>)</h6>
<p>JavaScript contains an implementation-defined <span
data-x="js-HostResolveImportedModule">HostResolveImportedModule</span> abstract operation. User
agents must use the following implementation: <ref spec=JAVASCRIPT></p>
data-x="js-HostResolveImportedModule">HostResolveImportedModule</span> abstract operation, very
slightly updated by the <cite>import()</cite> proposal. User agents must use the following
implementation: <ref spec=JAVASCRIPT> <ref spec=JSIMPORT></p>
<ol>
<li><p>Let <var>referencing module script</var> be
<var>referencingModule</var>.[[HostDefined]].</p></li>
<li><p>Let <var>referencing script</var> be
<var>referencingScriptOrModule</var>.[[HostDefined]].</p></li>
<li><p>Let <var>moduleMap</var> be <var>referencing module script</var>'s <span>settings
object</span>'s <span data-x="concept-settings-object-module-map">module map</span>.</p></li>
<li><p>Let <var>moduleMap</var> be <var>referencing script</var>'s <span>settings object</span>'s
<span data-x="concept-settings-object-module-map">module map</span>.</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>referencing module script</var> and
<var>specifier</var>.</p></li>
module specifier</span> given <var>referencing script</var> and <var>specifier</var>.</p></li>
<li><p>Assert: <var>url</var> is never failure, because <span data-x="resolve a module
specifier">resolving a module specifier</span> must have been <a
@@ -88156,6 +88167,76 @@ import "https://example.com/foo/../module2.js";</pre>
data-x="concept-script-record">record</span>.</p></li>
</ol>
<h6><dfn>HostImportModuleDynamically</dfn>(<var>referencingScriptOrModule</var>,
<var>specifier</var>, <var>promiseCapability</var>)</h6>
<p>The <cite>import()</cite> proposal contains an implementation-defined <span
data-x="js-HostImportModuleDynamically">HostImportModuleDynamically</span> abstract operation.
User agents must use the following implementation: <ref spec=JSIMPORT></p>
<ol>
<li><p>Let <var>referencing script</var> be
<var>referencingScriptOrModule</var>.[[HostDefined]].</p></li>
<li>
<p>Run the following steps <span>in parallel</span>:</p>
<ol>
<li><p>Let <var>url</var> be the result of <span data-x="resolve a module specifier">resolving a
module specifier</span> given <var>referencing script</var> and <var>specifier</var>.</p></li>
<li>
<p>If <var>url</var> is failure, then:</p>
<ol>
<li><p>Let <var>completion</var> be Completion { [[Type]]: throw, [[Value]]: a new
<code>TypeError</code>, [[Target]]: empty }.</p></li>
<li><p>Perform <span>FinishDynamicImport</span>(<var>referencingScriptOrModule</var>,
<var>specifier</var>, <var>promiseCapability</var>, <var>completion</var>).</p></li>
<li><p>Abort these steps.</p></li>
</ol>
</li>
<li><p>Let <var>options</var> be the <span>descendant script fetch options</span> for
<var>referencing script</var>'s <span data-x="concept-script-script-fetch-options">fetch
options</span>.</p></li>
<li><p><span>Fetch a module script graph</span> given <var>url</var>, <var>settings
object</var>, "<code data-x="">script</code>", and <var>options</var>. Wait until the algorithm
asynchronously completes with <var>result</var>.</p></li>
<li>
<p>If <var>result</var> is null, then:</p>
<ol>
<li><p>Let <var>completion</var> be Completion { [[Type]]: throw, [[Value]]: a new
<code>TypeError</code>, [[Target]]: empty }.</p></li>
<li><p>Perform <span>FinishDynamicImport</span>(<var>referencingScriptOrModule</var>,
<var>specifier</var>, <var>promiseCapability</var>, <var>completion</var>).</p></li>
<li><p>Abort these steps.</p></li>
</ol>
</li>
<li><p><span data-x="run a module script">Run the module script</span> <var>result</var>, with
the rethrow errors boolean set to true.</p></li>
<li><p>If running the module script throws an exception, then perform
<span>FinishDynamicImport</span>(<var>referencingScriptOrModule</var>, <var>specifier</var>,
<var>promiseCapability</var>, the thrown exception completion).</p></li>
<li><p>Otherwise, perform
<span>FinishDynamicImport</span>(<var>referencingScriptOrModule</var>, <var>specifier</var>,
<var>promiseCapability</var>, <span>NormalCompletion</span>(undefined)).</p></li>
</ol>
</li>
<li><p>Return undefined.</p></li>
</ol>
<h5>Integration with the JavaScript agent formalism</h5>
<p>JavaScript defines the concept of an <span>agent</span>. Until such a time that this standard

0 comments on commit d4d1704

Please sign in to comment.