9
9
- v12.20.0
10
10
pr-url: https://github.com/nodejs/node/pull/34718
11
11
description: Add support for `"exports"` patterns.
12
- - version: v14.6.0
12
+ - version:
13
+ - v14.6.0
14
+ - v12.19.0
13
15
pr-url: https://github.com/nodejs/node/pull/34117
14
16
description: Add package `"imports"` field.
15
17
- version:
@@ -136,6 +138,9 @@ package:
136
138
` "commonjs" ` package).
137
139
138
140
### ` --input-type ` flag
141
+ <!-- YAML
142
+ added: v12.0.0
143
+ -->
139
144
140
145
Strings passed in as an argument to ` --eval ` (or ` -e ` ), or piped to ` node ` via
141
146
` STDIN ` , are treated as [ ES modules] [ ] when the ` --input-type=module ` flag
@@ -253,6 +258,9 @@ absolute subpath of the package such as
253
258
` require('/path/to/node_modules/pkg/subpath.js') ` will still load ` subpath.js ` .
254
259
255
260
### Subpath exports
261
+ <!-- YAML
262
+ added: v12.7.0
263
+ -->
256
264
257
265
When using the [ ` "exports" ` ] [ ] field, custom subpaths can be defined along
258
266
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';
283
291
```
284
292
285
293
### Subpath imports
294
+ <!-- YAML
295
+ added:
296
+ - v14.6.0
297
+ - v12.19.0
298
+ -->
286
299
287
300
In addition to the [ ` "exports" ` ] [ ] field, it is possible to define internal
288
301
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
320
333
analogous to the exports field.
321
334
322
335
### Subpath patterns
336
+ <!-- YAML
337
+ added:
338
+ - v14.13.0
339
+ - v12.19.0
340
+ -->
323
341
324
342
For packages with a small number of exports or imports, we recommend
325
343
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
407
425
imported by consumers without subpath file extensions being necessary.
408
426
409
427
### Exports sugar
428
+ <!-- YAML
429
+ added: v12.11.0
430
+ -->
410
431
411
432
If the ` "." ` export is the only export, the [ ` "exports" ` ] [ ] field provides sugar
412
433
for this case being the direct [ ` "exports" ` ] [ ] field value.
@@ -431,6 +452,17 @@ can be written:
431
452
```
432
453
433
454
### 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
+ -->
434
466
435
467
Conditional exports provide a way to map to different paths depending on
436
468
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
529
561
conditions behave analogously to nested JavaScript ` if ` statements.
530
562
531
563
### Resolving user conditions
564
+ <!-- YAML
565
+ added:
566
+ - v14.9.0
567
+ - v12.19.0
568
+ -->
532
569
533
570
When running Node.js, custom user conditions can be added with the
534
571
` --conditions ` flag:
@@ -590,6 +627,17 @@ The above definitions may be moved to a dedicated conditions registry in due
590
627
course.
591
628
592
629
### 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
+ -->
593
641
594
642
Within a package, the values defined in the package’s
595
643
` package.json ` [ ` "exports" ` ] [ ] field can be referenced via the package’s name.
0 commit comments