Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/ns-builtin-modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,14 @@ Call it from a task context instead — a native boundary, an event handler, a
timer callback, or module evaluation itself. A **synchronous** graph needs no
pumping and stays legal from anywhere, microtask turns included.

**An `import()` started before the require settles after it.** While a
synchronous load runs (any `require()` of an ES module, pumping or not), a
module graph that an earlier `import()` is loading is not evaluated, and that
`import()`'s promise stays pending until the require returns. A graph that
awaits such a promise cannot settle in-pump: it waits out `deadlineSeconds`,
then follows `onTimeout`. An `import()` the graph starts itself, such as
`await import("./x.mjs")` in its own code, is not held back.

### What an HTTP module response must be

A module fetched over `http(s)` is classified by status and MIME type before it
Expand Down
2 changes: 2 additions & 0 deletions test-app/app/src/main/assets/app/mainpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ require('./tests/testConcurrentProxyGeneration');
require('./tests/testEsmHttpLoader');
// What import() settles with, per importer kind and specifier shape
require('./tests/testDynamicImport');
// File modules large enough to load off the JS thread
require('./tests/testFileModuleLoad');
// Node-API addon surface
require('./tests/NapiTests');
require('./tests/NapiCoverageTests');
Expand Down
10 changes: 10 additions & 0 deletions test-app/app/src/main/assets/app/tests/fileModuleImportWorker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Imports the module named by each message, reporting "loading" as soon as
// import() has returned and the module's id and line count once it settles.
onmessage = function (msg) {
import(msg.data).then(function (mod) {
postMessage("ok:" + mod.id + ":" + mod.count);
}, function (error) {
postMessage("error:" + String((error && error.message) || error));
});
postMessage("loading");
};
Loading