src: include `node_api_types.h` instead of `node_api.h` in `node.h` by addaleax · Pull Request #60496 · nodejs/node

@nodejs-github-bot nodejs-github-bot added c++

Issues and PRs that require attention from people who are familiar with C++.

lib / src

Issues and PRs related to general changes in the lib or src directory.

needs-ci

PRs that need a full CI run.

labels

Oct 30, 2025

@addaleax addaleax added semver-major

PRs that contain breaking changes and should be released in the next major version.

commit-queue-squash

Add this label to instruct the Commit Queue to squash all the PR commits into the first one.

labels

Oct 30, 2025

juanarbol

addaleax

addaleax added a commit to addaleax/node that referenced this pull request

Oct 31, 2025
This means that `node.h` can include only this file, instead of
the entirety of `node_api.h`.

Split out from nodejs#60496 since
it was rightfully pointed out that the breaking part of the change
should not touch Node-API headers.

nodejs-github-bot pushed a commit that referenced this pull request

Nov 2, 2025
This means that `node.h` can include only this file, instead of
the entirety of `node_api.h`.

Split out from #60496 since
it was rightfully pointed out that the breaking part of the change
should not touch Node-API headers.

PR-URL: #60512
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>

@addaleax

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: nodejs#60345 (comment)

@addaleax addaleax marked this pull request as ready for review

November 2, 2025 18:24

legendecas

RaisinTen

addaleax added a commit that referenced this pull request

Nov 4, 2025
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: #60345 (comment)
PR-URL: #60496
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>

@addaleax addaleax deleted the node-h-only-include-node-api-types.h branch

November 4, 2025 14:48

aduh95 pushed a commit that referenced this pull request

Nov 5, 2025
This means that `node.h` can include only this file, instead of
the entirety of `node_api.h`.

Split out from #60496 since
it was rightfully pointed out that the breaking part of the change
should not touch Node-API headers.

PR-URL: #60512
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>

aduh95 pushed a commit that referenced this pull request

Nov 11, 2025
This means that `node.h` can include only this file, instead of
the entirety of `node_api.h`.

Split out from #60496 since
it was rightfully pointed out that the breaking part of the change
should not touch Node-API headers.

PR-URL: #60512
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>

aduh95 pushed a commit that referenced this pull request

Nov 13, 2025
This means that `node.h` can include only this file, instead of
the entirety of `node_api.h`.

Split out from #60496 since
it was rightfully pointed out that the breaking part of the change
should not touch Node-API headers.

PR-URL: #60512
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>

aduh95 pushed a commit that referenced this pull request

Feb 17, 2026
This means that `node.h` can include only this file, instead of
the entirety of `node_api.h`.

Split out from #60496 since
it was rightfully pointed out that the breaking part of the change
should not touch Node-API headers.

PR-URL: #60512
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>

aduh95 pushed a commit that referenced this pull request

Feb 19, 2026
This means that `node.h` can include only this file, instead of
the entirety of `node_api.h`.

Split out from #60496 since
it was rightfully pointed out that the breaking part of the change
should not touch Node-API headers.

PR-URL: #60512
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>

aduh95 pushed a commit that referenced this pull request

Feb 23, 2026
This means that `node.h` can include only this file, instead of
the entirety of `node_api.h`.

Split out from #60496 since
it was rightfully pointed out that the breaking part of the change
should not touch Node-API headers.

PR-URL: #60512
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>