fix(electron): pre-bundle lazy-route deps to avoid dev 504

Analysis pages (private/group chat) are lazy-loaded routes that pull in
heavy deps (echarts, markdown-it, snapdom, vue-virtual, etc.) which Vite's
cold-start scan does not discover. The first navigation triggered an
in-flight dependency re-optimization, invalidating already-loaded chunks
and failing with 504 (Outdated Optimize Dep) on the dynamically imported
page module. This surfaced after a fresh pnpm install wiped the warm
node_modules/.vite cache.

Add optimizeDeps.include so the initial optimize pass already contains
these deps, preventing mid-session re-optimization and the 504.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
diguaandCursor committed 2026-06-14 23:54:12 +08:00
1 parent 3cd0d0f680
commit 9fbabd02b6
1 file changed
+17
+17
View File
@@ -59,6 +59,23 @@ export default defineConfig({
define: {
__IS_ELECTRON__: JSON.stringify(true),
},
// 分析页(私聊/群聊)懒加载时才会引入图表/Markdown/截图等重依赖,
// 默认冷启动扫描发现不到,首次进入会触发二次依赖优化,导致已加载 chunk 失效报
// 504 (Outdated Optimize Dep) 并使动态导入页面失败。这里显式预打包,避免运行中再次优化。
optimizeDeps: {
include: [
'echarts/core',
'echarts/charts',
'echarts/components',
'echarts/renderers',
'echarts-wordcloud',
'markdown-it',
'@zumer/snapdom',
'@tanstack/vue-virtual',
'@internationalized/date',
'@vueuse/core',
],
},
plugins: [
vue(),
ui({