fix: prebundle deps before loading electron app #254

Merged
talksik merged 1 commits from fix-unoptimized-deps-error into main 2026-06-09 18:11:01 +00:00
talksik commented 2026-06-09 18:06:37 +00:00 (Migrated from github.com)

Electron Forge restarts the renderer process without fully restarting the Vite dev server, so the browser gets a fresh page with a new hash but the Vite server still has the old pre-bundle cache — mismatch causes the 504 outdated error every other time we launch.

Closes #185

Summary by CodeRabbit

  • Chores
    • Optimized the desktop application startup process.
Electron Forge restarts the renderer process without fully restarting the Vite dev server, so the browser gets a fresh page with a new hash but the Vite server still has the old pre-bundle cache — mismatch causes the 504 outdated error every other time we launch. Closes #185 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Optimized the desktop application startup process. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
coderabbitai[bot] commented 2026-06-09 18:06:53 +00:00 (Migrated from github.com)

Review Change Stack

📝 Walkthrough

Walkthrough

The start npm script in the desktop package is updated to run Vite dependency optimization before launching Electron Forge. This adds a preprocessing step that optimizes dependencies according to vite.main.config.ts configuration.

Changes

Desktop development startup flow

Layer / File(s) Summary
Start script with Vite optimization
js/desktop/package.json
The start script now executes cross-env vite optimize -c vite.main.config.ts before electron-forge start, adding dependency optimization as a pre-launch step.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A script so neat, now optimized right,
Vite warms the deps before Forge takes flight,
No more white screens on every other run,
Dependencies ready—the startup is done!

