Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorRonald J Kimball <rjk@tamias.net>2019-05-01 16:27:27 +0300
committerRuben Bridgewater <ruben@bridgewater.de>2020-01-03 19:47:46 +0300
commitd3a8088cd5dd3ab4a6cb987c7b71bb900c9ebe39 (patch)
tree7199629ef7fd3770bcad9d9876343cca338d4cd5 /doc
parent1b720aa80202dd5ac6e8823a197ae6d530ac4b70 (diff)
doc: improve explanation of package.json "type" field
Regardless of the value of the `"type"` field, `.mjs` files are always treated as ES modules and `.cjs` files are always treated as CommonJS. PR-URL: https://github.com/nodejs/node/pull/27516 Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'doc')
-rw-r--r--doc/api/esm.md9
1 files changed, 6 insertions, 3 deletions
diff --git a/doc/api/esm.md b/doc/api/esm.md
index 93996584283..897fadb09ea 100644
--- a/doc/api/esm.md
+++ b/doc/api/esm.md
@@ -59,9 +59,9 @@ or when referenced by `import` statements within ES module code:
### `package.json` `"type"` field
-Files ending with `.js` or `.mjs`, or lacking any extension,
-will be loaded as ES modules when the nearest parent `package.json` file
-contains a top-level field `"type"` with a value of `"module"`.
+Files ending with `.js` or lacking any extension will be loaded as ES modules
+when the nearest parent `package.json` file contains a top-level field `"type"`
+with a value of `"module"`.
The nearest parent `package.json` is defined as the first `package.json` found
when searching in the current folder, that folder’s parent, and so on up
@@ -101,6 +101,9 @@ future-proof the package in case the default type of Node.js ever changes, and
it will also make things easier for build tools and loaders to determine how the
files in the package should be interpreted.
+Regardless of the value of the `"type"` field, `.mjs` files are always treated
+as ES modules and `.cjs` files are always treated as CommonJS.
+
### Package Scope and File Extensions
A folder containing a `package.json` file, and all subfolders below that