| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4889a31 commit 86644b9
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1093,17 +1093,19 @@ added: v0.4.0 | |||
| 1093 | 1093 | } | |
| 1094 | 1094 | ``` | |
| 1095 | 1095 | ||
| 1096 | - The `"main"` field defines the script that is used when the [package directory | ||
| 1097 | - is loaded via `require()`](modules.md#folders-as-modules). Its value | ||
| 1098 | - is a path. | ||
| 1096 | + The `"main"` field defines the entry point of a package when imported by name | ||
| 1097 | + via a `node_modules` lookup. Its value is a path. | ||
| 1098 | + | ||
| 1099 | + When a package has an [`"exports"`][] field, this will take precedence over the | ||
| 1100 | + `"main"` field when importing the package by name. | ||
| 1101 | + | ||
| 1102 | + It also defines the script that is used when the [package directory is loaded | ||
| 1103 | + via `require()`](modules.md#folders-as-modules). | ||
| 1099 | 1104 | ||
| 1100 | 1105 | ```cjs | |
| 1101 | 1106 | require('./path/to/directory'); // This resolves to ./path/to/directory/main.js. | |
| 1102 | 1107 | ``` | |
| 1103 | 1108 | ||
| 1104 | - When a package has an [`"exports"`][] field, this will take precedence over the | ||
| 1105 | - `"main"` field when importing the package by name. | ||
| 1106 | - | ||
| 1107 | 1109 | ### `"packageManager"` | |
| 1108 | 1110 | ||
| 1109 | 1111 | <!-- YAML | |
| Back | FazBrowse Home | New Git URL |
0 commit comments