fix: skip native build when a bundled prebuild matches the platform#1
Merged
Merged
Conversation
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.
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
binding.gyp+gypfile) ran unconditionally on every install, even on platforms wherebin/<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.gypfileis nowfalse, replaced with an explicitinstallscript (scripts/install.js) that checks for a matching prebuild first and only falls back tonode-gyp rebuildwhen none exists.node-gypmoved fromdevDependenciestodependencies, since the fallback build path needs it available for consumers too, not just local development.bin/prebuild present yet) are unaffected — they still build from source exactly as before.Test plan
npm installin a fresh clone (nobin/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-scriptsthat the install step prints "using the bundled prebuild... skipping the native build" and never invokes node-gypgeneratePrivateKey()/publicKey()/WireGuardClientall work correctly from the prebuild.github/workflows/ci.yml— no changes needed; thetestandpackage-dry-runjobs run before any prebuild exists (so they still exercise the from-source build path with the toolchain they already install), andreleasebuilds+stages its own x86_64 prebuild as before