refactor(code): migrate build and dev to electron-vite#2811
refactor(code): migrate build and dev to electron-vite#2811charlesvien wants to merge 12 commits into
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
|
React Doctor found no issues in the changed files. 🎉 Reviewed by React Doctor for commit |
e25d4d1 to
105cec7
Compare
ab18bbc to
3efbf3f
Compare
|
There was a problem hiding this comment.
Gates denied because this PR touches CI/CD workflows and build/dependency toolchain — both on the deny-list for auto-approval. Additionally, there is an unresolved substantive inline comment flagging that autoServicesPlugin was dropped from the preload build in the new consolidated config, which could silently break preload functionality.
105cec7 to
dd8572f
Compare
There was a problem hiding this comment.
Gates denied because this PR touches CI/CD workflows and build/dependency toolchain files, both on the deny-list for auto-approval. Additionally, there is an unresolved inline comment about autoServicesPlugin being dropped from the preload build in the new config, which could silently break preload functionality.
There was a problem hiding this comment.
Gates denied: this PR touches CI/CD workflows and build/dependency toolchain files, both on the deny-list for auto-approval. There is also an unresolved inline comment about autoServicesPlugin being dropped from the preload build, which could silently break preload functionality.
118ea82 to
de167fb
Compare
507c6ab to
d1b0efd
Compare
ab2b60b to
77dc1fa
Compare
77dc1fa to
e4c54c9
Compare
d1b0efd to
8e56223
Compare
There was a problem hiding this comment.
Gates denied: this PR touches CI/CD workflows and build/dependency toolchain files, both on the deny-list for auto-approval. There is also an unresolved inline comment about autoServicesPlugin being dropped from the preload build, which could silently break preload functionality.

Problem
The desktop app's build and dev tooling was hand-rolled: four separate Vite configs (
main,preload,workspace-server,renderer) driven by a 169-linescripts/dev.mjsthat spawned the renderer dev server plus three watch builds plus Electron and parsed stdout for "ready" lines, with a separatescripts/build.mjsto sequence the builds. It worked, but it was a pile of bespoke orchestration to maintain instead of the purpose-built Electron + Vite framework (electron-vite).This replaces that with electron-vite, consolidates the native-module list into a single source of truth, and moves the packaging config to TypeScript.
Stacked on #2795 (the electron-builder migration); review the diff against
feat/electron-builder-migration.Changes
electron-vite
electron.vite.config.tswith{ main, preload, renderer }replaces the fourvite.*.config.mtsfiles.workspace-serveris folded in as a secondmainrollup input (it is a Node entrypoint spawned as a child, the same shape as the bootstrap entry), not a separate build.scripts/dev.mjs(the hand-rolled orchestrator) andscripts/build.mjs.dev/startis nowelectron-vite dev --watch(renderer HMR plus main/preload auto-restart out of the box); the build step iselectron-vite build.vite-main-plugins.mts.window.tsreads electron-vite'sELECTRON_RENDERER_URLin dev, and the CDP:9222port (used by the test-electron-app skill) is set inbootstrap.ts. Output paths are unchanged (.vite/build,.vite/renderer/main_window), so electron-builder,package.jsonmain and the production load path did not move.chunks/, which broke the__dirname-relative path the main process uses to spawnworkspace-server.js. Flattening the chunk output restores the original layout.build-linux-docker.sh,knip.jsonand the package scripts.Native modules: single source of truth
runtime-dependencies.tsis now the only place the native-module list lives, consumed bybefore-pack.ts(staging from the hoisted root),electron-builder.ts(filesplusasarUnpack) and the Vite externals. Verified the generated globs are set-equal to the previous inline lists, so packaging behavior is unchanged.TypeScript configs
electron-builder.config.cjsbecomeselectron-builder.tsandscripts/before-pack.cjsbecomesscripts/before-pack.ts. electron-builder v26 loads.tsconfigs through its bundledjiti, and the beforePack hook is imported as a function so jiti transpiles the wholeelectron-builder.ts -> before-pack.ts -> runtime-dependencies.tsgraph. Nots-nodeortsxis needed.Net result is roughly 200 fewer lines.
How did you test this?
Locally on macOS arm64:
electron-vite dev --watch: the app boots, the renderer loads overELECTRON_RENDERER_URL, and the workspace-server child spawns and connects ([workspace-server] listening on http://127.0.0.1:<port>) with no module or health errors.electron-vite build: produces the expected flat.vite/buildlayout (bootstrap.jsrequiring./index-*.js, a self-contained electron-freeworkspace-server.js, renderer assets with./assets/relative paths).electron-builder build --dir --mac --arm64: confirms jiti loadselectron-builder.ts, thebefore-pack.tshook runs and stages every native module, andout/mac-arm64/PostHog Code.appis produced.pnpm typecheck,biome checkandvitest run(152/152) all pass.runtime-dependencies.tsgeneratesfiles/asarUnpackglobs set-equal to the previous inline lists.Not validated here (needs a tagged CI run, same caveat as the parent PR): the full signed and notarized multi-platform
electron-builderpublish (macOS dmg/zip, Windows, Linux) and end-to-end auto-update.Automatic notifications