Skip to content

Switch Node.js CI and development builds from node-gyp to Bazel - #1426

Merged
BYVoid merged 4 commits into
masterfrom
claude/remove-gyp-dependencies-gn5vlc
Jul 15, 2026
Merged

BYVoid merged 4 commits into
masterfrom
claude/remove-gyp-dependencies-gn5vlc

Conversation

@BYVoid

@BYVoid BYVoid commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Summary

First step of removing the gyp / node-gyp / node-gyp-build dependencies: the main Node.js CI job, the make node target, and source-checkout development no longer invoke node-gyp. They now build the addon and prebuild assets with Bazel via scripts/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 unchanged pack-source-install CI job. Removing that fallback (and then deleting binding.gyp, the .gypi files, and the npm gyp dependencies) is planned as follow-up steps.

Changes

  • .github/workflows/nodejs.yml: build-and-test 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 plus prebuildify. The Windows job moves from windows-2022 to windows-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=optional keeps 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 (skips build/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 node calls the Bazel script instead of node-gyp configure && node-gyp build.
  • CONTRIBUTING.md / node/PUBLISHING.md: developer instructions updated to the Bazel flow.

Testing

  • bash -n / node --check on the edited scripts; YAML validated.
  • node scripts/install.js in the source checkout prints the hint and exits 0.
  • Verified PREBUILDS_ONLY=1 skips the build/Release candidate (default lookup attempts it, env var set falls through to prebuilds/scoped lookup).
  • Full Bazel build + npm test relies 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

claude added 4 commits July 14, 2026 22:35
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`.
@BYVoid
BYVoid merged commit 2dbbe00 into master Jul 15, 2026
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants