Migrate native addon from V8 API to node-addon-api, add Bun support#1259
Open
zaccharyfavere wants to merge 6 commits into
Open
Migrate native addon from V8 API to node-addon-api, add Bun support#1259zaccharyfavere wants to merge 6 commits into
zaccharyfavere wants to merge 6 commits into
Conversation
- Rewrite the native addon (cjson, common, fromjs, tojs, main) from V8 direct
API to node-addon-api for better ABI stability across Node.js versions.
- Add #include <sstream> in common.cc for std::ostringstream support.
- Add Bun runtime support:
- New unit test spec (tests/src/addon.bun.spec.ts) running the test suite
under Bun via mocha with a dedicated .mocharc.bun.json config.
- New shell script (tests/examples/bun/run_examples.sh) executing examples
under Bun in src mode.
- New Makefile targets: test-bun-unit, test-bun-examples,
test-skipruntime-ts-bun.
- Adapt database example for dual-runtime compatibility:
- Use dynamic import to select bun:sqlite under Bun, better-sqlite3 under
Node, via a small getDatabase() helper in database.ts and database-server.ts.
- Switch to positional SQL parameters (?) for compatibility between the two
sqlite drivers.
- Use JSON.stringify in groups-client.ts and database-client.ts to produce
deterministic output across runtimes.
- Update database.exp.out and groups.exp.out to match the JSON.stringify
output format.
- Add node-addon-api 8.7.0 as a dependency of @skipruntime/native.
- Apply clang-format to addon C++ sources, prettier to TS/JSON files per the repo's 'make fmt' standards. - Exclude tests/src/addon.bun.spec.ts from eslint's typed-linting since it is intentionally outside the tsconfig project (it is excluded from tsc compilation because it uses Bun-specific features).
The no-unsafe-call rule covers both unsafe calls and unsafe constructions on any-typed values, so a single pragma is sufficient. Other disable directives reported errors as unused (no-explicit-any, no-unsafe-construction) so they are removed.
Regenerates package-lock.json to incorporate both upstream's engines.node relaxation (SkipLabs#1262) and the node-addon-api dependency added for the V8 to node-addon-api migration.
The original code used the BSD-style u_int32_t typedef in SkipRuntime_getChangeManager. Replace it with the C99 standard uint32_t for portability (u_int32_t is not available on all platforms, e.g. MSVC without specific includes).
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.
cc @skiplabsdaniel