Skip to content

Commit a448c8b

Browse files
Gabriel Schulhoftargos
Gabriel Schulhof
authored andcommitted
doc: add blurb about implications of ABI stability
Mention that ABI stability can be achieved only by linking to ABI- stable parts of Node.js and to other libraries which are ABI-stable. PR-URL: #22508 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent a3e3ae0 commit a448c8b

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

doc/api/addons.md

+4
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,10 @@ set of APIs that are used by the native code. Instead of using the V8
367367
or [Native Abstractions for Node.js][] APIs, the functions available
368368
in the N-API are used.
369369

370+
Creating and maintaining an addon that benefits from the ABI stability
371+
provided by N-API carries with it certain
372+
[implementation considerations](n-api.html#n_api_implications_of_abi_stability).
373+
370374
To use N-API in the above "Hello world" example, replace the content of
371375
`hello.cc` with the following. All other instructions remain the same.
372376

doc/api/n-api.md

+30
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,36 @@ for the N-API C based functions exported by Node.js. These wrappers are not
4242
part of N-API, nor will they be maintained as part of Node.js. One such
4343
example is: [node-addon-api](https://github.com/nodejs/node-addon-api).
4444

45+
## Implications of ABI Stability
46+
47+
Although N-API provides an ABI stability guarantee, other parts of Node.js do
48+
not, and any external libraries used from the addon may not. In particular,
49+
none of the following APIs provide an ABI stability guarantee across major
50+
versions:
51+
* the Node.js C++ APIs available via any of
52+
```C++
53+
#include <node.h>
54+
#include <node_buffer.h>
55+
#include <node_version.h>
56+
#include <node_object_wrap.h>
57+
```
58+
* the libuv APIs which are also included with Node.js and available via
59+
```C++
60+
#include <uv.h>
61+
```
62+
* the V8 API available via
63+
```C++
64+
#include <v8.h>
65+
```
66+
67+
Thus, for an addon to remain ABI-compatible across Node.js major versions, it
68+
must make use exclusively of N-API by restricting itself to using
69+
```C
70+
#include <node_api.h>
71+
```
72+
and by checking, for all external libraries that it uses, that the external
73+
library makes ABI stability guarantees similar to N-API.
74+
4575
## Usage
4676

4777
In order to use the N-API functions, include the file

0 commit comments

Comments
 (0)