Commit Graph
39038 Commits
Author SHA1 Message Date
Node.js GitHub Bot e9632454cd tools: update eslint to 8.45.0
PR-URL: https://github.com/nodejs/node/pull/48793
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2023-11-23 10:52:17 +01:00
Geoffrey Booth c3c945e654 esm: bypass CommonJS loader under --default-type
PR-URL: https://github.com/nodejs/node/pull/49986
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2023-11-23 10:52:13 +01:00
João Lenon a67fa2a107 util: add getCwdSafe internal util fn
This function was first implemented in #46826, but at some point
of the PR implementation this fn was no longer related to the PR.

Refs: https://github.com/nodejs/node/pull/46826#discussion_r1225431178
PR-URL: https://github.com/nodejs/node/pull/48434
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2023-11-23 10:52:03 +01:00
Geoffrey Booth fe691984b2 esm: unflag extensionless javascript and wasm in module scope
PR-URL: https://github.com/nodejs/node/pull/49974
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2023-11-23 10:51:52 +01:00
Geoffrey Booth 56bd9a88ac esm: --experimental-default-type flag to flip module defaults
PR-URL: https://github.com/nodejs/node/pull/49869
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Guy Bedford <guybedford@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2023-11-23 10:51:31 +01:00
Antoine du HamelandGeoffrey Booth 72644d62e7 esm: improve JSDoc annotation of internal functions
Co-authored-by: Geoffrey Booth <webadmin@geoffreybooth.com>
PR-URL: https://github.com/nodejs/node/pull/49959
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
2023-11-23 10:51:20 +01:00
Geoffrey Booth 8c55f317a3 module: move helpers out of cjs loader
PR-URL: https://github.com/nodejs/node/pull/49912
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2023-11-23 10:51:10 +01:00
Geoffrey Booth 97579895f2 module, esm: jsdoc for modules files
PR-URL: https://github.com/nodejs/node/pull/49523
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2023-11-23 10:51:02 +01:00
Geoffrey Booth 957725f601 esm: require braces for modules code
PR-URL: https://github.com/nodejs/node/pull/49657
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
2023-11-23 10:50:35 +01:00
Yagiz Nizipli fe26f8a860 lib: merge cjs and esm package json reader caches
PR-URL: https://github.com/nodejs/node/pull/48477
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2023-11-23 10:50:24 +01:00
Antoine du Hamel c12685f82d esm: fix cache collision on JSON files using file: URL
PR-URL: https://github.com/nodejs/node/pull/49887
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Fixes: https://github.com/nodejs/node/issues/49724
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
2023-11-23 10:50:11 +01:00
Jacob Smith ed8dd33493 esm: identify parent importing a url with invalid host
PR-URL: https://github.com/nodejs/node/pull/49736
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
2023-11-23 10:50:01 +01:00
Antoine du Hamel 73a7e00d06 doc: add missing history info for import.meta.resolve
PR-URL: https://github.com/nodejs/node/pull/49700
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Jacob Smith <jacob@frende.me>
2023-11-23 10:49:51 +01:00
Antoine du Hamel 46d730ab75 esm: fix return type of import.meta.resolve
PR-URL: https://github.com/nodejs/node/pull/49698
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Fixes: https://github.com/nodejs/node/issues/49695
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
2023-11-23 10:49:43 +01:00
Geoffrey Booth 12cb700478 esm: update loaders warning
PR-URL: https://github.com/nodejs/node/pull/49633
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
2023-11-23 10:49:35 +01:00
Antoine du Hamel 47193a347e esm: fix support for URL instances in register
PR-URL: https://github.com/nodejs/node/pull/49655
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2023-11-23 10:49:23 +01:00
Daniel Compton 51ced0f1a1 esm: clarify ERR_REQUIRE_ESM errors
In #39175, better ESM errors were introduced. This commit tweaks the
language in the error slightly to make it clear that there are three
different options to resolve the error.

Refs: https://github.com/nodejs/node/pull/39175
PR-URL: https://github.com/nodejs/node/pull/49521
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
2023-11-23 10:49:12 +01:00
Antoine du Hamel 866d646b0e test: increase coverage of Module.register and initialize hook
PR-URL: https://github.com/nodejs/node/pull/49532
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2023-11-23 10:49:02 +01:00
Geoffrey Booth 65201ab36b test: isolate globalPreload tests
PR-URL: https://github.com/nodejs/node/pull/49545
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
2023-11-23 10:48:51 +01:00
Antoine du Hamel 945609487c typings: fix missing property in ExportedHooks
PR-URL: https://github.com/nodejs/node/pull/49567
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
2023-11-23 10:48:39 +01:00
Antoine du Hamel 4be5612bae esm: remove return value for Module.register
The current API shape si not great because it's too limited and
redundant with the use of `MessagePort`.

