You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/lib/content/configuring-npm/package-json.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -341,7 +341,7 @@ If `main` is not set, it defaults to `index.js` in the package's root folder.
341
341
342
342
### exports
343
343
344
-
The exports field is an object that maps entry points to modules. It supports wild cards (`*`) and explicit names.
344
+
The exports field is an object that maps entry points to modules. This field is supported by Node.js versions including and higher than 12. It acts a more featureful alternative to the `main` field. It supports wild cards (`*`) and explicit names.
345
345
346
346
For example, you could have:
347
347
@@ -351,14 +351,16 @@ For example, you could have:
351
351
".": "./index.js",
352
352
"./*": "./*.js",
353
353
"./*.js": "./*.js",
354
-
"./foo": "./path/to/foo.js"
354
+
"./foo": "./path/to/foo.js",
355
+
"./package.json": "./package.json",
356
+
"./
355
357
}
356
358
}
357
359
```
358
360
359
361
If someone installed your package with this in your `package.json`, they could `require("my-package")` and it would be mapped to `./node_modules/my-package/index.js` because of `".": "./index.js"`.<br>
360
362
If they did `require("my-package/bar")` or `require("my-package/bar.js")`, it would be mapped to `./node_modules/my-package/bar.js` because of the wild cards (`*`).<br>
361
-
If they did `require("my-package/foo")` it would be mapped to `./node_modules/my-package/path/to/foo.js` because of the explicit mapping `"./foo": "./path/to/foo.js"`.<br>
363
+
If they did `require("my-package/foo")` it would be mapped to `./node_modules/my-package/path/to/foo.js` because of the explicit mapping `"./foo": "./path/to/foo.js"`.
0 commit comments