File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,15 @@ if the nearest parent `package.json` contains `"type": "module"`.
97
97
import ' ./startup.js' ; // Loaded as ES module because of package.json
98
98
```
99
99
100
+ It is recommended that package authors always include the ` "type" ` field, even
101
+ in packages where it is unnecessary because all sources are CommonJS (and so
102
+ therefore the default ` "type": "commonjs" ` is implied) or because there are no
103
+ files ending in ` .js ` (for example, all files end in ` .mjs ` or ` .cjs ` or
104
+ ` .wasm ` , etc.). Being explicit about the ` type ` of the package will future-proof
105
+ the package in case Node.js’ default type ever changes, and it will also make
106
+ things easier for build tools and loaders to determine how the files in the
107
+ package should be interpreted.
108
+
100
109
### Package Scope and File Extensions
101
110
102
111
A folder containing a ` package.json ` file, and all subfolders below that
You can’t perform that action at this time.
0 commit comments