Skip to content

Commit 6db465a

Browse files
mildsunrisedanielleadams
authored andcommitted
doc: clarify that N-API addons are context-aware
The docs on N-API say that NAPI_MODULE_INIT must be used for the addon to be context-aware. That seems to be wrong, i.e. all N-API addons are context-aware(?) PR-URL: #36640 Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Gabriel Schulhof <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent fad07d5 commit 6db465a

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

doc/api/n-api.md

+5-9
Original file line numberDiff line numberDiff line change
@@ -1853,8 +1853,8 @@ napi_value Init(napi_env env, napi_value exports) {
18531853
}
18541854
```
18551855

1856-
If the module will be loaded multiple times during the lifetime of the Node.js
1857-
process, use the `NAPI_MODULE_INIT` macro to initialize the module:
1856+
You can also use the `NAPI_MODULE_INIT` macro, which acts as a shorthand
1857+
for `NAPI_MODULE` and defining an `Init` function:
18581858

18591859
```c
18601860
NAPI_MODULE_INIT() {
@@ -1871,13 +1871,9 @@ NAPI_MODULE_INIT() {
18711871
}
18721872
```
18731873

1874-
This macro includes `NAPI_MODULE`, and declares an `Init` function with a
1875-
special name and with visibility beyond the addon. This will allow Node.js to
1876-
initialize the module even if it is loaded multiple times.
1877-
1878-
There are a few design considerations when declaring a module that may be loaded
1879-
multiple times. The documentation of [context-aware addons][] provides more
1880-
details.
1874+
All N-API addons are context-aware, meaning they may be loaded multiple
1875+
times. There are a few design considerations when declaring such a module.
1876+
The documentation on [context-aware addons][] provides more details.
18811877

18821878
The variables `env` and `exports` will be available inside the function body
18831879
following the macro invocation.

0 commit comments

Comments
 (0)