Skip to content

fix: skip native build when a bundled prebuild matches the platform#1

Merged
AlexanderSlaa merged 1 commit into
mainfrom
fix/skip-build-when-prebuild-matches
Jun 24, 2026
Merged

fix: skip native build when a bundled prebuild matches the platform#1
AlexanderSlaa merged 1 commit into
mainfrom
fix/skip-build-when-prebuild-matches

Conversation

@AlexanderSlaa

Copy link
Copy Markdown
Contributor

Summary

  • npm's automatic node-gyp invocation (via binding.gyp + gypfile) ran unconditionally on every install, even on platforms where bin/<triplet>/ already had a matching prebuild — forcing every consumer on a supported architecture to have a full C++ toolchain, pkg-config, libmnl-dev, and libsodium-dev installed just to immediately discard the build and use the prebuild at runtime anyway.
  • gypfile is now false, replaced with an explicit install script (scripts/install.js) that checks for a matching prebuild first and only falls back to node-gyp rebuild when none exists.
  • node-gyp moved from devDependencies to dependencies, since the fallback build path needs it available for consumers too, not just local development.
  • Unsupported architectures and local development (no bin/ prebuild present yet) are unaffected — they still build from source exactly as before.

Test plan

  • npm install in a fresh clone (no bin/ prebuild) still builds from source successfully and all existing tests pass (npm test, including the real kernel-backed netlink tests, run as root)
  • npm run package && npm pack, then installed the resulting tarball as a dependency in a separate test project — confirmed via --foreground-scripts that the install step prints "using the bundled prebuild... skipping the native build" and never invokes node-gyp
  • Required the installed module and confirmed generatePrivateKey()/publicKey()/WireGuardClient all work correctly from the prebuild
  • Reviewed .github/workflows/ci.yml — no changes needed; the test and package-dry-run jobs run before any prebuild exists (so they still exercise the from-source build path with the toolchain they already install), and release builds+stages its own x86_64 prebuild as before

npm's automatic node-gyp invocation (triggered by binding.gyp + gypfile)
ran unconditionally on every install, even when bin/<triplet>/ already
had a matching prebuild for this platform/arch — forcing every consumer
on a supported architecture to have a full C++ toolchain, pkg-config,
libmnl-dev, and libsodium-dev installed just to skip straight back to
that same prebuild at runtime.

Sets "gypfile": false and replaces it with an explicit "install" script
that checks for a matching prebuild first and only falls back to
`node-gyp rebuild` (now a regular dependency, not a devDependency, since
this fallback path needs to work for consumers too) when none exists —
unsupported architectures and local development (no bin/ prebuild present)
are unaffected and still build from source as before.
@AlexanderSlaa AlexanderSlaa merged commit cebb243 into main Jun 24, 2026
8 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.

1 participant