src: include node_api_types.h instead of node_api.h in node.h#60496
src: include node_api_types.h instead of node_api.h in node.h#60496addaleax wants to merge 1 commit intonodejs:mainfrom
node_api_types.h instead of node_api.h in node.h#60496Conversation
|
Review requested:
|
| "Experimental features may be unstable." | ||
| #endif | ||
| #endif | ||
|
|
There was a problem hiding this comment.
For context, this was moved because this file actually depends on these macros being applied, so previously there was an implicit requirement that js_native_api.h would need to be included prior to this file, either directly or indirectly.
There was a problem hiding this comment.
I believe this is not a semver-major change. I'm wondering if this can be split into a PR so that it can be backport-ed? Usually we don't mark node-api header changes as semver-major and node-api headers are sync-ed across LTS versions.
There was a problem hiding this comment.
@legendecas Yup, that makes a ton of sense. Opened #60512 with the non-breaking changes to Node-API headers.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #60496 +/- ##
==========================================
+ Coverage 88.54% 88.55% +0.01%
==========================================
Files 704 704
Lines 207843 207843
Branches 40044 40041 -3
==========================================
+ Hits 184028 184057 +29
+ Misses 15858 15834 -24
+ Partials 7957 7952 -5
🚀 New features to boost your workflow:
|
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.
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>
|
Sorry for being late. This needs a rebase after #60512 landed. |
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)
617271c to
73d929d
Compare
|
@legendecas Yep, done! And no worries at all, your input here has been great. |
|
@nodejs/tsc I'd leave this tagged |
Commit Queue failed- Loading data for nodejs/node/pull/60496 ✔ Done loading data for nodejs/node/pull/60496 ----------------------------------- PR info ------------------------------------ Title src: include `node_api_types.h` instead of `node_api.h` in `node.h` (#60496) ⚠ Could not retrieve the email or name of the PR author's from user's GitHub profile! Branch addaleax:node-h-only-include-node-api-types.h -> nodejs:main Labels c++, semver-major, lib / src, needs-ci, review wanted, commit-queue-squash Commits 1 - src: include `node_api_types.h` instead of `node_api.h` in `node.h` Committers 1 - Anna Henningsen <anna@addaleax.net> PR-URL: https://github.com/nodejs/node/pull/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> ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/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> -------------------------------------------------------------------------------- ℹ This PR was created on Thu, 30 Oct 2025 15:31:25 GMT ✔ Approvals: 5 ✔ - Juan José Arboleda (@juanarbol): https://github.com/nodejs/node/pull/60496#pullrequestreview-3400508206 ✔ - Chengzhong Wu (@legendecas) (TSC): https://github.com/nodejs/node/pull/60496#pullrequestreview-3408999164 ✔ - Michaël Zasso (@targos) (TSC): https://github.com/nodejs/node/pull/60496#pullrequestreview-3416771399 ✔ - Filip Skokan (@panva) (TSC): https://github.com/nodejs/node/pull/60496#pullrequestreview-3416773895 ✔ - Darshan Sen (@RaisinTen) (TSC): https://github.com/nodejs/node/pull/60496#pullrequestreview-3416825540 ✘ Last GitHub CI failed ℹ Last Full PR CI on 2025-11-03T16:28:47Z: https://ci.nodejs.org/job/node-test-pull-request/70025/ - Querying data for job/node-test-pull-request/70025/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/19072542185 |
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>
|
Landed in 7d2bc52 |
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>
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>
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>
Edit: Split out #60512 from this PR and marking this PR as blocked on it
Including
node.hshould not result in all of Node-API also being available to callers. Users who wantnode_api.hcontents should explicitly include that header.We currently include it specifically for
napi_addon_register_func; by moving that intonode_api_types.hand including that instead, we can reduce unintentionally included API surface a lot.Refs: #60345 (comment)