Skip to content

Commit 5c3a443

Browse files
committed
doc: remove extensionless CJS exception for type:module packages
Remove the documented exception that extensionless files in type: "module" packages are recognized as CommonJS when included via require(). This exception conflicted with the ESM resolution specification which states that extensionless files within a package scope with an explicit type field follow the format of the type field. The behavior on main already matches the ESM spec since #61600, this change aligns the CJS documentation accordingly. Refs: #61600 Refs: #62083
1 parent 70b3570 commit 5c3a443

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

doc/api/modules.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,8 @@ By default, Node.js will treat the following as CommonJS modules:
9292

9393
* Files with an extension that is not `.mjs`, `.cjs`, `.json`, `.node`, or `.js`
9494
(when the nearest parent `package.json` file contains a top-level field
95-
[`"type"`][] with a value of `"module"`, those files will be recognized as
96-
CommonJS modules only if they are being included via `require()`, not when
97-
used as the command-line entry point of the program).
95+
[`"type"`][] with a value of `"module"`, those files will not be recognized as
96+
CommonJS modules).
9897

9998
See [Determining module system][] for more details.
10099

0 commit comments

Comments
 (0)