Repository navigation
Switch Node.js CI and development builds from node-gyp to Bazel - #1426
Merged
Merged
Conversation
The npm-install source-build fallback (binding.gyp + node-gyp-build) stays
in place for tarball installs without a scoped binary package, but the main
CI test job, the Makefile target, and source-checkout development now build
the addon and prebuild assets with Bazel, the same path the npm release uses.
Detailed Changes:
- **.github/workflows/nodejs.yml**:
- build-and-test now builds prebuilds/ with build-node-prebuild-bazel.sh
and runs npm test with PREBUILDS_ONLY=1, instead of relying on the
implicit node-gyp build from npm ci and prebuildify.
- Move the Windows job to windows-2025-vs2026, the runner already used
for native Bazel builds in bazel.yml, and add Bazel/Python/BuildBuddy
setup mirroring bazel.yml.
- pack-source-install is unchanged; it still covers the shipped
node-gyp source-build fallback for tarball installs.
- **scripts/install.js**:
- Skip the node-gyp-build step in source checkouts and point developers
at the Bazel script; tarball installs keep the fallback behavior.
- **node/opencc.js**:
- Honor PREBUILDS_ONLY (the node-gyp-build convention CI and docs
already reference) by skipping the build/Release lookup, so prebuild
tests cannot silently pick up a stale local build.
- **scripts/build-node-prebuild-bazel.sh**:
- Default to the host platform when no target argument is given.
- **Makefile, CONTRIBUTING.md, node/PUBLISHING.md**:
- Update the make node target and developer instructions to the Bazel
build flow.
The AppVeyor npm packaging job builds from a source checkout with npm_config_build_from_source=true and expects `npm install` to produce build/Release before `npm test`. Keep the source-checkout skip for regular development, but respect the standard npm --build-from-source escape hatch so that job (and anyone explicitly requesting a node-gyp build) still works.
The previous commit made the install script consult the @opencc/opencc-<platform>-<arch> scoped package before the node-gyp build even in source checkouts. On AppVeyor, plain `npm install` pulls the published scoped optionalDependency, so the build-from-source request exited early and `npm test` ran against the released 1.4.1 addon and its bundled dictionaries instead of the checked-out sources, failing the test cases added since that release. Restrict the scoped-package early exit to tarball installs, and let build-from-source force a local compile there too, matching the standard npm flag semantics.
`node-gyp prebuild` is not a real command; the npm script is `npm run prebuild`.
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
First step of removing the gyp / node-gyp / node-gyp-build dependencies: the main Node.js CI job, the
make nodetarget, and source-checkout development no longer invoke node-gyp. They now build the addon and prebuild assets with Bazel viascripts/build-node-prebuild-bazel.sh— the same path the npm binary release already uses.The npm-install source-build fallback (
binding.gyp+node-gyp-build) is intentionally kept in this step for tarball installs on platforms without an@opencc/opencc-*scoped binary package (#1409), and remains covered by the unchangedpack-source-installCI job. Removing that fallback (and then deletingbinding.gyp, the.gypifiles, and the npm gyp dependencies) is planned as follow-up steps.Changes
.github/workflows/nodejs.yml:build-and-testbuildsprebuilds/withbuild-node-prebuild-bazel.shand runsnpm testwithPREBUILDS_ONLY=1, instead of relying on the implicit node-gyp build fromnpm ciplusprebuildify. The Windows job moves fromwindows-2022towindows-2025-vs2026, the runner bazel.yml already uses for native Bazel builds (including//node/test:node_test), with the same Bazel/Python/BuildBuddy setup.npm ci --omit=optionalkeeps published scoped binaries out of the test environment.scripts/install.js: source checkouts skip the node-gyp-build step (with a hint to run the Bazel script); tarball installs keep the existing fallback behavior.node/opencc.js:PREBUILDS_ONLY— the node-gyp-build env var that CI and CONTRIBUTING.md still reference — is now honored by the addon lookup (skipsbuild/Release). Previously it was a no-op since the direct filesystem lookup replaced node-gyp-build, so "prebuild" test steps could silently pick up a stale local build.scripts/build-node-prebuild-bazel.sh: defaults to the host platform when no target is given.Makefile:make nodecalls the Bazel script instead ofnode-gyp configure && node-gyp build.CONTRIBUTING.md/node/PUBLISHING.md: developer instructions updated to the Bazel flow.Testing
bash -n/node --checkon the edited scripts; YAML validated.node scripts/install.jsin the source checkout prints the hint and exits 0.PREBUILDS_ONLY=1skips thebuild/Releasecandidate (default lookup attempts it, env var set falls through to prebuilds/scoped lookup).npm testrelies on this PR's CI (no Bazel in the local sandbox).🤖 Generated with Claude Code
https://claude.ai/code/session_011sQk5XBhgd3BcgbfMWUmva
Generated by Claude Code