PR-URL: https://github.com/nodejs/node/pull/49529
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
2023-11-23 10:48:30 +01:00
Geoffrey Booth 0875867e27 esm: refactor test-esm-loader-resolve-type
PR-URL: https://github.com/nodejs/node/pull/49493
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2023-11-23 10:48:19 +01:00
Geoffrey Booth 9b7c9d93e9 esm: refactor test-esm-named-exports
PR-URL: https://github.com/nodejs/node/pull/49493
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2023-11-23 10:48:10 +01:00
Livia Medeiros 65058d9a35 test: add tmpdir.fileURL()
PR-URL: https://github.com/nodejs/node/pull/49040
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2023-11-23 10:47:54 +01:00
Antoine du Hamel c20fdb4e52 doc: edit import.meta.resolve documentation
PR-URL: https://github.com/nodejs/node/pull/49247
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Refs: https://github.com/nodejs/node/pull/49028
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Guy Bedford <guybedford@gmail.com>
2023-11-23 10:47:43 +01:00
Geoffrey Booth 1ac389ecef doc: update module hooks docs
PR-URL: https://github.com/nodejs/node/pull/49265
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2023-11-23 10:47:34 +01:00
Geoffrey Booth ed2d46f4cc doc: move and rename loaders section
PR-URL: https://github.com/nodejs/node/pull/49261
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2023-11-23 10:47:22 +01:00
Geoffrey Booth d1f5514917 esm: refactor mocking test
PR-URL: https://github.com/nodejs/node/pull/49465
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2023-11-23 10:47:12 +01:00
Geoffrey Booth 258df0e72d doc: add signature for module.register
PR-URL: https://github.com/nodejs/node/pull/49251
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2023-11-23 10:47:02 +01:00
Antoine du Hamel e1c6f46926 test: reduce flakiness of test-esm-loader-hooks
PR-URL: https://github.com/nodejs/node/pull/49248
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
2023-11-23 10:46:52 +01:00
Jacob Smith 58eaf3f6ae doc: caveat unavailability of import.meta.resolve in custom loaders
PR-URL: https://github.com/nodejs/node/pull/49242
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
2023-11-23 10:46:42 +01:00
Antoine du Hamel e8d475ffc4 test: refactor test-esm-loader-hooks for easier debugging
- Always check stderr before stdout as the former would contain error
  information.
- Always match the full stdout to avoid surprises.
- Use `deepStrictEqual` when appropriate to get more informative test
  failures.
- Remove leading slashes from relative paths/URLs to not confuse them
  with absolute paths.
- Remove unnecessary `--no-warnings` flag.

PR-URL: https://github.com/nodejs/node/pull/49131
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
2023-11-23 10:46:32 +01:00
Antoine du Hamel 2fef28b2b9 doc: fix name of the flag in initialize() docs
PR-URL: https://github.com/nodejs/node/pull/49158
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2023-11-23 10:46:22 +01:00
Antoine du Hamel 01ca6d277d esm: fix globalPreload warning
PR-URL: https://github.com/nodejs/node/pull/49069
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Fixes: https://github.com/nodejs/node/issues/49026
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Jacob Smith <jacob@frende.me>
2023-11-23 10:46:11 +01:00
Guy Bedford c1a84398b4 esm: unflag import.meta.resolve
PR-URL: https://github.com/nodejs/node/pull/49028
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
2023-11-23 10:46:00 +01:00
Guy Bedford ef43f084e9 esm: import.meta.resolve exact module not found errors should return
PR-URL: https://github.com/nodejs/node/pull/49038
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Jan Krems <jan.krems@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
2023-11-23 10:45:47 +01:00
Antoine du Hamel 26f01669fc test: reduce flakiness of test-esm-loader-hooks
PR-URL: https://github.com/nodejs/node/pull/49105
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
2023-11-23 10:45:35 +01:00
Antoine du Hamel 385f24c9cc esm: protect ERR_UNSUPPORTED_DIR_IMPORT against prototype pollution
PR-URL: https://github.com/nodejs/node/pull/49060
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
2023-11-23 10:45:17 +01:00
Antoine du Hamel d5a1153970 test: use fixtures.fileURL when appropriate
PR-URL: https://github.com/nodejs/node/pull/48990
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2023-11-23 10:45:07 +01:00
Izaak Schroeder 10e7c3a376 esm: add initialize hook, integrate with register
Follows @giltayar's proposed API:

> `register` can pass any data it wants to the loader, which will be
passed to the exported `initialize` function of the loader.
Additionally, if the user of `register` wants to communicate with the
loader, it can just create a `MessageChannel` and pass the port to the
loader as data.

The `register` API is now:

