[v18.x] Backport most ESM and customization hook changes
List of commits backported in this PR (in reverse order):
- [a71e3a65] - test: fix edge snapshot stack traces (Geoffrey Booth) https://github.com/nodejs/node/pull/49659
- [3af7cfe7] - test: refactor
test-node-output-errors
(Antoine du Hamel) https://github.com/nodejs/node/pull/48992 - [8f7eb156] - (SEMVER-MINOR) vm: use import attributes instead of import assertions (Antoine du Hamel) https://github.com/nodejs/node/pull/50141
- [317e447d] - test: deflake
test-loaders-workers-spawned
(Antoine du Hamel) https://github.com/nodejs/node/pull/50251 - [19d3ce24] - test: deflake
test-esm-loader-resolve-type
(Antoine du Hamel) https://github.com/nodejs/node/pull/50273 - [d1ef6aa2] - esm: use import attributes instead of import assertions (Antoine du Hamel) https://github.com/nodejs/node/pull/50140
- [69fb55e6] - tools: update eslint to 8.51.0 (Node.js GitHub Bot) https://github.com/nodejs/node/pull/50084
- [581434e5] - tools: update eslint to 8.50.0 (Node.js GitHub Bot) https://github.com/nodejs/node/pull/49989
- [e4d1259e] - tools: update eslint to 8.49.0 (Node.js GitHub Bot) https://github.com/nodejs/node/pull/49586
- [7104a715] - tools: update eslint to 8.48.0 (Node.js GitHub Bot) https://github.com/nodejs/node/pull/49343
- [a3b25ebc] - tools: update eslint to 8.47.0 (Node.js GitHub Bot) https://github.com/nodejs/node/pull/49124
- [d396a041] - tools: update eslint to 8.46.0 (Node.js GitHub Bot) https://github.com/nodejs/node/pull/48966
- [8f7c4e9c] - tools: update eslint to 8.45.0 (Node.js GitHub Bot) https://github.com/nodejs/node/pull/48793
- [19b470f8] - esm: bypass CommonJS loader under --default-type (Geoffrey Booth) https://github.com/nodejs/node/pull/49986
- [c2cd7445] - util: add
getCwdSafe
internal util fn (João Lenon) https://github.com/nodejs/node/pull/48434 - [9c683204] - esm: unflag extensionless javascript and wasm in module scope (Geoffrey Booth) https://github.com/nodejs/node/pull/49974
- [85301803] - esm: --experimental-default-type flag to flip module defaults (Geoffrey Booth) https://github.com/nodejs/node/pull/49869
- [aadfea49] - esm: improve JSDoc annotation of internal functions (Antoine du Hamel) https://github.com/nodejs/node/pull/49959
- [51f4ff24] - module: move helpers out of cjs loader (Geoffrey Booth) https://github.com/nodejs/node/pull/49912
- [7517c9f9] - module, esm: jsdoc for modules files (Geoffrey Booth) https://github.com/nodejs/node/pull/49523
- [f42a1039] - esm: require braces for modules code (Geoffrey Booth) https://github.com/nodejs/node/pull/49657
- [951da528] - lib: merge cjs and esm package json reader caches (Yagiz Nizipli) https://github.com/nodejs/node/pull/48477
- [7f0e36af] - esm: fix cache collision on JSON files using file: URL (Antoine du Hamel) https://github.com/nodejs/node/pull/49887
- [645b788b] - esm: identify parent importing a url with invalid host (Jacob Smith) https://github.com/nodejs/node/pull/49736
- [fd140632] - doc: add missing history info for
import.meta.resolve
(Antoine du Hamel) https://github.com/nodejs/node/pull/49700 - [20b996dc] - esm: fix return type of
import.meta.resolve
(Antoine du Hamel) https://github.com/nodejs/node/pull/49698 - [f91b4e2b] - esm: update loaders warning (Geoffrey Booth) https://github.com/nodejs/node/pull/49633
- [56ecf292] - esm: fix support for
URL
instances inregister
(Antoine du Hamel) https://github.com/nodejs/node/pull/49655 - [6a489df7] - esm: clarify ERR_REQUIRE_ESM errors (Daniel Compton) https://github.com/nodejs/node/pull/49521
- [c159b90b] - test: increase coverage of
Module.register
andinitialize
hook (Antoine du Hamel) https://github.com/nodejs/node/pull/49532 - [479a50c7] - test: isolate
globalPreload
tests (Geoffrey Booth) https://github.com/nodejs/node/pull/49545 - [5bb0cb26] - typings: fix missing property in
ExportedHooks
(Antoine du Hamel) https://github.com/nodejs/node/pull/49567 - [b64c3ee6] - esm: remove return value for
Module.register
(Antoine du Hamel) https://github.com/nodejs/node/pull/49529 - [63c3846d] - esm: refactor test-esm-loader-resolve-type (Geoffrey Booth) https://github.com/nodejs/node/pull/49493
- [a927adef] - esm: refactor test-esm-named-exports (Geoffrey Booth) https://github.com/nodejs/node/pull/49493
- [7bbcb292] - test: add
tmpdir.fileURL()
(LiviaMedeiros) https://github.com/nodejs/node/pull/49040 - [e11c7b75] - doc: edit
import.meta.resolve
documentation (Antoine du Hamel) https://github.com/nodejs/node/pull/49247 - [33710e7e] - doc: update module hooks docs (Geoffrey Booth) https://github.com/nodejs/node/pull/49265
- [164c57d4] - doc: move and rename loaders section (Geoffrey Booth) https://github.com/nodejs/node/pull/49261
- [6a5394ea] - esm: refactor mocking test (Geoffrey Booth) https://github.com/nodejs/node/pull/49465
- [484ad833] - doc: add signature for
module.register
(Geoffrey Booth) https://github.com/nodejs/node/pull/49251 - [0daea967] - test: reduce flakiness of
test-esm-loader-hooks
(Antoine du Hamel) https://github.com/nodejs/node/pull/49248 - [41a3a1da] - doc: caveat unavailability of
import.meta.resolve
in custom loaders (Jacob Smith) https://github.com/nodejs/node/pull/49242 - [1aeb48c9] - test: refactor
test-esm-loader-hooks
for easier debugging (Antoine du Hamel) https://github.com/nodejs/node/pull/49131 - [52b3007f] - doc: fix name of the flag in
initialize()
docs (Antoine du Hamel) https://github.com/nodejs/node/pull/49158 - [b5da2f4d] - esm: fix
globalPreload
warning (Antoine du Hamel) https://github.com/nodejs/node/pull/49069 - [ee8b7f1f] - esm: unflag import.meta.resolve (Guy Bedford) https://github.com/nodejs/node/pull/49028
- [569267d0] - esm: import.meta.resolve exact module not found errors should return (Guy Bedford) https://github.com/nodejs/node/pull/49038
- [e68e359a] - test: reduce flakiness of
test-esm-loader-hooks
(Antoine du Hamel) https://github.com/nodejs/node/pull/49105 - [6aafb6fb] - esm: protect
ERR_UNSUPPORTED_DIR_IMPORT
against prototype pollution (Antoine du Hamel) https://github.com/nodejs/node/pull/49060 - [a061781d] - test: use
fixtures.fileURL
when appropriate (Antoine du Hamel) https://github.com/nodejs/node/pull/48990 - [6ad83183] - esm: add
initialize
hook, integrate withregister
(Izaak Schroeder) https://github.com/nodejs/node/pull/48842 - [5c655651] - esm: fix typo
parentUrl
->parentURL
(Antoine du Hamel) https://github.com/nodejs/node/pull/48999 - [217abd47] - test: fix snapshot tests when cwd contains spaces or backslashes (Antoine du Hamel) https://github.com/nodejs/node/pull/48959
- [97ca9a89] - test: order
common.mjs
in ASCII order (Antoine du Hamel) https://github.com/nodejs/node/pull/48960 - [384f5d44] - test: fix some assumptions in tests (Antoine du Hamel) https://github.com/nodejs/node/pull/48958
- [6bef80a5] - fs: make mkdtemp accept buffers and URL (LiviaMedeiros) https://github.com/nodejs/node/pull/48828
- [42b5711d] - test: fix
es-module/test-esm-initialization
(Antoine du Hamel) https://github.com/nodejs/node/pull/48880 - [053511f7] - module: ensure successful import returns the same result (Antoine du Hamel) https://github.com/nodejs/node/pull/46662
- [a2fc4a38] - esm: unflag
Module.register
and allow nested loaderimport()
(Izaak Schroeder) https://github.com/nodejs/node/pull/48559 - [16b8c71a] - esm: add back
globalPreload
tests and fix failing ones (Antoine du Hamel) https://github.com/nodejs/node/pull/48779 - [a40a6c89] - module: implement
register
utility (João Lenon) https://github.com/nodejs/node/pull/46826 - [d2d4a310] - typings: fix JSDoc in ESM loader modules (Antoine du Hamel) https://github.com/nodejs/node/pull/48424
- [9f3466bc] - esm: remove support for arrays in
import
internal method (Antoine du Hamel) https://github.com/nodejs/node/pull/48296 - [fa1c7321] - esm: handle
globalPreload
hook returning a nullish value (Antoine du Hamel) https://github.com/nodejs/node/pull/48249 - [d28f1f11] - esm: handle more error types thrown from the loader thread (Antoine du Hamel) https://github.com/nodejs/node/pull/48247
- [cdd20cfd] - esm: do not use
'beforeExit'
on the main thread (Antoine du Hamel) https://github.com/nodejs/node/pull/47964 - [d6c0b81f] - esm: rename
URLCanParse
to be consistent (Antoine du Hamel) https://github.com/nodejs/node/pull/47668 - [f14d2e5a] - loader: use default loader as cascaded loader in the in loader worker (Joyee Cheung) https://github.com/nodejs/node/pull/47620
- [7dd37324] - esm: remove support for deprecated hooks (Antoine du Hamel) https://github.com/nodejs/node/pull/47580
- [ee08c701] - esm: initialize
import.meta
on eval (Antoine du Hamel) https://github.com/nodejs/node/pull/47551 - [2e0152cc] - esm: propagate
process.exit
from the loader thread to the main thread (Antoine du Hamel) https://github.com/nodejs/node/pull/47548 - [17570c0a] - esm: avoid try/catch when validating urls (Yagiz Nizipli) https://github.com/nodejs/node/pull/47541
- [4667b07c] - esm: move hook execution to separate thread (Jacob Smith) https://github.com/nodejs/node/pull/44710
/cc @nodejs/loaders