Files
node/doc/api
Izaak Schroeder 0a4f7c669a 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
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
2023-08-15 14:34:00 -03:00
..
2023-05-12 11:57:05 +02:00
2023-07-18 13:45:29 -05:00
2023-07-18 13:45:29 -05:00
2023-05-02 09:34:04 +02:00
2023-05-03 08:57:36 +02:00
2023-01-14 14:25:08 +00:00
2023-05-02 09:34:04 +02:00
2023-08-15 14:33:58 -03:00
2023-07-18 13:45:29 -05:00
2023-07-04 19:18:25 -03:00
2023-07-04 19:18:25 -03:00
2023-08-15 14:33:59 -03:00
2022-06-30 09:34:10 -04:00
2023-08-15 14:33:58 -03:00
2023-08-15 14:34:00 -03:00
2023-07-18 13:45:29 -05:00
2023-07-18 12:35:54 -05:00
2023-07-18 13:45:29 -05:00
2023-07-04 19:18:25 -03:00
2022-11-01 04:21:13 +00:00
2023-05-30 11:36:18 +02:00
2023-05-15 16:59:31 +02:00
2023-05-02 09:34:04 +02:00