feat: add experimental Node-API feature infrastructure#31
Open
kraenhansen wants to merge 1 commit intonodejs:mainfrom
Open
feat: add experimental Node-API feature infrastructure#31kraenhansen wants to merge 1 commit intonodejs:mainfrom
kraenhansen wants to merge 1 commit intonodejs:mainfrom
Conversation
Vendor Node-API headers from the Node.js repository (replacing the node-api-headers npm package) and introduce infrastructure for experimental feature support. - Vendor headers from Node.js src/ into include/, including experimental API declarations behind #ifdef NAPI_EXPERIMENTAL - Add scripts/update-headers.mjs to download headers and generate layered .def files via clang AST dump - Add add_node_api_cts_experimental_addon() CMake function that defines NAPI_EXPERIMENTAL for addons using experimental APIs - Add implementor feature declaration (features.js) with globalThis.experimentalFeatures for conditional test execution - Add harness test validating the experimentalFeatures global, ensuring every expected feature is declared as a boolean The .def files are deduplicated layers: js_native_api.def contains stable engine-agnostic symbols, node_api.def adds stable runtime symbols, and the _experimental variants add only experimental symbols. CMake combines the layers when generating MSVC import libraries. Closes nodejs#26
3 tasks
legendecas
approved these changes
Mar 12, 2026
3 tasks
|
Should the GitHub Actions workflow be extended to include experimental builds/tests? |
Contributor
Author
Not really as I see it. Running / skipping tests based on the availability of experimental features is controlled by the harness. I expect a future PR to update the value of the feature flags based on the Node.js version executing the harness. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds infrastructure to support experimental Node-API features in the CTS, enabling future test ports for the six test suites that depend on experimental APIs (
test_dataview,test_sharedarraybuffer,test_object,test_general,test_finalizer,6_object_wrap). Closes #26.node-api-headersnpm package), giving access to experimental API declarations behind#ifdef NAPI_EXPERIMENTALscripts/update-headers.mjsto download latest headers and generate layered Windows.deffiles via clang AST dumpadd_node_api_cts_experimental_addon()CMake function that compiles addons withNAPI_EXPERIMENTALdefinedfeatures.jsharness module) so runtimes declare which experimental features they support viaglobalThis.experimentalFeaturestests/harness/features.js) that ensures all expected feature flags are declared as booleansDesign decisions
NAPI_EXPERIMENTALworks exactly as upstream. Removable ifnode-api-headersever adds experimental support.NAPI_EXPERIMENTALat C level, per-feature guards at JS level — The vendored headers auto-define allNODE_API_EXPERIMENTAL_HAS_*macros whenNAPI_EXPERIMENTALis set. Per-feature granularity is only needed in JS (experimentalFeatures.*)..deffiles — Four deduplicated.deffiles (js_native_api.def,node_api.def,js_native_api_experimental.def,node_api_experimental.def) combined at CMake configure time for Windows import libraries.Test plan
npm run addons:configure && npm run addons:build— addons compile with vendored headersnpm run node:test— all 26 tests pass, including newharness/features.jsnpm run update-headers— headers download and.deffiles regenerate via clang.defimport libraries🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com