Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c44df51

Browse filesBrowse files
Gabriel Schulhoftargos
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 <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 45816c5 commit c44df51
Copy full SHA for c44df51

File tree

Expand file treeCollapse file tree

1 file changed

+5
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-0
lines changed
Open diff view settings
Collapse file

‎doc/api/n-api.md‎

Copy file name to clipboardExpand all lines: doc/api/n-api.md
+5Lines changed: 5 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.