Skip to content

perf(build): minify desktop JavaScript bundles without dropping crash context - #17527

Merged
nwparker merged 3 commits into
stablyai:mainfrom
nwparker:nwparker/pr-size-minify-20260830
Aug 31, 2026
Merged

nwparker merged 3 commits into
stablyai:mainfrom
nwparker:nwparker/pr-size-minify-20260830

Conversation

@nwparker

Copy link
Copy Markdown
Contributor

What this changes

Use esbuild minification for the Electron main and renderer bundles, while keeping function/class names (keepNames: true). This reduces shipped JavaScript without changing the crash-report fields or the bootstrap diagnostics path.

ELI5

The build currently ships JavaScript with extra spaces and repeated spelling. The minifier packs that code down. keepNames leaves the useful labels on errors, so crash reports still say which function failed instead of only showing anonymous letters.

Measurement (macOS arm64, unpacked dist/mac-arm64/Orca.app)

Payload Before After Change
Total app ~531 MB ~495 MB ~36 MB smaller
app.asar 137,717,677 B 112,521,710 B 25,195,967 B smaller
Main bundle ~12.28 MB 7,483,700 B ~4.8 MB smaller
Renderer output ~69 MB 46,973,659 B ~22 MB smaller

Installer compression is not included in these numbers.

Crash-report/debugability contract

  • Error.stack and React componentStack are still captured and persisted unchanged by the existing crash-report path.
  • Generic renderer errors still retain filename/line/column fields and durable breadcrumbs.
  • Minidump signatures remain independent of JavaScript minification.
  • keepNames: true is asserted by config/scripts/electron-vite-output-contract.test.ts.
  • Release bundles do not contain source maps today; minified line/column frames are therefore less source-level friendly. That is a documented observability tradeoff, not a dropped crash field. A future release-symbol archive can add hidden maps without putting them in the installed app.

Readiness checklist

Reviewed against all eight sections:

  • SSH/remote/network: no SSH, relay, RPC, or network code changed.
  • Crash/retry/growth: no new retry, timer, listener, buffer, or unbounded state; crash fields remain covered above.
  • Security/supply chain: no dependency, install hook, secret, or network-sink change.
  • Performance/resources: measured bundle and app reductions above; no runtime hot path added.
  • Functional correctness: output contract test plus packaged Electron/CDP smoke test passed.
  • Backward compatibility/data loss: no persisted state, schema, IPC, or mobile surface changed.
  • Cross-platform/remoting: Vite config is platform-neutral; target builds use the same contract.
  • Code organization: build policy remains in the existing Vite config and contract test.

Verdict: PASS. No proven P0/P1/P2 findings. Residual risk is limited to unsymbolicated minified source locations; function names and all existing crash evidence remain available.

Validation

  • pnpm exec vitest run config/scripts/electron-vite-output-contract.test.ts (and focused packaging suite): 55/55 tests passed.
  • pnpm run tc:node passed.
  • Changed-file code-quality and formatting checks passed.
  • pnpm run build:unpack passed.
  • Packaged Electron/CDP smoke test passed with zero console errors/warnings.

@greptile-apps

greptile-apps Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

Greptile Summary

The PR minifies Electron main and renderer bundles using Rolldown’s OXC minifier and generates hidden source maps for the main bundle.

  • Excludes generated source maps from packaged application contents.
  • Adds output-contract coverage for minification and source-map packaging settings.
  • Preserves existing build entry and renderer manifest configuration.

Confidence Score: 5/5

The PR appears safe to merge because no eligible blocking failure remains in the follow-up review scope.

No blocking failure remains.

Important Files Changed

Filename Overview
electron.vite.config.ts Enables OXC minification for main and renderer output and hidden source-map generation for the main bundle.
config/electron-builder.config.cjs Excludes generated source maps from the packaged application.
config/scripts/electron-vite-output-contract.test.ts Adds contract assertions for OXC minification, hidden main source maps, and packaging exclusion.

Reviews (3): Last reviewed commit: "perf(build): minify with rolldown's oxc ..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c6ab9076-65a2-451c-85fc-d89469eb0692

📥 Commits

Reviewing files that changed from the base of the PR and between 6d776f9 and 0d7dbf4.

📒 Files selected for processing (3)
  • config/electron-builder.config.cjs
  • config/scripts/electron-vite-output-contract.test.ts
  • electron.vite.config.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

