Skip to content

Commit 86644b9

Browse files
benmccannruyadorno
authored andcommitted
doc: clarify that import also uses main
PR-URL: #41720 Reviewed-By: Geoffrey Booth <[email protected]> Reviewed-By: Mohammed Keyvanzadeh <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent 4889a31 commit 86644b9

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

doc/api/packages.md

+8-6
Original file line numberDiff line numberDiff line change
@@ -1093,17 +1093,19 @@ added: v0.4.0
10931093
}
10941094
```
10951095

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).
10991104

11001105
```cjs
11011106
require('./path/to/directory'); // This resolves to ./path/to/directory/main.js.
11021107
```
11031108

1104-
When a package has an [`"exports"`][] field, this will take precedence over the
1105-
`"main"` field when importing the package by name.
1106-
11071109
### `"packageManager"`
11081110

11091111
<!-- YAML

0 commit comments

Comments
 (0)