From c633cdaae77bd6b3c6d30993a506c7916e443af6 Mon Sep 17 00:00:00 2001 From: Rom Grk Date: Sat, 4 Jul 2026 16:50:30 -0400 Subject: [PATCH 1/2] ci: strip prebuilt binaries before publishing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- scripts/ci.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/scripts/ci.sh b/scripts/ci.sh index 8247ce5d..359b69e4 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -19,8 +19,38 @@ if [[ ${COMMIT_MESSAGE} =~ "[skip tests]" ]]; then fi; +# The Linux Release build embeds full DWARF debug info (binding.gyp passes -g so +# a local `npm run build` stays debuggable), which balloons the addon from +# ~0.5MB to ~5MB. Strip the packaged copy — and only that copy, right before +# `node-pre-gyp package` archives it — so every user's download shrinks ~90% +# while local builds keep their symbols. +function strip_binaries() { + echo "### Stripping prebuilt ###" + local os + os=$(uname -s) + for f in lib/binding/*/node_gtk.node; do + [[ -e "$f" ]] || continue + local before after + before=$(wc -c < "$f") + if [[ $os == 'Darwin' ]]; then + strip -x "$f"; + else + strip --strip-unneeded "$f"; + fi + after=$(wc -c < "$f") + echo " $f: ${before} -> ${after} bytes" + done + + # Stripping runs after the test job, so a strip that produced an unloadable + # addon would otherwise ship unnoticed. Smoke-test the stripped binary here; + # `set -e` aborts the publish if it can no longer be loaded. + node -e "require('./lib/index.js').require('GLib', '2.0')" + echo " stripped addon loads OK" +} + function publish() { echo "### Publish ###" + strip_binaries if [[ $PUBLISH_BINARIES == true ]]; then npx node-pre-gyp package testpackage; npx node-pre-gyp publish; From d49dc1f8d13b0cf3f4f5cc0cc9e24896dec53270 Mon Sep 17 00:00:00 2001 From: Rom Grk Date: Sat, 4 Jul 2026 16:50:30 -0400 Subject: [PATCH 2/2] build: drop unused runtime dependencies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- package-lock.json | 22 ++++------------------ package.json | 8 +++----- tests/__common__.js | 4 ++-- 3 files changed, 9 insertions(+), 25 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7bd5a2da..fd2090ae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,12 +12,9 @@ "dependencies": { "@mapbox/node-pre-gyp": "^2.0.3", "lodash.camelcase": "4.3.0", - "lodash.isequal": "4.5.0", "lodash.snakecase": "^4.1.1", "nan": "^2.27.0", - "node-gyp": "^11.2.0", - "remove-trailing-spaces": "^1.0.7", - "unindent": "^2.0.0" + "node-gyp": "^11.2.0" }, "bin": { "node-gtk": "bin/node-gtk.js" @@ -27,7 +24,8 @@ "aws-sdk": "^2.1692.0", "chalk": "^2.4.2", "mocha": "^11.7.0", - "nid-parser": "0.0.5" + "nid-parser": "0.0.5", + "remove-trailing-spaces": "^1.0.7" } }, "node_modules/@isaacs/cliui": { @@ -1340,13 +1338,6 @@ "integrity": "sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==", "license": "MIT" }, - "node_modules/lodash.isequal": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", - "integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==", - "deprecated": "This package is deprecated. Use require('node:util').isDeepStrictEqual instead.", - "license": "MIT" - }, "node_modules/lodash.snakecase": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz", @@ -2069,6 +2060,7 @@ "version": "1.0.9", "resolved": "https://registry.npmjs.org/remove-trailing-spaces/-/remove-trailing-spaces-1.0.9.tgz", "integrity": "sha512-xzG7w5IRijvIkHIjDk65URsJJ7k4J95wmcArY5PRcmjldIOl7oTvG8+X2Ag690R7SfwiOcHrWZKVc1Pp5WIOzA==", + "dev": true, "license": "MIT" }, "node_modules/require-directory": { @@ -2405,12 +2397,6 @@ "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", "license": "MIT" }, - "node_modules/unindent": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/unindent/-/unindent-2.0.0.tgz", - "integrity": "sha512-Mo5gKmshwTR3b2BwCSMish/UuwTqP5W7TIRa88HQTydH+07HhkOCE1P6HZ4lSxJS5klEqXFnhlZSxkxbBOMk4Q==", - "license": "MIT" - }, "node_modules/unique-filename": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/unique-filename/-/unique-filename-4.0.0.tgz", diff --git a/package.json b/package.json index 9433ef72..818579f2 100644 --- a/package.json +++ b/package.json @@ -53,19 +53,17 @@ "dependencies": { "@mapbox/node-pre-gyp": "^2.0.3", "lodash.camelcase": "4.3.0", - "lodash.isequal": "4.5.0", "lodash.snakecase": "^4.1.1", "nan": "^2.27.0", - "node-gyp": "^11.2.0", - "remove-trailing-spaces": "^1.0.7", - "unindent": "^2.0.0" + "node-gyp": "^11.2.0" }, "devDependencies": { "assert": "^1.5.0", "aws-sdk": "^2.1692.0", "chalk": "^2.4.2", "mocha": "^11.7.0", - "nid-parser": "0.0.5" + "nid-parser": "0.0.5", + "remove-trailing-spaces": "^1.0.7" }, "overrides": { "nid-parser": { diff --git a/tests/__common__.js b/tests/__common__.js index 744237d3..b6352930 100644 --- a/tests/__common__.js +++ b/tests/__common__.js @@ -3,7 +3,7 @@ */ const chalk = require('chalk') -const isEqual = require('lodash.isequal') +const { isDeepStrictEqual } = require('node:util') module.exports = { assert, @@ -38,7 +38,7 @@ function isntUndefined(value, message) { } function expect(value, expected) { - assert(isEqual(value, expected), + assert(isDeepStrictEqual(value, expected), `Expected: "${expected}", got: "${value}"`) return value }