build(desktop): reduce installed app size by ~300MB #4824
main fromrefs/pull/4824/head·merged by juliusmarminge View on GitHubWhat Changed#
Desktop app builds now:
- Omit unused binaries from Claude SDK
- Drop unused language packs (T3 Code is en-US only)
- Pack dependencies into ASAR on compatible platforms (macOS/Linux) and retain the Windows-only unpacking for WSL
Why#
The current version of the T3 Code desktop app is unreasonably huge: ~737 MB on arm64 macOS. This made me wonder why it's this big, and turns out it's pretty trivial to fix.
This PR brings it down to ~424 MB without any functional changes:
UI Changes#
None.
Checklist#
- This PR is small and focused
- I explained what changed and why
- I included before/after screenshots for any UI changes
- I included a video for animation/interaction changes
Note
Medium Risk Packaging-only change with a behavioral shift on macOS/Linux (no explicit asarUnpack); risk is native/runtime loading if anything still expected unpacked paths outside smart unpack—Windows WSL path remains explicitly unpacked.
Overview
Cuts installed desktop size (~737MB → ~424MB on arm64 macOS) by tightening electron-builder packaging in createBuildConfig, without changing runtime behavior for normal macOS/Linux backends.
Locale and dependency trimming: All platforms now set electronLanguages to en-US and add files exclusions that drop optional @anthropic-ai/claude-agent-sdk-* platform bundles (the app uses the user’s Claude binary, so those ~200MB packages are unused).
Platform-specific ASAR unpacking: asarUnpack is applied only on Windows via WINDOWS_ASAR_UNPACK (apps/server/dist/** and **/node_modules/** for the WSL backend). macOS and Linux builds no longer set asarUnpack; the old global DESKTOP_ASAR_UNPACK for @ff-labs/fff-bin-* is removed, with comments that native libs are handled via smart unpack / app.asar.unpacked (aligned with the fff-node patch).
Tests were updated to assert the new constants and that mac/linux configs omit asarUnpack while Windows keeps the WSL unpack list.
Note
Reduce desktop app installed size by ~300MB#
- Limits Electron locales to
en-USviaelectronLanguagesincreateBuildConfig, dropping unused locale files. - Excludes optional Claude SDK platform bundles (
@anthropic-ai/claude-agent-sdk-*) from packaged files via newDESKTOP_FILE_EXCLUSIONSconstant. - Makes
asarUnpackWindows-only usingWINDOWS_ASAR_UNPACK; macOS and Linux builds no longer unpack asar contents. - Removes the old
DESKTOP_ASAR_UNPACKconstant that unconditionally unpacked@ff-labs/fff-bin-*on all platforms. - Behavioral Change: macOS and Linux builds no longer include
asarUnpack, which may affect native module loading if any path relied on unpacked asar access.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
Approvability#
Verdict: Approved ff0f7ea
Build/packaging optimization changes only - limits Electron locales to en-US, excludes unused SDK executables, and makes asar unpacking Windows-specific. No runtime logic changes, well-documented rationale, and includes test coverage.
You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).juliusmarminge merged this72b960f
juliusmarminge closed this
I know this is already merged, but build size is something I care about and needed to add my two-cents.
I've dived through
electron-builders output semi extensivly before. I've done it before with an extensive deny lists, but a restrictive allow list is simpler.Node packages include often sourcecode and documentation in their releases. Which isn't really a bad thing, but
electron-builderdoesn't know any better and takes everything.I made this change
export const DESKTOP_FILE_EXCLUSIONS = [ "apps/server/dist/**/*", "apps/desktop/dist-electron/**/*", // electron-builder takes *everything* in the node_modules folder. // which is far too much. So lets filter out the entire folder and // use an allow list to add only what we want. "!**/node_modules/**/*", // We want all JS, node native extensions and json files. "**/node_modules/**/{*.js,*.mjs,*.cjs,*.node,*.json}", // But not tests or examples. "!**/node_modules/*/{test,__tests__,tests,powered-test,example,examples}", "!**/node_modules/@*/*/{test,__tests__,tests,powered-test,example,examples}", ] as const;and reduced the installer size from 146MB to 125MB, and the 'node_modules' folder from 141MB to 71MB.
It should have more testing done, but it does produce an application that launches.
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
57817d93-dc15-46bf-9357-b0406c2fdd13You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share