Skip to content

Commit db0551a

Browse files
committed
@aduh95 notes
1 parent e9ed963 commit db0551a

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

doc/api/cli.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ Otherwise, the file is loaded using the CommonJS module loader. See
4444

4545
### ECMAScript modules loader entry point caveat
4646

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

5252
## Options

doc/api/module.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,9 @@ were registered. The same applies to all the other hooks.
283283
### Communication between main and hooks threads
284284
285285
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.
289289
290290
The `register` method can be used to pass data to an [`initialize`][] hook on
291291
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
388388
ports and other transferrable objects. The return value of `initialize` must be
389389
either:
390390
391-
* `undefined` or `void`,
391+
* `undefined`,
392392
* something that can be posted as a message between threads (e.g. the input to
393393
[`port.postMessage`][]),
394394
* a `Promise` resolving to one of the aforementioned values.
@@ -420,7 +420,7 @@ port1.on('message', (msg) => {
420420
assert.strictEqual(msg, 'increment: 2');
421421
});
422422

423-
const result = register('/path-to-my-hooks.js', {
423+
const result = register('./path-to-my-hooks.js', {
424424
parentURL: import.meta.url,
425425
data: { number: 1, port: port2 },
426426
transferList: [port2],
@@ -444,7 +444,7 @@ port1.on('message', (msg) => {
444444
assert.strictEqual(msg, 'increment: 2');
445445
});
446446

447-
const result = register('/path-to-my-hooks.js', {
447+
const result = register('./path-to-my-hooks.js', {
448448
parentURL: pathToFileURL(__filename),
449449
data: { number: 1, port: port2 },
450450
transferList: [port2],
@@ -608,10 +608,11 @@ loader with registered `resolve` and `load` hooks; all `require.resolve` calls
608608
from this module will be processed by the ESM loader with registered `resolve`
609609
hooks; `require.extensions` and monkey-patching on the CommonJS module loader
610610
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.
615616
616617
The Node.js internal `load` implementation, which is the value of `next` for the
617618
last hook in the `load` chain, returns `null` for `source` when `format` is

0 commit comments

Comments
 (0)