perf(packaging): strip unused Electron locale .lproj dirs (-36 MB) - #47
Merged
Conversation
Chromium's Electron Framework ships ~55 .lproj directories with translated UI strings (menus, error pages, accessibility labels) for every locale it supports. We're English-only, so all but en.lproj/en_GB.lproj are dead weight inside the .app. electronLanguages can't filter these — they're macOS-style strings dirs, not the per-locale .pak files that flag targets. Add a small afterPack hook that walks the framework's Resources/ and removes non-English .lproj dirs after Electron is staged but before signing. .cjs extension because the package's "type": "module" would otherwise load the hook as ESM and fail on require/module.exports. Result on the latest dist build: • stripped 53 unused .lproj dirs (36.4 MB) .app: 751M -> 695M (-56 MB) Electron Framework: 223M -> 185M (-38 MB) dmg: ~250 MB zip: ~244 MB Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced Apr 25, 2026
Open
7 tasks
dbbaskette
added a commit
that referenced
this pull request
Apr 25, 2026
…52) Three categories of dead weight identified from a fresh inventory of the post-#47 build, all verified safe via the existing /diarize smoke on pyannote's bundled sample.wav. Sidecar (PyInstaller post-build prune) - strip **/*.pyi type stubs (4+ MB across torch / numpy / scipy) - strip *.dist-info/{RECORD,WHEEL,INSTALLER,REQUESTED,top_level.txt} pip-bookkeeping files (torch's RECORD alone was 2.1 MB). LICENSE / NOTICE / AUTHORS files inside dist-info are kept — MIT/Apache-2/BSD require redistributing them. - drop torch/bin/protoc + torch/bin/protoc-3.13.0.0 (~8 MB). Both are the protobuf compiler — a build-time codegen tool. Torch ships pre-generated message classes, so inference never invokes protoc. Sidecar (additional --exclude-module entries) - scipy.io._fast_matrix_market — Matrix Market reader, never called - hf_xet — Xet large-file backend; HF falls back to plain HTTP - uvloop — alternative asyncio loop; unused on our path Tried but reverted (documented in build-bundle.sh): - scipy.optimize._highspy — caught by /diarize. scipy.optimize.__init__ unconditionally imports _linprog → _linprog_highs → _highspy via the lightning → torchmetrics → scipy.signal → scipy.interpolate chain. Restored. app.asar - Drop **/*.map, **/*.d.ts, **/*.d.ts.map from prod node_modules (the remark/mdast tree alone leaks 263 .map files). README, CHANGELOG, HISTORY also dropped — pure docs, no license clause requires redistributing them. LICENSE / NOTICE / AUTHORS kept. Verification: /health 200, /diarize 200 with 13 segments + two speakers on the bundled sample.wav. Result vs post-#47 build: .app: 695M -> 669M (-26 MB) dmg: 250M -> 242M (-8 MB) zip: 244M -> 237M (-7 MB) Follow-ups filed: #48 (PyInstaller --strip), #49 (drop SwiftShader/ GLESv2 from Electron), #50 (compression: maximum). Co-authored-by: Claude Opus 4.7 (1M context) <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.
Summary
afterPackhook (build/strip-electron-locales.cjs) that removes Chromium's unused.lprojstrings dirs from the stagedElectron Framework.framework. Keeps onlyen.lprojanden_GB.lproj.electronLanguagesdoesn't reach these — they're macOS-style strings directories, not the per-locale.pakfileselectronLanguagesfilters..cjsbecause the package's"type": "module"would otherwise load it as ESM and fail onrequire/module.exports.Why this is safe
en.lprojcleanly when a requested locale isn't present (Apple's standard missing-locale fallback chain).Result on the latest local
distbuildTest plan
npm run distcompletes (exit 0)Resources/contains onlyen.lprojanden_GB.lprojpost-build.appto confirm Electron starts and the renderer comes upen.lproj)🤖 Generated with Claude Code