The Electron Vite main and renderer builds now use Rolldown’s oxc minifier. The main build emits hidden source maps. Electron Builder excludes out/**/*.map files from the packaged application. A contract test verifies the minifier settings, absence of esbuild options, hidden source maps, and packaging exclusion.

Merge Risk: 🔵 Low · up to 0d7db

Release builds now rely on hidden source maps kept outside the installed application; if the matching maps are not archived and retained, crash reports may be harder to interpret at source level. The change is mergeable with explicit owner follow-up on release-symbol storage and retention.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the goal and reports validation, but it describes the implementation as esbuild minification with keepNames, which conflicts with the actual Rolldown oxc minifier, hidden sour… Update the description to match the implemented oxc minifier, hidden main source maps, removed keepNames settings, and packaged-app source-map exclusion. Add the required template sections, including an issue reference after “Fixes #”, Visu…
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary change: minifying desktop JavaScript bundles while preserving crash context.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 3 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the goal and reports validation, but it describes the implementation as esbuild minification with keepNames, which conflicts with the actual Rolldown oxc minifier, hidden source maps, and removed keepNames settings. It also omits or does not complete several required template sections, including Linked Issue, Visual Proof/N/A, Testing, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist.

Resolution

Update the description to match the implemented oxc minifier, hidden main source maps, removed keepNames settings, and packaged-app source-map exclusion. Add the required template sections, including an issue reference after “Fixes #”, Visual Proof with “N/A” and a reason, Testing details and checklist status, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist.

  • Fix all pre-merge checks with AI

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

Comment @coderabbitai help to get the list of available commands.

@nwparker

Copy link
Copy Markdown
Contributor Author

Readiness checklist review — PASS

Reviewed all 8 sections. No proven P0/P1/P2 findings.

  • Crash/debugability: Error.stack, React componentStack, generic filename/line/column fields, durable breadcrumbs, and minidump signatures remain in the existing paths. keepNames: true is contract-tested. The only residual is that release bundles have no source maps, so minified locations are less source-level friendly; no crash field is dropped.
  • SSH/mobile/remoting/data: no SSH, relay, RPC, persisted-state, schema, or mobile-facing surface changed.
  • Security: no dependency, installer, secret, or network-sink change.
  • Performance: measured ~36 MB unpacked macOS arm64 reduction; no runtime hot path added.
  • Functional/cross-platform: output contract, typecheck, packaging, and Electron smoke checks passed; config is platform-neutral.

ELI5: code gets smaller, but the names and evidence that explain a crash stay attached.

@nwparker

Copy link
Copy Markdown
Contributor Author

Debugability clarification: minification does not preserve original source line numbers. It does preserve the crash-report fields (errorStack, componentStack, filename/line/column, breadcrumbs) and function/class names via keepNames; the installed artifact has no source maps, so source-level remapping remains a documented follow-up rather than part of this size PR.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Enable esbuild minification for the Electron main and renderer bundles — electron.vite.config.ts sets build.minify: 'esbuild' plus esbuild.keepNames: true on both the main and renderer configs, turning on minification that electron-vite's presets otherwise default to false.
  • Add output-contract assertions — a new config/scripts/electron-vite-output-contract.test.ts case pins the minify/keepNames settings for both environments.

Verified the mechanics independently: electron-vite 5.0.0 defaults build.minify to false for main/preload/renderer, so this is the change that actually enables minification. Vite 7.3.1 (rolldown-vite) honors esbuild.keepNames when build.minify === 'esbuild' — its vite:esbuild-transpile plugin spreads config.esbuild into the esbuild transform options — and a direct esbuild check confirmed that arrow-function components, function declarations, and classes all retain their .name under minify: true, keepNames: true. The bootstrap banners are prepended in generateBundle (after minify), so they ship unminified, and the require("electron") scan in plain-node-entry-guard still matches esbuild's minified output since string literals are preserved.

The observability tradeoff in the PR body is accurate: function/class names survive via keepNames, but minified error_stack frames lose source-level line/column fidelity since release bundles carry no source maps and there is no symbolication pipeline in src/main. That is an accepted, documented cost of this change, not a dropped crash field.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@nwparker

Copy link
Copy Markdown
Contributor Author

CI status note

All eight test shards, typecheck, package, package (Windows), macOS/Linux/Windows native smoke, and both automated code reviews pass. The remaining static-analysis failure is the unchanged baseline src/main/runtime/rpc/dispatcher.ts:323 max-lines error (302 counted lines); verify fails only because it requires static analysis success. Neither failing check implicates this PRs two changed build-config/test files.

'esbuild' made rolldown disable its own minifier and re-print every chunk
through esbuild, which is not a declared dependency and resolves only via
pnpm's shamefullyHoist from electron-vite's tree (0.25.12 against a declared
peer of ^0.27.0). Switching to rolldown's in-process 'oxc' minifier drops
that second pass: main+renderer build falls 23.2s -> 11.9s and ships ~2.7MB
less JavaScript.

keepNames is dropped with it — it cost ~1.5MB and only recovered function
names. main now builds with sourcemap:'hidden', which restores names *and*
locations without emitting a sourceMappingURL. Packaging excludes
out/**/*.map so app.asar is unaffected; release CI publishes the maps.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

The switch from esbuild to minify: 'oxc' silently removed the keepNames guarantee this PR exists to preserve — see the inline comment. Rolldown's default minifier mangles function/class names, so crash context regresses to exactly the single-letter frames the PR title says it avoids.

Reviewed changes

  • Switched the desktop minifier to rolldown's in-process oxc — main.build.minify and renderer.build.minify are now 'oxc', dropping the prior esbuild.keepNames: true overrides (the rationale comment explains why the undeclared esbuild pass was undesirable).
  • Emitted hidden main-process source maps — main.build.sourcemap: 'hidden' emits .js.map without a sourceMappingURL, and !out/**/*.map in electron-builder.config.cjs strips them from app.asar.
  • Updated the output-contract test — the keepNames assertion was replaced with minify: 'oxc' + esbuild-undefined checks and a hidden-sourcemap packaging check that loads electron-builder.config.cjs via createRequire.

ℹ️ Nitpicks

  • The comment at electron.vite.config.ts:203 says "Release CI uploads them so minified crash traces stay decodable," but this PR adds no upload step — the maps are emitted and then stripped with no consumer yet. Consider future-tense wording to match the PR body's "future release-symbol archive" framing.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

Comment thread electron.vite.config.ts
// Why: 'esbuild' makes rolldown disable its own minifier and re-print every
// chunk through esbuild, which is undeclared here and only resolves via
// pnpm hoisting. 'oxc' is rolldown's in-process minifier.
minify: 'oxc',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minify: 'oxc' drops the keepNames guarantee this PR is titled around. Rolldown-vite maps minify: 'oxc' to rolldown's minify: true for non-lib builds, and that minifier mangles function/class names by default — const MyComponent = () => null becomes const e = () => null, so React componentStack and Error.stack will show single letters. The renderer config at line 309 is identical.

Technical details
# Restore function/class names under the oxc minifier

## Affected sites
- electron.vite.config.ts:200 — `main.build.minify: 'oxc'` with no `keepNames` (the `esbuild.keepNames: true` from the prior commit was removed).
- electron.vite.config.ts:309 — `renderer.build.minify: 'oxc'`, same regression.
- config/scripts/electron-vite-output-contract.test.ts:83 — the assertion now pins `esbuild` being `undefined`, so nothing guards name preservation anymore.

## Evidence
- rolldown-vite@7.3.1 `dist/node/chunks/node.js:32742`: `build.minify === 'oxc'` → `output.minify: true` for non-library builds (both main's `cjs` and renderer's `es` format).
- Empirical rolldown run: `minify: true` emits `const e=()=>null;function t(){return 42}var n=class{...}` (names mangled); `minify: true` + `output.keepNames: true` preserves them via a `__name` helper.
- Passing `minify: { compress: true, mangle: { keepNames: true } }` through `build.minify` is NOT an option here: rolldown-vite only honors `'oxc'`, `false`, `'esbuild'`, or `'terser'` at `build.minify`; any object falls through to `false` (no minification).

## Required outcome
- Shipped bundles keep function/class names readable in stack traces (parity with the `esbuild.keepNames: true` behavior the prior commit had), while remaining minified.

## Suggested approach (optional)
- Set `rollupOptions.output.keepNames: true` on both `main` and `renderer` outputs (rolldown maps `esbuildOptions.keepNames` to `output.keepNames`, so this is the direct oxc-era equivalent), and add a contract-test assertion that pins it.

## Open questions for the human (optional)
- Is mangling short-lived locals acceptable as long as declared function/class names survive, or is full name preservation required?

@nwparker
nwparker merged commit 3e2d0f2 into stablyai:main Aug 31, 2026
34 checks passed
nwparker added a commit that referenced this pull request Sep 8, 2026
The macOS, Windows, and both Linux release builds all failed on "Verify
telemetry constants present in app.asar", blocking publish-release:

    ::error::BUILD_IDENTITY constant missing or unexpected value in
    dist/mac-arm64/Orca.app/Contents/Resources/app.asar

The verifier printed no context sample, because the string
`BUILD_IDENTITY` does not occur anywhere in the shipped bundle at all.
#17527 added `minify: 'oxc'` to the main bundle, so oxc renames the
module-local `const BUILD_IDENTITY` to a short identifier.
`BUILD_IDENTITY_RE` keys off the literal name and therefore cannot match a
production bundle. `MINIFIED_TELEMETRY_RE` matches the adjacent injected
identity/key pair instead, which survives renaming.

#11019 created these patterns without that fallback, and its own comment
predicted this exact failure if minification were ever enabled on the main
bundle. The fallback was written on the v1.4.197 release branch in
35f1b0e and never merged back to main, so main has never been able to
verify a minified bundle.

Verified against a real local bundle built with the release env vars
(ORCA_BUILD_IDENTITY=stable, ORCA_POSTHOG_WRITE_KEY=phc_...): the bundle
does not contain "BUILD_IDENTITY"; both the narrowed and the widened
BUILD_IDENTITY_RE fail; MINIFIED_TELEMETRY_RE matches and recovers
identity=stable plus the write key.
nwparker pushed a commit that referenced this pull request Sep 8, 2026
`verify-telemetry-constants.mjs` keys off the literal identifiers
`BUILD_IDENTITY` and `WRITE_KEY`. #17527 turned on `minify: 'oxc'` for the
main bundle, so oxc renames those module-locals and neither name survives
into the shipped bundle — the gate can no longer pass on any platform.

Port the release-branch fix (35f1b0e, shipped in v1.4.197 and never
merged back): `MINIFIED_TELEMETRY_RE` matches the adjacent injected
identity/key pair instead, and the verify falls back to it when the named
declarations are absent. The quote class also accepts backticks, which is
what oxc emits.

Proven against a local release-env build of out/main: literal
"BUILD_IDENTITY" absent, named regexes miss, MINIFIED_TELEMETRY_RE matches
`var xde=`stable`,Sde=`phc_TestKey_abc123`` and recovers both values.

