Skip to content

Commit 50582e6

Browse files
GeoffreyBoothaduh95
andcommitted
Update doc/api/module.md
Co-authored-by: Antoine du Hamel <[email protected]>
1 parent 3d5ff16 commit 50582e6

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

doc/api/module.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -601,17 +601,19 @@ The final value of `format` must be one of the following:
601601
The value of `source` is ignored for type `'builtin'` because currently it is
602602
not possible to replace the value of a Node.js builtin (core) module.
603603
604-
The value of `source` can be omitted for type `'commonjs'`. When a `source` is
605-
provided, all `require` calls from this module will be processed by the ESM
606-
loader with registered `resolve` and `load` hooks; all `require.resolve` calls
607-
from this module will be processed by the ESM loader with registered `resolve`
608-
hooks; `require.extensions` and monkey-patching on the CommonJS module loader
609-
will not apply. (In other words, handled `require` calls will behave similarly
610-
to an `import` of a CommonJS module, other than `require` being sync.) If
611-
`source` is undefined or `null`, it will be handled by the CommonJS module
612-
loader and `require`/`require.resolve` calls will not go through the registered
613-
hooks. This behavior for nullish `source` is temporary — in the future, nullish
614-
`source` will not be supported.
604+
The value of `source` can be omitted for type `'commonjs'`:
605+
606+
- When a `source` is provided, all `require` calls from this module will be
607+
processed by the ESM loader with registered `resolve` and `load` hooks; all
608+
`require.resolve` calls from this module will be processed by the ESM loader
609+
with registered `resolve` hooks; only a subset of the CommonJS API will be
610+
available (e.g. no `require.extensions`, no `require.cache`, no
611+
`require.resolve.paths`) and monkey-patching on the CommonJS module loader
612+
will not apply.
613+
- If `source` is undefined or `null`, it will be handled by the CommonJS module
614+
loader and `require`/`require.resolve` calls will not go through the
615+
registered hooks. This behavior for nullish `source` is temporary — in the
616+
future, nullish `source` will not be supported.
615617
616618
The Node.js internal `load` implementation, which is the value of `next` for the
617619
last hook in the `load` chain, returns `null` for `source` when `format` is

0 commit comments

Comments
 (0)