Skip to content

Commit 332521e

Browse files
committed
doc: add version metadata for packages features
PR-URL: #37289 Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent e511c0b commit 332521e

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

doc/api/packages.md

+49-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ changes:
99
- v12.20.0
1010
pr-url: https://github.com/nodejs/node/pull/34718
1111
description: Add support for `"exports"` patterns.
12-
- version: v14.6.0
12+
- version:
13+
- v14.6.0
14+
- v12.19.0
1315
pr-url: https://github.com/nodejs/node/pull/34117
1416
description: Add package `"imports"` field.
1517
- version:
@@ -136,6 +138,9 @@ package:
136138
`"commonjs"` package).
137139

138140
### `--input-type` flag
141+
<!-- YAML
142+
added: v12.0.0
143+
-->
139144

140145
Strings passed in as an argument to `--eval` (or `-e`), or piped to `node` via
141146
`STDIN`, are treated as [ES modules][] when the `--input-type=module` flag
@@ -253,6 +258,9 @@ absolute subpath of the package such as
253258
`require('/path/to/node_modules/pkg/subpath.js')` will still load `subpath.js`.
254259

255260
### Subpath exports
261+
<!-- YAML
262+
added: v12.7.0
263+
-->
256264

257265
When using the [`"exports"`][] field, custom subpaths can be defined along
258266
with the main entry point by treating the main entry point as the
@@ -283,6 +291,11 @@ import submodule from 'es-module-package/private-module.js';
283291
```
284292

285293
### Subpath imports
294+
<!--YAML
295+
added:
296+
- v14.6.0
297+
- v12.19.0
298+
-->
286299

287300
In addition to the [`"exports"`][] field, it is possible to define internal
288301
package import maps that only apply to import specifiers from within the package
@@ -320,6 +333,11 @@ The resolution rules for the imports field are otherwise
320333
analogous to the exports field.
321334

322335
### Subpath patterns
336+
<!--YAML
337+
added:
338+
- v14.13.0
339+
- v12.19.0
340+
-->
323341

324342
For packages with a small number of exports or imports, we recommend
325343
explicitly listing each exports subpath entry. But for packages that have
@@ -407,6 +425,9 @@ The benefit of patterns over folder exports is that packages can always be
407425
imported by consumers without subpath file extensions being necessary.
408426

409427
### Exports sugar
428+
<!--YAML
429+
added: v12.11.0
430+
-->
410431

411432
If the `"."` export is the only export, the [`"exports"`][] field provides sugar
412433
for this case being the direct [`"exports"`][] field value.
@@ -431,6 +452,17 @@ can be written:
431452
```
432453

433454
### Conditional exports
455+
<!--YAML
456+
added:
457+
- v13.2.0
458+
- v12.16.0
459+
changes:
460+
- version:
461+
- v13.7.0
462+
- v12.16.0
463+
pr-url: https://github.com/nodejs/node/pull/31001
464+
description: Unflag conditional exports.
465+
-->
434466

435467
Conditional exports provide a way to map to different paths depending on
436468
certain conditions. They are supported for both CommonJS and ES module imports.
@@ -529,6 +561,11 @@ the remaining conditions of the parent condition. In this way nested
529561
conditions behave analogously to nested JavaScript `if` statements.
530562

531563
### Resolving user conditions
564+
<!-- YAML
565+
added:
566+
- v14.9.0
567+
- v12.19.0
568+
-->
532569

533570
When running Node.js, custom user conditions can be added with the
534571
`--conditions` flag:
@@ -590,6 +627,17 @@ The above definitions may be moved to a dedicated conditions registry in due
590627
course.
591628

592629
### Self-referencing a package using its name
630+
<!--YAML
631+
added:
632+
- v13.1.0
633+
- v12.16.0
634+
changes:
635+
- version:
636+
- v13.6.0
637+
- v12.16.0
638+
pr-url: https://github.com/nodejs/node/pull/31002
639+
description: Unflag self-referencing a package using its name.
640+
-->
593641

594642
Within a package, the values defined in the package’s
595643
`package.json` [`"exports"`][] field can be referenced via the package’s name.

0 commit comments

Comments
 (0)