@@ -283,9 +283,9 @@ were registered. The same applies to all the other hooks.
283
283
### Communication between main and hooks threads
284
284
285
285
Module customization hooks run on a dedicated thread, separate from the main
286
- thread that runs application code. This means that global variables are unique
287
- to each thread, and message channels must be used to communicate between the
288
- threads.
286
+ thread that runs application code. This means mutating global variables won't
287
+ affect the other thread(s) , and message channels must be used to communicate
288
+ between the threads.
289
289
290
290
The ` register` method can be used to pass data to an [` initialize` ][] hook on
291
291
the hooks thread. The data passed to the hook may include transferrable objects
@@ -388,7 +388,7 @@ This hook can send and receive data from a [`register`][] invocation, including
388
388
ports and other transferrable objects. The return value of ` initialize` must be
389
389
either:
390
390
391
- * ` undefined` or ` void ` ,
391
+ * ` undefined` ,
392
392
* something that can be posted as a message between threads (e.g. the input to
393
393
[` port.postMessage` ][]),
394
394
* a ` Promise` resolving to one of the aforementioned values.
@@ -420,7 +420,7 @@ port1.on('message', (msg) => {
420
420
assert .strictEqual (msg, ' increment: 2' );
421
421
});
422
422
423
- const result = register (' /path-to-my-hooks.js' , {
423
+ const result = register (' . /path-to-my-hooks.js' , {
424
424
parentURL: import .meta.url,
425
425
data: { number: 1 , port: port2 },
426
426
transferList: [port2],
@@ -444,7 +444,7 @@ port1.on('message', (msg) => {
444
444
assert .strictEqual (msg, ' increment: 2' );
445
445
});
446
446
447
- const result = register (' /path-to-my-hooks.js' , {
447
+ const result = register (' . /path-to-my-hooks.js' , {
448
448
parentURL: pathToFileURL (__filename ),
449
449
data: { number: 1 , port: port2 },
450
450
transferList: [port2],
@@ -608,10 +608,11 @@ loader with registered `resolve` and `load` hooks; all `require.resolve` calls
608
608
from this module will be processed by the ESM loader with registered ` resolve`
609
609
hooks; ` require .extensions ` and monkey-patching on the CommonJS module loader
610
610
will not apply. (In other words, handled ` require` calls will behave similarly
611
- to an ` import ` of a CommonJS module.) If ` source` is undefined or ` null` , it
612
- will be handled by the CommonJS module loader and ` require` /` require.resolve`
613
- calls will not go through the registered hooks. This behavior for nullish
614
- ` source` is temporary — in the future, nullish ` source` will not be supported.
611
+ to an ` import ` of a CommonJS module, other than ` require` being sync.) If
612
+ ` source` is undefined or ` null` , it will be handled by the CommonJS module
613
+ loader and ` require` /` require.resolve` calls will not go through the registered
614
+ hooks. This behavior for nullish ` source` is temporary — in the future, nullish
615
+ ` source` will not be supported.
615
616
616
617
The Node.js internal ` load` implementation, which is the value of ` next` for the
617
618
last hook in the ` load` chain, returns ` null` for ` source` when ` format` is
0 commit comments