ABI 稳定性的影响


¥Implications of ABI stability

尽管 Node-API 提供了 ABI 稳定性保证,但 Node.js 的其他部分却没有,插件中使用的任何外部库也可能没有。特别是,以下 API 均未提供跨主要版本的 ABI 稳定性保证:

¥Although Node-API provides an ABI stability guarantee, other parts of Node.js do not, and any external libraries used from the addon may not. In particular, none of the following APIs provide an ABI stability guarantee across major versions:

  • 可通过任何方式获得的 Node.js C++ API

    ¥the Node.js C++ APIs available via any of

    #include <node.h>
    #include <node_buffer.h>
    #include <node_version.h>
    #include <node_object_wrap.h> 
  • libuv API,它也包含在 Node.js 中,可通过

    ¥the libuv APIs which are also included with Node.js and available via

    #include <uv.h> 
  • V8 API 可通过

    ¥the V8 API available via

    #include <v8.h> 

因此,为了使插件在 Node.js 主要版本之间保持 ABI 兼容,它必须通过限制自己使用来独占使用 Node-API

¥Thus, for an addon to remain ABI-compatible across Node.js major versions, it must use Node-API exclusively by restricting itself to using

#include <node_api.h> 

并通过检查它使用的所有外部库,外部库使 ABI 稳定性保证类似于 Node-API。

¥and by checking, for all external libraries that it uses, that the external library makes ABI stability guarantees similar to Node-API.