| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1b720aa commit d3a8088
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -59,9 +59,9 @@ or when referenced by `import` statements within ES module code: | |||
| 59 | 59 | ||
| 60 | 60 | ### `package.json` `"type"` field | |
| 61 | 61 | ||
| 62 | - Files ending with `.js` or `.mjs`, or lacking any extension, | ||
| 63 | - will be loaded as ES modules when the nearest parent `package.json` file | ||
| 64 | - contains a top-level field `"type"` with a value of `"module"`. | ||
| 62 | + Files ending with `.js` or lacking any extension will be loaded as ES modules | ||
| 63 | + when the nearest parent `package.json` file contains a top-level field `"type"` | ||
| 64 | + with a value of `"module"`. | ||
| 65 | 65 | ||
| 66 | 66 | The nearest parent `package.json` is defined as the first `package.json` found | |
| 67 | 67 | 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 | |||
| 101 | 101 | it will also make things easier for build tools and loaders to determine how the | |
| 102 | 102 | files in the package should be interpreted. | |
| 103 | 103 | ||
| 104 | + Regardless of the value of the `"type"` field, `.mjs` files are always treated | ||
| 105 | + as ES modules and `.cjs` files are always treated as CommonJS. | ||
| 106 | + | ||
| 104 | 107 | ### Package Scope and File Extensions | |
| 105 | 108 | ||
| 106 | 109 | A folder containing a `package.json` file, and all subfolders below that | |
| Back | FazBrowse Home | New Git URL |
0 commit comments