From 73d929da97f5d83a51b0f4b44a831c6996255b55 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Thu, 30 Oct 2025 16:29:51 +0100 Subject: [PATCH] src: include `node_api_types.h` instead of `node_api.h` in `node.h` Including `node.h` should not result in all of Node-API also being available to callers. Users who want `node_api.h` contents should explicitly include that header. We currently include it specifically for `napi_addon_register_func`; by moving that into `node_api_types.h` and including that instead, we can reduce unintentionally included API surface a lot. Refs: https://github.com/nodejs/node/pull/60345#issuecomment-3463904087 --- src/node.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/node.h b/src/node.h index 75553fb119fae4..f04e461aa6e59d 100644 --- a/src/node.h +++ b/src/node.h @@ -76,7 +76,7 @@ #include "v8-platform.h" // NOLINT(build/include_order) #include "node_version.h" // NODE_MODULE_VERSION -#include "node_api.h" +#include "node_api_types.h" // napi_addon_register_func #include #include @@ -124,6 +124,7 @@ // Forward-declare libuv loop struct uv_loop_s; +struct napi_module; // Forward-declare these functions now to stop MSVS from becoming // terminally confused when it's done in node_internals.h