@@ -93,7 +93,26 @@ By default, Node.js will treat the following as CommonJS modules:
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
9595 [ ` "type" ` ] [ ] with a value of ` "module" ` , those files will not be recognized as
96- CommonJS modules).
96+ By default, Node.js will treat the following as CommonJS modules:
97+
98+ * Files with a ` .cjs ` extension.
99+
100+ * Files with a ` .js ` extension or without an extension, when the nearest parent
101+ ` package.json ` file contains a top-level field [ ` "type" ` ] [ ] with a value of
102+ ` "commonjs" ` .
103+
104+ * Files with a ` .js ` extension or without an extension, when the nearest parent
105+ ` package.json ` file doesn't contain a top-level field [ ` "type" ` ] [ ] or there is
106+ no ` package.json ` in any parent folder; unless the file contains syntax that
107+ errors unless it is evaluated as an ES module. Package authors should include
108+ the [ ` "type" ` ] [ ] field, even in packages where all sources are CommonJS. Being
109+ explicit about the ` type ` of the package will make things easier for build
110+ tools and loaders to determine how the files in the package should be
111+ interpreted.
112+
113+ * Files with an extension that is not ` .mjs ` , ` .cjs ` , ` .json ` , ` .node ` , or ` .js ` ,
114+ when the nearest parent ` package.json ` file contains a top-level field
115+ [ ` "type" ` ] [ ] with a value of ` "module" ` .
97116
98117See [ Determining module system] [ ] for more details.
99118
0 commit comments