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
+21Lines changed: 21 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -339,6 +339,27 @@ not much else.
339
339
340
340
If `main` is not set, it defaults to `index.js` in the package's root folder.
341
341
342
+
### exports
343
+
344
+
The exports field is an object that maps entry points to modules. It supports wild cards (`*`) and explicit names.
345
+
346
+
For example, you could have:
347
+
348
+
```json
349
+
{
350
+
"exports": {
351
+
".": "./index.js",
352
+
"./*": "./*.js",
353
+
"./*.js": "./*.js",
354
+
"./foo": "./path/to/foo.js"
355
+
}
356
+
}
357
+
```
358
+
359
+
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
+
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>
362
+
342
363
### browser
343
364
344
365
If your module is meant to be used client-side the browser field should be
0 commit comments