Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup! esm: bypass CJS loader in default load under `--default-type=m…
…odule`
  • Loading branch information
aduh95 committed Oct 23, 2023
commit bd3208aa235d20d626c21e727423e5df0edf1574
19 changes: 9 additions & 10 deletions doc/api/module.md
Original file line number Diff line number Diff line change
Expand Up @@ -610,18 +610,17 @@ not possible to replace the value of a Node.js builtin (core) module.

Omitting vs providing a `source` for `'commonjs'` has very different effects:

* When a `source` is provided, or when running `node` with
`--experimental-default-type=module`, all `require` calls from this module
will be processed by the ESM loader with registered `resolve` and `load`
hooks; all `require.resolve` calls from this module will be processed by the
ESM loader with registered `resolve` hooks; only a subset of the CommonJS API
will be available (e.g. no `require.extensions`, no `require.cache`, no
* When a `source` is provided, all `require` calls from this module will be
processed by the ESM loader with registered `resolve` and `load` hooks; all
`require.resolve` calls from this module will be processed by the ESM loader
with registered `resolve` hooks; only a subset of the CommonJS API will be
available (e.g. no `require.extensions`, no `require.cache`, no
`require.resolve.paths`) and monkey-patching on the CommonJS module loader
will not apply.
* If `source` is undefined or `null`, and `node` is run with
`--experimental-default-type=commonjs`, it will be handled by the CommonJS
module loader and `require`/`require.resolve` calls will not go through the
registered hooks.
* If `source` is undefined or `null`, it will be handled by the CommonJS module
loader and `require`/`require.resolve` calls will not go through the
registered hooks. This behavior for nullish `source` is temporary — in the
future, nullish `source` will not be supported.

When `node` is run with `--experimental-default-type=commonjs`, the Node.js
internal `load` implementation, which is the value of `next` for the
Expand Down