🚥 Pre-merge checks | 5
Passed checks (5 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title accurately summarizes the main change: prebundling dependencies before loading the Electron app to fix the unoptimized deps issue.
Linked Issues check Passed The PR change directly addresses issue #185 by running vite optimize before electron-forge start, ensuring pre-bundle consistency and preventing the white screen error.
Out of Scope Changes check Passed The single change to the start script in package.json is directly scoped to fixing the vite pre-bundling issue described in issue #185.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-unoptimized-deps-error

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

<!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/flowy-live/llink/pull/254?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## Walkthrough The `start` npm script in the desktop package is updated to run Vite dependency optimization before launching Electron Forge. This adds a preprocessing step that optimizes dependencies according to `vite.main.config.ts` configuration. ## Changes **Desktop development startup flow** |Layer / File(s)|Summary| |---|---| |**Start script with Vite optimization** <br> `js/desktop/package.json`|The `start` script now executes `cross-env vite optimize -c vite.main.config.ts` before `electron-forge start`, adding dependency optimization as a pre-launch step.| ## Estimated code review effort 🎯 1 (Trivial) | ⏱️ ~3 minutes ## Poem > 🐰 A script so neat, now optimized right, > Vite warms the deps before Forge takes flight, > No more white screens on every other run, > Dependencies ready—the startup is done! ✨ </details> <!-- walkthrough_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 5</summary> <details> <summary>✅ Passed checks (5 passed)</summary> | Check name | Status | Explanation | | :------------------------: | :------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. | | Title check | ✅ Passed | The title accurately summarizes the main change: prebundling dependencies before loading the Electron app to fix the unoptimized deps issue. | | Linked Issues check | ✅ Passed | The PR change directly addresses issue `#185` by running vite optimize before electron-forge start, ensuring pre-bundle consistency and preventing the white screen error. | | Out of Scope Changes check | ✅ Passed | The single change to the start script in package.json is directly scoped to fixing the vite pre-bundling issue described in issue `#185`. | | Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. | </details> <sub>✏️ Tip: You can configure your own custom pre-merge checks in the settings.</sub> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- finishing_touch_checkbox_start --> <details> <summary>✨ Finishing Touches</summary> <details> <summary>🧪 Generate unit tests (beta)</summary> - [ ] <!-- {"checkboxId": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} --> Create PR with unit tests - [ ] <!-- {"checkboxId": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} --> Commit unit tests in branch `fix-unoptimized-deps-error` </details> </details> <!-- finishing_touch_checkbox_end --> <!-- tips_start --> --- <sub>Comment `@coderabbitai help` to get the list of available commands and usage tips.</sub> <!-- tips_end --> <!-- internal state start --> <!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKPR1AGxJcAZvAAeXLwkAtgYtF6QStwyJD74FCSQHvhotPAYRJAkXmIU+Fho3NyQkAYAco4ClFwATACsACylBgCCeLAJXLhoHgDWiPB9LQBCVBgMsL4BYGH43OLM8ABedGDRiGCU+XyASYSQzNpYZQDKPbjYiFzzZC0AwonUdHUADLUAbGAvny8AnNAARgAHBxvhwAMwAdgAWi0AKo2AAyXFguFwMQ4AHpMUR1LBsAINExmJifCkAO6yMAeSQkTEeGkYPqY7jYBmYhqNIwAEWkDAo8AW8AKXAAorlcPksAAxBKkSCJRA9Ci4ZC4WBJRLhSiUHj5BjSZDkvH4PCQHxsjzyRXK8SZSDqpIANXUSSUEnslCkFA0kFayDQCukbNwABoHRrIAJ8uTELqUmkA+bFbAeGh5cb1ehIORyZBYGhEKnyQhIo7IC6aJ6KN6gz0MgGsPgPPRgmBQuFIgw0JM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F+EhEaFoGI0ClqOSIEAVQrVUBIDQHBAYCtVNQYAEEaGyNv3BCUHBB6J8A+F+CBAYHqByJXCBHVUaBWMaCKK2wiKdT5WCEDUoFIBDTO1FV9RcT5TJQKUgQXGlUymBLckdXSUGKsHnDjFoFaFwECwlToBTTOhRTCHclBCeNcX+MBLjFBJoB9T0T9SgBOnbV6DxJIDFWgiQA3lBJVHBLEnJAFBoGyWaReABF+BWNoF+HBBIQwiBDAEhAqUhDACBABHaLAHeG2KtR1SUFqHBHeDxSJRJMPDJLqgpI9UGAKAJPoH0CAA --> <!-- internal state end -->
coderabbitai[bot] (Migrated from github.com) reviewed 2026-06-09 18:10:09 +00:00
coderabbitai[bot] (Migrated from github.com) left a comment
🧹 Nitpick comments (2)
js/desktop/package.json (2)

9-9: 💤 Low value

Remove redundant cross-env wrapper.

The cross-env prefix serves no purpose here since no environment variables are set. Other scripts in this file (lines 10-14, 21-23) use cross-env with actual variables like APP_ENV=prod, but this invocation passes no variables to vite.

♻️ Simplify the command
-    "start": "cross-env vite optimize -c vite.main.config.ts && electron-forge start",
+    "start": "vite optimize -c vite.main.config.ts && electron-forge start",
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@js/desktop/package.json` at line 9, The "start" npm script currently wraps
the command in cross-env unnecessarily; update the package.json script named
"start" (the npm script key "start") to remove the redundant cross-env prefix so
it simply runs vite optimize -c vite.main.config.ts && electron-forge start
(i.e., delete "cross-env " from the script value).

9-9: Confirm vite optimize CLI usage in start script
vite optimize is a valid Vite 5.4.21 command (it’s marked deprecated since dependency pre-bundling runs automatically), and -c/--config is supported; vite.main.config.ts exists at js/desktop/vite.main.config.ts. cross-env is redundant here since no environment variables are set.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@js/desktop/package.json` at line 9, Update the "start" script in package.json
to remove the unnecessary cross-env prefix and ensure the Vite command uses the
existing config file; specifically, edit the "start" script string (the "start"
npm script) to run vite optimize -c vite.main.config.ts && electron-forge start
(or remove the vite optimize step entirely if you decide not to run the
deprecated optimize step), referencing the "start" script and
vite.main.config.ts to locate the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@js/desktop/package.json`:
- Line 9: The "start" npm script currently wraps the command in cross-env
unnecessarily; update the package.json script named "start" (the npm script key
"start") to remove the redundant cross-env prefix so it simply runs vite
optimize -c vite.main.config.ts && electron-forge start (i.e., delete "cross-env
" from the script value).
- Line 9: Update the "start" script in package.json to remove the unnecessary
cross-env prefix and ensure the Vite command uses the existing config file;
specifically, edit the "start" script string (the "start" npm script) to run
vite optimize -c vite.main.config.ts && electron-forge start (or remove the vite
optimize step entirely if you decide not to run the deprecated optimize step),
referencing the "start" script and vite.main.config.ts to locate the change.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 13bb0a3e-85b0-4f59-b1b7-a6747b1ffd33

📥 Commits

Reviewing files that changed from the base of the PR and between 946d141897 and cf9c272df7.

📒 Files selected for processing (1)
  • js/desktop/package.json
<details> <summary>🧹 Nitpick comments (2)</summary><blockquote> <details> <summary>js/desktop/package.json (2)</summary><blockquote> `9-9`: _💤 Low value_ **Remove redundant `cross-env` wrapper.** The `cross-env` prefix serves no purpose here since no environment variables are set. Other scripts in this file (lines 10-14, 21-23) use `cross-env` with actual variables like `APP_ENV=prod`, but this invocation passes no variables to `vite`. <details> <summary>♻️ Simplify the command</summary> ```diff - "start": "cross-env vite optimize -c vite.main.config.ts && electron-forge start", + "start": "vite optimize -c vite.main.config.ts && electron-forge start", ``` </details> <details> <summary>🤖 Prompt for AI Agents</summary> ``` Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@js/desktop/package.json` at line 9, The "start" npm script currently wraps the command in cross-env unnecessarily; update the package.json script named "start" (the npm script key "start") to remove the redundant cross-env prefix so it simply runs vite optimize -c vite.main.config.ts && electron-forge start (i.e., delete "cross-env " from the script value). ``` </details> <!-- cr-comment:v1:2faf6c7cbfcf3059c7be4051 --> --- `9-9`: **Confirm `vite optimize` CLI usage in start script** `vite optimize` is a valid Vite 5.4.21 command (it’s marked deprecated since dependency pre-bundling runs automatically), and `-c/--config` is supported; `vite.main.config.ts` exists at `js/desktop/vite.main.config.ts`. `cross-env` is redundant here since no environment variables are set. <details> <summary>🤖 Prompt for AI Agents</summary> ``` Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@js/desktop/package.json` at line 9, Update the "start" script in package.json to remove the unnecessary cross-env prefix and ensure the Vite command uses the existing config file; specifically, edit the "start" script string (the "start" npm script) to run vite optimize -c vite.main.config.ts && electron-forge start (or remove the vite optimize step entirely if you decide not to run the deprecated optimize step), referencing the "start" script and vite.main.config.ts to locate the change. ``` </details> <!-- cr-comment:v1:f16ca4c9506b3160242955cc --> </blockquote></details> </blockquote></details> <details> <summary>🤖 Prompt for all review comments with AI agents</summary> ``` Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. Nitpick comments: In `@js/desktop/package.json`: - Line 9: The "start" npm script currently wraps the command in cross-env unnecessarily; update the package.json script named "start" (the npm script key "start") to remove the redundant cross-env prefix so it simply runs vite optimize -c vite.main.config.ts && electron-forge start (i.e., delete "cross-env " from the script value). - Line 9: Update the "start" script in package.json to remove the unnecessary cross-env prefix and ensure the Vite command uses the existing config file; specifically, edit the "start" script string (the "start" npm script) to run vite optimize -c vite.main.config.ts && electron-forge start (or remove the vite optimize step entirely if you decide not to run the deprecated optimize step), referencing the "start" script and vite.main.config.ts to locate the change. ``` </details> --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> **Configuration used**: defaults **Review profile**: CHILL **Plan**: Pro Plus **Run ID**: `13bb0a3e-85b0-4f59-b1b7-a6747b1ffd33` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 946d141897d091493062b58067aba48dc20be6fa and cf9c272df72a5053f08644869c520f7f8d662565. </details> <details> <summary>📒 Files selected for processing (1)</summary> * `js/desktop/package.json` </details> </details> <!-- This is an auto-generated comment by CodeRabbit for review status -->
Sign in to join this conversation.