Skip to content

Commit a0adc6a

Browse files
joyeecheungaduh95
authored andcommitted
doc: reorganize docs of module customization hooks
This reorganizes the documentation of module customization hooks to promote the synchronous variant as it has fewer caveats. Previously the documentation was organized as follows: To do something: 1. For asynchronous hooks, do this, which may have these caveats 2. For synchronous hooks, do this, which does not have the caveats To do something else: 1. For asynchronous hooks, do this, which may have these caveats 2. For synchronous hooks, do this, which does not have the caveats It's now organized as follows: Synchronous hooks: To do something, do this. To do something else, do this. (No mention that it doesn't have caveats, because users are not supposed to burden themselves with caveats in the other API that they do not use). Asynchronous hooks: They have these caveats, if they are too complex to deal with, consider use the synchronous variant. To do something, do this, which may have these caveats. To do something, do this, which may have these caveats. PR-URL: #60960 Refs: #56241 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
1 parent 2cf963d commit a0adc6a

File tree

2 files changed

+505
-335
lines changed

2 files changed

+505
-335
lines changed

doc/api/cli.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,9 +1106,9 @@ changes:
11061106

11071107
> This flag is discouraged and may be removed in a future version of Node.js.
11081108
> Please use
1109-
> [`--import` with `register()`][module customization hooks: enabling] instead.
1109+
> [`--import` with `register()`][preloading asynchronous module customization hooks] instead.
11101110
1111-
Specify the `module` containing exported [module customization hooks][].
1111+
Specify the `module` containing exported [asynchronous module customization hooks][].
11121112
`module` may be any string accepted as an [`import` specifier][].
11131113

11141114
This feature requires `--allow-worker` if used with the [Permission Model][].
@@ -4030,8 +4030,6 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
40304030
[ExperimentalWarning: `vm.measureMemory` is an experimental feature]: vm.md#vmmeasurememoryoptions
40314031
[File System Permissions]: permissions.md#file-system-permissions
40324032
[Loading ECMAScript modules using `require()`]: modules.md#loading-ecmascript-modules-using-require
4033-
[Module customization hooks]: module.md#customization-hooks
4034-
[Module customization hooks: enabling]: module.md#enabling
40354033
[Module resolution and loading]: packages.md#module-resolution-and-loading
40364034
[Navigator API]: globals.md#navigator
40374035
[Node.js issue tracker]: https://github.com/nodejs/node/issues
@@ -4094,6 +4092,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
40944092
[`v8.startupSnapshot.addDeserializeCallback()`]: v8.md#v8startupsnapshotadddeserializecallbackcallback-data
40954093
[`v8.startupSnapshot.setDeserializeMainFunction()`]: v8.md#v8startupsnapshotsetdeserializemainfunctioncallback-data
40964094
[`v8.startupSnapshot` API]: v8.md#startup-snapshot-api
4095+
[asynchronous module customization hooks]: module.md#asynchronous-customization-hooks
40974096
[captured by the built-in snapshot of Node.js]: https://github.com/nodejs/node/blob/b19525a33cc84033af4addd0f80acd4dc33ce0cf/test/parallel/test-bootstrap-modules.js#L24
40984097
[collecting code coverage from tests]: test.md#collecting-code-coverage
40994098
[conditional exports]: packages.md#conditional-exports
@@ -4108,6 +4107,7 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
41084107
[jitless]: https://v8.dev/blog/jitless
41094108
[libuv threadpool documentation]: https://docs.libuv.org/en/latest/threadpool.html
41104109
[module compile cache]: module.md#module-compile-cache
4110+
[preloading asynchronous module customization hooks]: module.md#registration-of-asynchronous-customization-hooks
41114111
[remote code execution]: https://www.owasp.org/index.php/Code_Injection
41124112
[running tests from the command line]: test.md#running-tests-from-the-command-line
41134113
[scavenge garbage collector]: https://v8.dev/blog/orinoco-parallel-scavenger

0 commit comments

Comments
 (0)