Skip to content

Commit

Permalink
doc: update module hooks docs
Browse files Browse the repository at this point in the history
PR-URL: #49265
Backport-PR-URL: #50669
Reviewed-By: Jacob Smith <jacob@frende.me>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
GeoffreyBooth authored and targos committed Nov 23, 2023
1 parent ed2d46f commit 1ac389e
Show file tree
Hide file tree
Showing 3 changed files with 304 additions and 243 deletions.
19 changes: 12 additions & 7 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ absolute path, it's resolved as a relative path from the current working
directory. That path is then resolved by [CommonJS][] module loader. If no
corresponding file is found, an error is thrown.

If a file is found, its path will be passed to the [ECMAScript module loader][]
under any of the following conditions:
If a file is found, its path will be passed to the
[ES module loader][Modules loaders] under any of the following conditions:

* The program was started with a command-line flag that forces the entry
point to be loaded with ECMAScript module loader.
Expand All @@ -43,9 +43,9 @@ Otherwise, the file is loaded using the CommonJS module loader. See

### ECMAScript modules loader entry point caveat

When loading [ECMAScript module loader][] loads the program entry point, the `node`
command will only accept as input only files with `.js`, `.mjs`, or `.cjs`
extensions; and with `.wasm` extensions when
When loading, the [ES module loader][Modules loaders] loads the program
entry point, the `node` command will accept as input only files with `.js`,
`.mjs`, or `.cjs` extensions; and with `.wasm` extensions when
[`--experimental-wasm-modules`][] is enabled.

## Options
Expand Down Expand Up @@ -396,7 +396,11 @@ changes:
`--experimental-loader`.
-->

Specify the `module` of a custom experimental [ECMAScript module loader][].
> This flag is discouraged and may be removed in a future version of Node.js.
> Please use
> [`--import` with `register()`][module customization hooks: enabling] instead.
Specify the `module` containing exported [module customization hooks][].
`module` may be any string accepted as an [`import` specifier][].

### `--experimental-network-imports`
Expand Down Expand Up @@ -2366,8 +2370,9 @@ done
[CommonJS module]: modules.md
[CustomEvent Web API]: https://dom.spec.whatwg.org/#customevent
[ECMAScript module]: esm.md#modules-ecmascript-modules
[ECMAScript module loader]: esm.md#loaders
[Fetch API]: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
[Module customization hooks]: module.md#customization-hooks
[Module customization hooks: enabling]: module.md#enabling
[Modules loaders]: packages.md#modules-loaders
[Node.js issue tracker]: https://github.com/nodejs/node/issues
[OSSL_PROVIDER-legacy]: https://www.openssl.org/docs/man3.0/man7/OSSL_PROVIDER-legacy.html
Expand Down
2 changes: 1 addition & 1 deletion doc/api/esm.md
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,7 @@ success!
[`package.json`]: packages.md#nodejs-packagejson-field-definitions
[`process.dlopen`]: process.md#processdlopenmodule-filename-flags
[cjs-module-lexer]: https://github.com/nodejs/cjs-module-lexer/tree/1.2.2
[custom https loader]: module.md#https-loader
[custom https loader]: module.md#import-from-https
[import.meta.resolve]: #importmetaresolvespecifier
[percent-encoded]: url.md#percent-encoding-in-urls
[special scheme]: https://url.spec.whatwg.org/#special-scheme
Expand Down
Loading

0 comments on commit 1ac389e

Please sign in to comment.