From 7d9a777a615254906a2cb2caa2ebf3e7744fd104 Mon Sep 17 00:00:00 2001 From: OrcaWin Date: Fri, 16 Oct 2026 00:48:16 -0700 Subject: [PATCH] perf(ci): skip unused main source maps in PR build fixtures (#29512) Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com> --- .github/workflows/e2e.yml | 1 + .github/workflows/pr.yml | 4 +++ .../electron-vite-output-contract.test.ts | 28 +++++++++++++++++++ electron.vite.config.ts | 6 ++++ 4 files changed, 39 insertions(+) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 71df770da5b..4430bc84063 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -106,6 +106,7 @@ jobs: - name: Build E2E outputs env: VITE_EXPOSE_STORE: 'true' + ORCA_CI_MAIN_SOURCEMAPS: '0' run: pnpm run build:electron-vite:parallel --mode e2e # The CLI emits into out/main too; start only after Electron finishes clearing that tree. diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index a92de3c7ce4..45dada409ed 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1154,6 +1154,8 @@ jobs: timeout 300 sudo apt-get install -y cpio rpm - name: Build package inputs + env: + ORCA_CI_MAIN_SOURCEMAPS: '0' run: | status=0 pnpm run build:cli || status=1 @@ -1420,6 +1422,8 @@ jobs: # electron-vite targets overlap instead of running back to back. The Linux package # job already packages and smoke-tests an AppImage built that way. - name: Build package inputs + env: + ORCA_CI_MAIN_SOURCEMAPS: '0' run: pnpm run build:release:parallel - name: Prepare Electron native runtime diff --git a/config/scripts/electron-vite-output-contract.test.ts b/config/scripts/electron-vite-output-contract.test.ts index 1459c31ec30..631fdc42cc5 100644 --- a/config/scripts/electron-vite-output-contract.test.ts +++ b/config/scripts/electron-vite-output-contract.test.ts @@ -79,6 +79,34 @@ const electronBuilderConfig = require('../electron-builder.config.cjs') const { FileMatcher } = require('app-builder-lib/out/fileMatcher') describe('Electron Vite output contract', () => { + it('skips main maps only for explicit check builds and always keeps official release maps', async () => { + try { + for (const [setting, identity, expected] of [ + [undefined, undefined, 'hidden'], + ['false', undefined, 'hidden'], + ['1', undefined, 'hidden'], + ['0', undefined, false], + ['0', 'stable', 'hidden'], + ['0', 'rc', 'hidden'] + ] as const) { + vi.stubEnv('ORCA_CI_MAIN_SOURCEMAPS', setting) + vi.stubEnv('ORCA_BUILD_IDENTITY', identity) + vi.resetModules() + const { electronViteConfig: configured } = await import('../../electron.vite.config') + expect(configured.main?.build?.sourcemap).toBe(expected) + expect(configured.main?.build?.minify).toBe(electronViteConfig.main?.build?.minify) + expect(configured.main?.build?.rollupOptions?.input).toEqual( + electronViteConfig.main?.build?.rollupOptions?.input + ) + expect(configured.renderer?.build).toEqual(electronViteConfig.renderer?.build) + expect(configured.preload?.build).toEqual(electronViteConfig.preload?.build) + } + } finally { + vi.unstubAllEnvs() + vi.resetModules() + } + }) + it('can skip main source maps during development without changing build output settings', () => { try { vi.stubEnv('ORCA_DEV_MAIN_SOURCEMAPS', undefined) diff --git a/electron.vite.config.ts b/electron.vite.config.ts index 4ef41ff12cf..225c30415f1 100644 --- a/electron.vite.config.ts +++ b/electron.vite.config.ts @@ -233,6 +233,12 @@ export const electronViteConfig: UserConfig = { // bundle never references maps that packaging strips out. Release CI // uploads them so minified crash traces stay decodable. sourcemap: 'hidden', + // PR fixtures discard maps; official releases must always retain them. + ...(process.env.ORCA_CI_MAIN_SOURCEMAPS === '0' && + orcaBuildIdentity !== 'stable' && + orcaBuildIdentity !== 'rc' + ? { sourcemap: false } + : {}), // Why: daemon-entry.js is asar-unpacked so child_process.fork() can // execute it from disk. Node's module resolution from the unpacked // directory cannot reach into app.asar; startup-critical pure JS must