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