88 - v14.13.0
99 pr-url: https://github.com/nodejs/node/pull/34718
1010 description: Add support for `"exports"` patterns.
11- - version: v14.6.0
11+ - version:
12+ - v14.6.0
13+ - v12.19.0
1214 pr-url: https://github.com/nodejs/node/pull/34117
1315 description: Add package `"imports"` field.
1416 - version:
@@ -135,6 +137,9 @@ package:
135137 ` "commonjs" ` package).
136138
137139### ` --input-type ` flag
140+ <!-- YAML
141+ added: v12.0.0
142+ -->
138143
139144Strings passed in as an argument to ` --eval ` (or ` -e ` ), or piped to ` node ` via
140145` STDIN ` , are treated as [ ES modules] [ ] when the ` --input-type=module ` flag
@@ -252,6 +257,9 @@ absolute subpath of the package such as
252257` require('/path/to/node_modules/pkg/subpath.js') ` will still load ` subpath.js ` .
253258
254259### Subpath exports
260+ <!-- YAML
261+ added: v12.7.0
262+ -->
255263
256264When using the [ ` "exports" ` ] [ ] field, custom subpaths can be defined along
257265with the main entry point by treating the main entry point as the
@@ -282,6 +290,11 @@ import submodule from 'es-module-package/private-module.js';
282290```
283291
284292### Subpath imports
293+ <!-- YAML
294+ added:
295+ - v14.6.0
296+ - v12.19.0
297+ -->
285298
286299In addition to the [ ` "exports" ` ] [ ] field, it is possible to define internal
287300package import maps that only apply to import specifiers from within the package
@@ -319,6 +332,11 @@ The resolution rules for the imports field are otherwise
319332analogous to the exports field.
320333
321334### Subpath patterns
335+ <!-- YAML
336+ added:
337+ - v14.13.0
338+ - v12.19.0
339+ -->
322340
323341For packages with a small number of exports or imports, we recommend
324342explicitly listing each exports subpath entry. But for packages that have
@@ -404,6 +422,9 @@ The benefit of patterns over folder exports is that packages can always be
404422imported by consumers without subpath file extensions being necessary.
405423
406424### Exports sugar
425+ <!-- YAML
426+ added: v12.11.0
427+ -->
407428
408429If the ` "." ` export is the only export, the [ ` "exports" ` ] [ ] field provides sugar
409430for this case being the direct [ ` "exports" ` ] [ ] field value.
@@ -428,6 +449,17 @@ can be written:
428449```
429450
430451### Conditional exports
452+ <!-- YAML
453+ added:
454+ - v13.2.0
455+ - v12.16.0
456+ changes:
457+ - version:
458+ - v13.7.0
459+ - v12.16.0
460+ pr-url: https://github.com/nodejs/node/pull/31001
461+ description: Unflag conditional exports.
462+ -->
431463
432464Conditional exports provide a way to map to different paths depending on
433465certain conditions. They are supported for both CommonJS and ES module imports.
@@ -526,6 +558,11 @@ the remaining conditions of the parent condition. In this way nested
526558conditions behave analogously to nested JavaScript ` if ` statements.
527559
528560### Resolving user conditions
561+ <!-- YAML
562+ added:
563+ - v14.9.0
564+ - v12.19.0
565+ -->
529566
530567When running Node.js, custom user conditions can be added with the
531568` --conditions ` flag:
@@ -587,6 +624,17 @@ The above definitions may be moved to a dedicated conditions registry in due
587624course.
588625
589626### Self-referencing a package using its name
627+ <!-- YAML
628+ added:
629+ - v13.1.0
630+ - v12.16.0
631+ changes:
632+ - version:
633+ - v13.6.0
634+ - v12.16.0
635+ pr-url: https://github.com/nodejs/node/pull/31002
636+ description: Unflag self-referencing a package using its name.
637+ -->
590638
591639Within a package, the values defined in the package’s
592640` package.json ` [ ` "exports" ` ] [ ] field can be referenced via the package’s name.
0 commit comments