Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 96fa387

Browse filesBrowse files
guybedforddanielleadams
authored andcommitted
doc: document null target pattern
PR-URL: #38724 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Derek Lewis <DerekNonGeneric@inf.is> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 4131f94 commit 96fa387
Copy full SHA for 96fa387

File tree

Expand file treeCollapse file tree

1 file changed

+23
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+23
-0
lines changed
Open diff view settings
Collapse file

‎doc/api/packages.md‎

Copy file name to clipboardExpand all lines: doc/api/packages.md
+23Lines changed: 23 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,9 @@ For these use cases, subpath export patterns can be used instead:
358358
}
359359
```
360360

361+
**`*` maps expose nested subpaths as it is a string replacement syntax
362+
only.**
363+
361364
The left hand matching pattern must always end in `*`. All instances of `*` on
362365
the right hand side will then be replaced with this value, including if it
363366
contains any `/` separators.
@@ -383,6 +386,26 @@ treating the right hand side target pattern as a `**` glob against the list of
383386
files within the package. Because `node_modules` paths are forbidden in exports
384387
targets, this expansion is dependent on only the files of the package itself.
385388

389+
To exclude private subfolders from patterns, `null` targets can be used:
390+
391+
```json
392+
// ./node_modules/es-module-package/package.json
393+
{
394+
"exports": {
395+
"./features/*": "./src/features/*.js",
396+
"./features/private-internal/*": null
397+
}
398+
}
399+
```
400+
401+
```js
402+
import featureInternal from 'es-module-package/features/private-internal/m';
403+
// Throws: ERR_PACKAGE_PATH_NOT_EXPORTED
404+
405+
import featureX from 'es-module-package/features/x';
406+
// Loads ./node_modules/es-module-package/src/features/x.js
407+
```
408+
386409
### Subpath folder mappings
387410
<!-- YAML
388411
changes:

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.