@@ -478,6 +478,11 @@ Node.js implements the following conditions:
478478* ` "node" ` - matches for any Node.js environment. Can be a CommonJS or ES
479479 module file. _ This condition should always come after ` "import" ` or
480480 ` "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] [ ] .
481486* ` "default" ` - the generic fallback that always matches. Can be a CommonJS
482487 or ES module file. _ This condition should always come last._
483488
@@ -556,17 +561,23 @@ node --conditions=development main.js
556561```
557562
558563which 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.
561566
562567Any number of custom conditions can be set with repeat flags.
563568
564569### Conditions Definitions
565570
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,
568573[ as specified above] ( #packages_conditional_exports ) .
569574
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+
570581Other condition strings are unknown to Node.js and thus ignored by default.
571582Runtimes or tools other than Node.js can use them at their discretion.
572583
@@ -1162,6 +1173,7 @@ This field defines [subpath imports][] for the current package.
11621173[` "main"` ]: #packages_main
11631174[` "name"` ]: #packages_name
11641175[` "type"` ]: #packages_type
1176+ [` --no-addons` flag]: cli .md #-- no- addons
11651177[` ERR_PACKAGE_PATH_NOT_EXPORTED` ]: errors .md #errors_err_package_path_not_exported
11661178[` esm` ]: https: // github.com/standard-things/esm#readme
11671179[` package.json` ]: #packages_node_js_package_json_field_definitions
0 commit comments