| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -357,6 +357,9 @@ For these use cases, subpath export patterns can be used instead: | |||
| 357 | 357 | } | |
| 358 | 358 | ``` | |
| 359 | 359 | ||
| 360 | + **`*` maps expose nested subpaths as it is a string replacement syntax | ||
| 361 | + only.** | ||
| 362 | + | ||
| 360 | 363 | The left hand matching pattern must always end in `*`. All instances of `*` on | |
| 361 | 364 | the right hand side will then be replaced with this value, including if it | |
| 362 | 365 | contains any `/` separators. | |
@@ -382,6 +385,26 @@ treating the right hand side target pattern as a `**` glob against the list of | |||
| 382 | 385 | files within the package. Because `node_modules` paths are forbidden in exports | |
| 383 | 386 | targets, this expansion is dependent on only the files of the package itself. | |
| 384 | 387 | ||
| 388 | + To exclude private subfolders from patterns, `null` targets can be used: | ||
| 389 | + | ||
| 390 | + ```json | ||
| 391 | + // ./node_modules/es-module-package/package.json | ||
| 392 | + { | ||
| 393 | + "exports": { | ||
| 394 | + "./features/*": "./src/features/*.js", | ||
| 395 | + "./features/private-internal/*": null | ||
| 396 | + } | ||
| 397 | + } | ||
| 398 | + ``` | ||
| 399 | + | ||
| 400 | + ```js | ||
| 401 | + import featureInternal from 'es-module-package/features/private-internal/m'; | ||
| 402 | + // Throws: ERR_PACKAGE_PATH_NOT_EXPORTED | ||
| 403 | + | ||
| 404 | + import featureX from 'es-module-package/features/x'; | ||
| 405 | + // Loads ./node_modules/es-module-package/src/features/x.js | ||
| 406 | + ``` | ||
| 407 | + | ||
| 385 | 408 | ### Exports sugar | |
| 386 | 409 | <!--YAML | |
| 387 | 410 | added: v12.11.0 | |
| Back | FazBrowse Home | New Git URL |
0 commit comments