Skip to content

Commit c44df51

Browse files
Gabriel Schulhoftargos
Gabriel Schulhof
authored andcommitted
doc: link n-api module init to multi-load addons
Add a blurb to the documentation of `NAPI_MODULE_INIT()` pointing to the discussion of the consequences of providing an addon that can be loaded multiple times from multiple contexts. PR-URL: #21891 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 45816c5 commit c44df51

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

doc/api/n-api.md

+5
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,10 @@ This macro includes `NAPI_MODULE`, and declares an `Init` function with a
11831183
special name and with visibility beyond the addon. This will allow Node.js to
11841184
initialize the module even if it is loaded multiple times.
11851185

1186+
There are a few design considerations when declaring a module that may be loaded
1187+
multiple times. The documentation of [context-aware addons][] provides more
1188+
details.
1189+
11861190
The variables `env` and `exports` will be available inside the function body
11871191
following the macro invocation.
11881192

@@ -4581,3 +4585,4 @@ This API may only be called from the main thread.
45814585
[`process.release`]: process.html#process_process_release
45824586
[`init` hooks]: async_hooks.html#async_hooks_init_asyncid_type_triggerasyncid_resource
45834587
[async_hooks `type`]: async_hooks.html#async_hooks_type
4588+
[context-aware addons]: addons.html#addons_context_aware_addons

0 commit comments

Comments
 (0)