From 589fa3c4fb2ac67fbec210b5cea1f1102c0fdd2c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?=
Date: Sun, 17 Jul 2022 11:54:58 +0200
Subject: [PATCH 1/6] Unset the top-level module fetch flag in dynamic imports
The the top-level module fetch is only used in two steps of "fetch a
single module script":
- Step 9, where it only has effect if descrination is "worker",
"sharedworker" or "serviceworker" (but for dynamic imports it's always
"script")
- Step 11, where it only has effect if there are custom "perform the
fetch" steps, but "fetch an import() module script graph" is never
called with custom "perform the fetch" steps.
---
source | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/source b/source
index d19f245ffd9..8b2480bb4fa 100644
--- a/source
+++ b/source
@@ -95855,10 +95855,11 @@ document.querySelector("button").addEventListener("click", bound);
sequence containing the response body. isTopLevel will be true for all classic
script fetches, and for the initial fetch when fetching an external module script graph, fetching a module worker script graph, or fetching an import() module script graph, but false for the fetches
- resulting from import statements encountered throughout the graph.
+ script graph">fetching an external module script graph, or fetching a module worker script graph, but false for the fetches
+ resulting from import statements encountered throughout the graph or from
+ fetching an import() module script
+ graph.
By default, not supplying a perform the fetch
hook will cause the below algorithms to simply fetch
@@ -96182,7 +96183,7 @@ document.querySelector("button").addEventListener("click", bound);
Fetch a single module script given url, settings
object, "script", options, settings object,
- "client", moduleRequest, true, and with the following steps
+ "client", moduleRequest, false, and with the following steps
given result:
From 7e80f33bd8db59be2f5cecbc71bcbf95b1018fa9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?=
Date: Sun, 17 Jul 2022 12:55:48 +0200
Subject: [PATCH 2/6] Implement `HostLoadImportedModule` hook
* Implement `HostLoadImportedModule` hook. This commit also removes the
`HostImportModuleDynamically` and `HostResolveImportedModule` hooks.
* Differentiate fetch referrer between static and dynamic imports
* Propagate custom perform the fetch steps through LoadRequestedModules
* Review by annevk
* Review by domenic
---
source | 622 ++++++++++++++++++---------------------------------------
1 file changed, 192 insertions(+), 430 deletions(-)
diff --git a/source b/source
index 8b2480bb4fa..0e2463416b3 100644
--- a/source
+++ b/source
@@ -2755,6 +2755,7 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
The HostEnsureCanAddPrivateElement abstract operation
The HostEnsureCanCompileStrings abstract operation
-
The HostImportModuleDynamically abstract operation
+
The HostLoadImportedModule abstract operation
The HostMakeJobCallback abstract operation
The HostPromiseRejectionTracker abstract operation
-
The HostResolveImportedModule abstract operation
The InitializeHostDefinedRealm abstract operation
The IsAccessorDescriptor abstract operation
The IsCallable abstract operation
@@ -95858,8 +95860,7 @@ document.querySelector("button").addEventListener("click", bound);
script graph">fetching an external module script graph, or fetching a module worker script graph, but false for the fetches
resulting from import statements encountered throughout the graph or from
- fetching an import() module script
- graph.
+ import() expressions.
By default, not supplying a perform the fetch
hook will cause the below algorithms to simply fetch
@@ -96143,58 +96144,9 @@ document.querySelector("button").addEventListener("click", bound);
If result is null, run onComplete given null, and abort these
steps.
-
Let visited set be « (url, "javascript")
- ».
-
Fetch the descendants of
and linkresult given settings object, "script", visited set, and onComplete.
-
-
-
-
-
To fetch an import() module script graph given a moduleRequest, a
- script, a settings object, some options, and an
- onComplete algorithm, run these steps. onComplete must be an algorithm
- accepting null (on failure) or a module script (on success).
-
-
-
Disallow further import maps given settings object.
-
-
Let url be the result of resolving a
- module specifier given script and moduleRequest.[[Specifier]],
- catching any exceptions.
-
-
If the previous step threw an exception, then run onComplete given null, and
- return.
-
-
Assert: moduleRequest.[[Assertions]] does not contain any
- Recordentry such that entry.[[Key]] is not "type", because we only asked for "type" assertions in
- HostGetSupportedImportAssertions.
-
-
Let moduleType be the result of running the module type from module
- request steps given moduleRequest.
-
-
If the result of running the module type allowed steps given
- moduleType and settings object is false, then run onComplete
- given null, and return.
-
-
-
Fetch a single module script given url, settings
- object, "script", options, settings object,
- "client", moduleRequest, false, and with the following steps
- given result:
-
-
-
If result is null, run onComplete with null, and abort these
- steps.
-
-
Let visited set be « (url, moduleType) ».
-
-
Fetch the descendants
- of and linkresult given settings object, destination,
- visited set, and onComplete.
If result is not null, optionally perform the following steps:
+
If result is not null, optionally fetch the descendants of and linkresult given
+ settings object, destination, and an empty algorithm.
-
-
Let visited set be « (url, "javascript")
- ».
-
-
Fetch the
- descendants of and linkresult given settings object,
- destination, visited set, and with an empty algorithm.
-
-
-
Generally, performing these steps will be beneficial for performance, as it
+
Generally, performing this step will be beneficial for performance, as it
allows pre-loading the modules that will invariably be requested later, via algorithms such as
fetch an external module script graph that fetch the entire graph. However, user
agents might wish to skip them in bandwidth-constrained situations, or situations where the
@@ -96252,12 +96197,9 @@ document.querySelector("button").addEventListener("click", bound);
If script is null, run onComplete given null, and return.
-
Let visited set be an empty set.
-
-
Fetch the
- descendants of and linkscript, given settings object, the
- destination "script", visited set, and
- onComplete.
+
Fetch the descendants of
+ and linkscript, given settings object, the destination "script", and onComplete.
To fetch a module worker script graph
@@ -96327,7 +96269,7 @@ document.querySelector("button").addEventListener("click", bound);
This diagram illustrates how these algorithms relate to the ones above, as well as to each
other: