| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 20d9c4a commit 211a3c4
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1138,17 +1138,19 @@ added: v0.4.0 | |||
| 1138 | 1138 | } | |
| 1139 | 1139 | ``` | |
| 1140 | 1140 | ||
| 1141 | - The `"main"` field defines the script that is used when the [package directory | ||
| 1142 | - is loaded via `require()`](modules.md#folders-as-modules). Its value | ||
| 1143 | - is a path. | ||
| 1141 | + The `"main"` field defines the entry point of a package when imported by name | ||
| 1142 | + via a `node_modules` lookup. Its value is a path. | ||
| 1143 | + | ||
| 1144 | + When a package has an [`"exports"`][] field, this will take precedence over the | ||
| 1145 | + `"main"` field when importing the package by name. | ||
| 1146 | + | ||
| 1147 | + It also defines the script that is used when the [package directory is loaded | ||
| 1148 | + via `require()`](modules.md#folders-as-modules). | ||
| 1144 | 1149 | ||
| 1145 | 1150 | ```cjs | |
| 1146 | 1151 | require('./path/to/directory'); // This resolves to ./path/to/directory/main.js. | |
| 1147 | 1152 | ``` | |
| 1148 | 1153 | ||
| 1149 | - When a package has an [`"exports"`][] field, this will take precedence over the | ||
| 1150 | - `"main"` field when importing the package by name. | ||
| 1151 | - | ||
| 1152 | 1154 | ### `"packageManager"` | |
| 1153 | 1155 | ||
| 1154 | 1156 | <!-- YAML | |
| Back | FazBrowse Home | New Git URL |
0 commit comments