```ts
interface Options {
  parentUrl?: string;
  data?: any;
  transferList?: any[];
}

function register(loader: string, parentUrl?: string): any;
function register(loader: string, options?: Options): any;
```

This API is backwards compatible with the old one (new arguments are
optional and at the end) and allows for passing data into the new
`initialize` hook. If this hook returns data it is passed back to
`register`:

```ts
function initialize(data: any): Promise<any>;
```

**NOTE**: Currently there is no mechanism for a loader to exchange
ownership of something back to the caller.

Refs: https://github.com/nodejs/loaders/issues/147
PR-URL: https://github.com/nodejs/node/pull/48842
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
2023-11-23 10:44:54 +01:00
Antoine du Hamel f96b610268 esm: fix typo parentUrl -> parentURL
PR-URL: https://github.com/nodejs/node/pull/48999
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
2023-11-23 10:44:42 +01:00
Antoine du Hamel 3424793013 test: fix snapshot tests when cwd contains spaces or backslashes
Both are valid characters for file names on non-Windows systems.

PR-URL: https://github.com/nodejs/node/pull/48959
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2023-11-23 10:44:33 +01:00
Antoine du Hamel a9347a4635 test: order common.mjs in ASCII order
PR-URL: https://github.com/nodejs/node/pull/48960
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2023-11-23 10:44:23 +01:00
Antoine du Hamel adb9280d8e test: fix some assumptions in tests
Some tests are assuming they will be run from a directory that do not
contain any quote or special character in its path. That assumption is
not necessary, using `JSON.stringify` or `pathToFileURL` ensures the
test can be run whatever the path looks like.

PR-URL: https://github.com/nodejs/node/pull/48958
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
2023-11-23 10:44:13 +01:00
LiviaMedeiros 48c25b154b fs: make mkdtemp accept buffers and URL
PR-URL: https://github.com/nodejs/node/pull/48828
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2023-11-23 10:44:04 +01:00
Antoine du Hamel f02637e805 test: fix es-module/test-esm-initialization
PR-URL: https://github.com/nodejs/node/pull/48880
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2023-11-23 10:43:53 +01:00
Antoine du Hamel 14e148ee6c module: ensure successful import returns the same result
PR-URL: https://github.com/nodejs/node/pull/46662
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
2023-11-23 10:43:44 +01:00
Izaak Schroeder 03c1b5e647 esm: unflag Module.register and allow nested loader import()
Major functional changes:

- Allow `import()` to work within loaders that require other loaders,
- Unflag the use of `Module.register`.

A new interface `Customizations` has been created in order to unify
`ModuleLoader` (previously `DefaultModuleLoader`), `Hooks` and
`CustomizedModuleLoader` all of which now implement it:

```ts
interface LoadResult {
  format: ModuleFormat;
  source: ModuleSource;
}

interface ResolveResult {
  format: string;
  url: URL['href'];
}

interface Customizations {
  allowImportMetaResolve: boolean;
  load(url: string, context: object): Promise<LoadResult>
  resolve(
    originalSpecifier:
    string, parentURL: string,
    importAssertions: Record<string, string>
  ): Promise<ResolveResult>
  resolveSync(
    originalSpecifier:
    string, parentURL: string,
    importAssertions: Record<string, string>
  ) ResolveResult;
  register(specifier: string, parentUrl: string): any;
  forceLoadHooks(): void;
  importMetaInitialize(meta, context, loader): void;
}
```

The `ModuleLoader` class now has `setCustomizations` which takes an
object of this shape and delegates its responsibilities to this object
if present.

Note that two properties `allowImportMetaResolve` and `resolveSync`
exist now as a mechanism for `import.meta.resolve` – since `Hooks`
does not implement `resolveSync` other loaders cannot use
`import.meta.resolve`; `allowImportMetaResolve` is a way of checking
for that case instead of invoking `resolveSync` and erroring.

Fixes https://github.com/nodejs/node/issues/48515
Closes https://github.com/nodejs/node/pull/48439

PR-URL: https://github.com/nodejs/node/pull/48559
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
2023-11-23 10:43:33 +01:00
Antoine du Hamel 63aa5d7270 esm: add back globalPreload tests and fix failing ones
PR-URL: https://github.com/nodejs/node/pull/48779
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Fixes: https://github.com/nodejs/node/issues/48778
Fixes: https://github.com/nodejs/node/issues/48516
Refs: https://github.com/nodejs/node/pull/46402
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Jacob Smith <jacob@frende.me>
2023-11-23 10:43:20 +01:00
João Lenon 65dfe85f03 module: implement register utility
PR-URL: https://github.com/nodejs/node/pull/46826
Backport-PR-URL: https://github.com/nodejs/node/pull/50669
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2023-11-23 10:43:08 +01:00