Co-authored-by: Jinwoo-H <jinwoo0825@gmail.com>
brennanb2025 added a commit that referenced this pull request Sep 11, 2026
…nheriting them (#19945)

* fix(release): prune optional natives before the linux arch floor check

The linux-arm64 release build failed packaging, and retried three times:

    [verify-linux-glibc-floor] 1 bundled native binary is built for the
    wrong architecture (target arm64):
      resources/node_modules/@parcel/watcher-linux-x64-glibc/watcher.node
      is x64, expected arm64 (from its own path)

`afterPack` ran `verifyLinuxGlibcFloor` at its top, before
`prunePackagedRuntimeNodeModules`. A cross-build intentionally installs
every optional native variant, so at that point the arm64 slice still
carries the x64 `@parcel/watcher` package that the prune exists to drop.
The check was reading a file that was never going to ship.

Move the floor check below the prune so it inspects the binaries actually
packed. Same ordering as 35f1b0e on the v1.4.197 release branch, which
shipped green and was never merged back to main.

(cherry picked from commit 6400598)
(cherry picked from commit a883e17)

* fix(release): restore the minified telemetry constant fallback

The macOS, Windows, and both Linux release builds all failed on "Verify
telemetry constants present in app.asar", blocking publish-release:

    ::error::BUILD_IDENTITY constant missing or unexpected value in
    dist/mac-arm64/Orca.app/Contents/Resources/app.asar

The verifier printed no context sample, because the string
`BUILD_IDENTITY` does not occur anywhere in the shipped bundle at all.
#17527 added `minify: 'oxc'` to the main bundle, so oxc renames the
module-local `const BUILD_IDENTITY` to a short identifier.
`BUILD_IDENTITY_RE` keys off the literal name and therefore cannot match a
production bundle. `MINIFIED_TELEMETRY_RE` matches the adjacent injected
identity/key pair instead, which survives renaming.

#11019 created these patterns without that fallback, and its own comment
predicted this exact failure if minification were ever enabled on the main
bundle. The fallback was written on the v1.4.197 release branch in
35f1b0e and never merged back to main, so main has never been able to
verify a minified bundle.

Verified against a real local bundle built with the release env vars
(ORCA_BUILD_IDENTITY=stable, ORCA_POSTHOG_WRITE_KEY=phc_...): the bundle
does not contain "BUILD_IDENTITY"; both the narrowed and the widened
BUILD_IDENTITY_RE fail; MINIFIED_TELEMETRY_RE matches and recovers
identity=stable plus the write key.

(cherry picked from commit 39c3e44)
(cherry picked from commit d0bbe44)

* fix(skills): stop asserting readdir order in the skill root walk test

The Windows skill-sharing release gate — which blocks publish-release —
failed on this test, wedging the 1.4.198 cut. The implementation is
correct; the assertion was not.

`findSkillFiles` pushes results in `readdir` order and dedupes visited
directories by realpath, so of the 32 junctions pointing at one target
exactly one survives. The assertion hardcoded both the array order and
which link won. `readdir` order is filesystem-dependent: APFS and ext4
return SKILL.md first, while NTFS enumerates its filename index
alphabetically on the uppercased name, where "LINK00" sorts before
"SKILL.MD" (L=0x4C < S=0x53). Windows therefore returned the same two
paths in the opposite order.

Assert the contract instead: the real file is present, exactly one
link-routed path survives dedup, and nothing else does.

(cherry picked from commit 9a832e9)
(cherry picked from commit 505b85c)

* test(release): pin ported release gate fixes

* style(skills): apply pinned test formatting

---------

Co-authored-by: Neil <neil@stably.ai>
Co-authored-by: Merge Sim <sim@local>
kukapu pushed a commit to kukapu/orca that referenced this pull request Sep 11, 2026
The macOS, Windows, and both Linux release builds all failed on "Verify
telemetry constants present in app.asar", blocking publish-release:

    ::error::BUILD_IDENTITY constant missing or unexpected value in
    dist/mac-arm64/Orca.app/Contents/Resources/app.asar

The verifier printed no context sample, because the string
`BUILD_IDENTITY` does not occur anywhere in the shipped bundle at all.
stablyai#17527 added `minify: 'oxc'` to the main bundle, so oxc renames the
module-local `const BUILD_IDENTITY` to a short identifier.
`BUILD_IDENTITY_RE` keys off the literal name and therefore cannot match a
production bundle. `MINIFIED_TELEMETRY_RE` matches the adjacent injected
identity/key pair instead, which survives renaming.

stablyai#11019 created these patterns without that fallback, and its own comment
predicted this exact failure if minification were ever enabled on the main
bundle. The fallback was written on the v1.4.197 release branch in
35f1b0e and never merged back to main, so main has never been able to
verify a minified bundle.

Verified against a real local bundle built with the release env vars
(ORCA_BUILD_IDENTITY=stable, ORCA_POSTHOG_WRITE_KEY=phc_...): the bundle
does not contain "BUILD_IDENTITY"; both the narrowed and the widened
BUILD_IDENTITY_RE fail; MINIFIED_TELEMETRY_RE matches and recovers
identity=stable plus the write key.

(cherry picked from commit 39c3e44)
(cherry picked from commit d0bbe44)
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
… context (stablyai#17527)

* perf(build): minify desktop JavaScript bundles

* perf(build): minify with rolldown's oxc and emit hidden main source maps

'esbuild' made rolldown disable its own minifier and re-print every chunk
through esbuild, which is not a declared dependency and resolves only via
pnpm's shamefullyHoist from electron-vite's tree (0.25.12 against a declared
peer of ^0.27.0). Switching to rolldown's in-process 'oxc' minifier drops
that second pass: main+renderer build falls 23.2s -> 11.9s and ships ~2.7MB
less JavaScript.

keepNames is dropped with it — it cost ~1.5MB and only recovered function
names. main now builds with sourcemap:'hidden', which restores names *and*
locations without emitting a sourceMappingURL. Packaging excludes
out/**/*.map so app.asar is unaffected; release CI publishes the maps.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant