Shrink install footprint: strip prebuilts (-90%) + drop unused deps#485
Merged
Conversation
The Linux Release build embeds full DWARF debug info (binding.gyp passes -g so local `npm run build` stays debuggable), leaving the published addon unstripped at ~5.1 MB. Strip the packaged copy in publish(), right before `node-pre-gyp package` archives it — local builds keep their symbols, but the prebuilt users download shrinks dramatically: binary: 5,096,472 -> 537,600 bytes (-89%) download: 1,885,792 -> 163,225 bytes (-91%, tar.gz) A post-strip smoke test loads the stripped addon so a bad strip aborts the publish instead of shipping an unloadable binary. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
None of these are needed at runtime by lib/: - unindent: entirely unused (the cairo generators use a local src/modules/cairo/indent.js, not this package) - lodash.isequal: only used by the test harness — replaced with node:util's isDeepStrictEqual (built in) - remove-trailing-spaces: only used by the build-time cairo code generators (whose output is committed) — moved to devDependencies Shrinks what every consumer installs; no runtime behavior change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Context
Investigated startup time for the hello-world example. Key finding: node-gtk's controllable startup is only ~55ms of the ~385ms real hello-world startup — the rest is Node itself (~17ms), GTK/libadwaita init (~55ms), and first-frame/compositor rendering (~180ms). The binding layer is already well-optimized by the prior lazy-GIR work, and the one thing that looked like free time — the ~31ms of eager GType registration in
GetInfoEntries— is load-bearing: skipping it made real startup ~20ms slower (it just moves the cost onto widget construction). So there's no meaningful startup win left to take there.What the investigation did surface are two real footprint wins, which is what this PR does. Neither changes runtime behavior or measurably affects startup — they reduce install/download size and dependency surface.
1. Strip prebuilt binaries (
ci: …)The Linux Release build ships unstripped with full DWARF (
binding.gyppasses-gso local crashes stay debuggable), so the published addon is ~5.1 MB. This strips the packaged copy inpublish()— only that copy, right beforenode-pre-gyp package— so localnpm run buildkeeps its symbols while the prebuilt users download shrinks:.nodebinary.tar.gz)DWARF lives in non-loaded
.debug_*sections, so this is a pure download/install win —dlopenis unchanged (~2.5→2.2ms). A post-strip smoke test loads the stripped addon so a bad strip aborts the publish instead of shipping something unloadable.Scope note: only Linux/macOS (
scripts/ci.sh). The Windows build is MSVC (debug info → separate.pdb, not shipped) and bundles the full GTK runtime, so the.nodestrip there is negligible — left as a possible follow-up.2. Drop unused runtime dependencies (
build: …)Verified by grepping every
require()acrosslib/,bin/,src/,tools/,tests/:unindent— entirely unused; the cairo generators use a localsrc/modules/cairo/indent.js, not this package. Removed.lodash.isequal— only the test harness used it. Replaced withnode:util's built-inisDeepStrictEqual. Removed.remove-trailing-spaces— only the build-time cairo code generators use it (and their output is committed). Moved todevDependencies.Removes 3 packages (+ transitive) from every consumer install, zero runtime behavior change. (Only
lodash.camelcase/lodash.snakecaseactually load at startup — ~1.3ms combined — so deps were never a startup factor.)Verification
require.jsfailure ("some modules failed to load") is pre-existing and environment-specific (system Peas/PeasGtk typelibs) — reproduces identically on cleanmaster, unrelated to these changes.isDeepStrictEqualswap: allexpect()-based tests pass.Gtk.Box/Windowresolve) →node-pre-gyp packagesucceeds; tarball 11.5× smaller.bash -n scripts/ci.shclean;strip_binariesverified idempotent with smoke test.🤖 Generated with Claude Code