Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominic Elm <elmdominic@gmx.net>2021-09-13 11:18:10 +0300
committerRichard Lau <rlau@redhat.com>2022-01-25 15:54:07 +0300
commitb050c658851c38b24bdbb516b214bfbe8e50ebdb (patch)
treebeae7d29e7ec1b3a3c5cc759a363eb463c4d40dd /doc/api/packages.md
parent2755d391a5e68e08b699e9d7c20e05cfc28bcac3 (diff)
src: add option to disable loading native addons
Backport-PR-URL: https://github.com/nodejs/node/pull/40094 PR-URL: https://github.com/nodejs/node/pull/39977 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Bradley Farias <bradley.meck@gmail.com> Reviewed-By: Guy Bedford <guybedford@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
Diffstat (limited to 'doc/api/packages.md')
-rw-r--r--doc/api/packages.md20
1 files changed, 16 insertions, 4 deletions
diff --git a/doc/api/packages.md b/doc/api/packages.md
index 2cdc1469465..2e3a731727f 100644
--- a/doc/api/packages.md
+++ b/doc/api/packages.md
@@ -477,6 +477,11 @@ Node.js implements the following conditions:
* `"node"` - matches for any Node.js environment. Can be a CommonJS or ES
module file. _This condition should always come after `"import"` or
`"require"`._
+* `"node-addons"` - similar to `"node"` and matches for any Node.js environment.
+ This condition can be used to provide an entry point which uses native C++
+ addons as opposed to an entry point which is more universal and doesn't rely
+ on native addons. This condition can be disabled via the
+ [`--no-addons` flag][].
* `"default"` - the generic fallback that always matches. Can be a CommonJS
or ES module file. _This condition should always come last._
@@ -555,17 +560,23 @@ node --conditions=development main.js
```
which would then resolve the `"development"` condition in package imports and
-exports, while resolving the existing `"node"`, `"default"`, `"import"`, and
-`"require"` conditions as appropriate.
+exports, while resolving the existing `"node"`, `"node-addons"`, `"default"`,
+`"import"`, and `"require"` conditions as appropriate.
Any number of custom conditions can be set with repeat flags.
### Conditions Definitions
-The `"import"`, `"require"`, `"node"` and `"default"` conditions are defined
-and implemented in Node.js core,
+The `"import"`, `"require"`, `"node"`, `"node-addons"` and `"default"`
+conditions are defined and implemented in Node.js core,
[as specified above](#packages_conditional_exports).
+The `"node-addons"` condition can be used to provide an entry point which
+uses native C++ addons. However, this condition can be disabled via the
+[`--no-addons` flag][]. When using `"node-addons"`, it's recommended to treat
+`"default"` as an enhancement that provides a more universal entry point, e.g.
+using WebAssembly instead of a native addon.
+
Other condition strings are unknown to Node.js and thus ignored by default.
Runtimes or tools other than Node.js can use them at their discretion.
@@ -1161,6 +1172,7 @@ This field defines [subpath imports][] for the current package.
[`"main"`]: #packages_main
[`"name"`]: #packages_name
[`"type"`]: #packages_type
+[`--no-addons` flag]: cli.md#cli_no_addons
[`ERR_PACKAGE_PATH_NOT_EXPORTED`]: errors.md#errors_err_package_path_not_exported
[`esm`]: https://github.com/standard-things/esm#readme
[`package.json`]: #packages_node_js_package_json_field_definitions