@@ -477,6 +477,11 @@ Node.js implements the following conditions:
477
477
* ` "node" ` - matches for any Node.js environment. Can be a CommonJS or ES
478
478
module file. _ This condition should always come after ` "import" ` or
479
479
` "require" ` ._
480
+ * ` "node-addons" ` - similar to ` "node" ` and matches for any Node.js environment.
481
+ This condition can be used to provide an entry point which uses native C++
482
+ addons as opposed to an entry point which is more universal and doesn't rely
483
+ on native addons. This condition can be disabled via the
484
+ [ ` --no-addons ` flag] [ ] .
480
485
* ` "default" ` - the generic fallback that always matches. Can be a CommonJS
481
486
or ES module file. _ This condition should always come last._
482
487
@@ -555,17 +560,23 @@ node --conditions=development main.js
555
560
```
556
561
557
562
which would then resolve the ` "development" ` condition in package imports and
558
- exports, while resolving the existing ` "node" ` , ` "default " ` , ` "import " ` , and
559
- ` "require" ` conditions as appropriate.
563
+ exports, while resolving the existing ` "node" ` , ` "node-addons " ` , ` "default " ` ,
564
+ ` "import" ` , and ` " require"` conditions as appropriate.
560
565
561
566
Any number of custom conditions can be set with repeat flags.
562
567
563
568
### Conditions Definitions
564
569
565
- The ` "import" ` , ` "require" ` , ` "node" ` and ` "default" ` conditions are defined
566
- and implemented in Node.js core,
570
+ The ` "import" ` , ` "require" ` , ` "node" ` , ` "node-addons" ` and ` "default" `
571
+ conditions are defined and implemented in Node.js core,
567
572
[ as specified above] ( #packages_conditional_exports ) .
568
573
574
+ The ` "node-addons" ` condition can be used to provide an entry point which
575
+ uses native C++ addons. However, this condition can be disabled via the
576
+ [ ` --no-addons ` flag] [ ] . When using ` "node-addons" ` , it's recommended to treat
577
+ ` "default" ` as an enhancement that provides a more universal entry point, e.g.
578
+ using WebAssembly instead of a native addon.
579
+
569
580
Other condition strings are unknown to Node.js and thus ignored by default.
570
581
Runtimes or tools other than Node.js can use them at their discretion.
571
582
@@ -1161,6 +1172,7 @@ This field defines [subpath imports][] for the current package.
1161
1172
[` "main"` ]: #packages_main
1162
1173
[` "name"` ]: #packages_name
1163
1174
[` "type"` ]: #packages_type
1175
+ [` --no-addons` flag]: cli .md #cli_no_addons
1164
1176
[` ERR_PACKAGE_PATH_NOT_EXPORTED` ]: errors .md #errors_err_package_path_not_exported
1165
1177
[` esm` ]: https: // github.com/standard-things/esm#readme
1166
1178
[` package.json` ]: #packages_node_js_package_json_field_definitions
0 commit comments