Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0c08835

Browse filesBrowse files
mcollinaRafaelGSS
authored andcommitted
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 PR-URL: #62176 Refs: #61600 Refs: #62083 Refs: #61971 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 6cc4cf8 commit 0c08835
Copy full SHA for 0c08835

1 file changed

+7-8Lines changed: 7 additions & 8 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/api/modules.md‎

Copy file name to clipboardExpand all lines: doc/api/modules.md
+7-8Lines changed: 7 additions & 8 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,11 @@ Node.js has two module systems: CommonJS modules and [ECMAScript modules][].
7676

7777
By default, Node.js will treat the following as CommonJS modules:
7878

79-
* Files with a `.cjs` extension;
79+
* Files with a `.cjs` extension.
8080

81-
* Files with a `.js` extension when the nearest parent `package.json` file
82-
contains a top-level field [`"type"`][] with a value of `"commonjs"`.
81+
* Files with a `.js` extension or without an extension, when the nearest parent
82+
`package.json` file contains a top-level field [`"type"`][] with a value of
83+
`"commonjs"`.
8384

8485
* Files with a `.js` extension or without an extension, when the nearest parent
8586
`package.json` file doesn't contain a top-level field [`"type"`][] or there is
@@ -90,11 +91,9 @@ By default, Node.js will treat the following as CommonJS modules:
9091
tools and loaders to determine how the files in the package should be
9192
interpreted.
9293

93-
* Files with an extension that is not `.mjs`, `.cjs`, `.json`, `.node`, or `.js`
94-
(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).
94+
* Files with an extension that is not `.mjs`, `.cjs`, `.json`, `.node`, or `.js`,
95+
when the nearest parent `package.json` file contains a top-level field
96+
[`"type"`][] with a value of `"module"`.
9897

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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.