Cra to vite8 - #4095
Open
hubin4826 wants to merge 17 commits into
Open
Conversation
Contributor
PR CI 汇总状态:全部通过
由 pull_request test workflow 自动生成 |
hubin4826
force-pushed
the
cra-to-vite8
branch
from
August 10, 2026 02:31
13d8209 to
e97aa1f
Compare
- 构建链:react-app-rewired/config-overrides.js → Vite 8 + Rolldown - MPA:index.html + yakit-aux.html 双入口(rolldownOptions.input) - Monaco:MonacoWebpackPlugin 自动注入 → setupMonacoWorkers 显式 ?worker 静态导入 - 环境变量:process.env 整体 define(避免与 process shim 冲突拆坏标识符); 平台 PLATFORM 单一来源回归 .env-cmdrc,删除冗余 .env.[mode] - CSS:cssCodeSplit:false + noop antd 逐组件样式,修复 Vite 细粒度 css chunk 导致 antd 反噬组件样式的顺序回归 - nodePolyfills:移除 fs 以对齐 CRA fallback.fs=false(主窗口 nodeIntegration 下真 Node fs 可用) - 测试:jest → vitest(setupVitest.ts + electronBridge stub);清理 web-vitals 与 CRA 脚手架遗留 - CI:Node 统一升级至 22.12.0,与 engines.node 对齐 - 新增 verify-renderer-build-artifacts.mjs 构建产物冒烟校验
将 Link 渲染端升级至 Vite 8 / Rolldown,同步升级 plugin-react 与 Vitest, 并把 gen-multi-link-render CI Node 提升到 22.12 以满足 Vite 8 要求。
…l styles - 将 NewApp/ChildNewApp 迁移至 src/newApp/,相对路径统一为 @/ 别名 - setupMonacoWorkers 迁移至 src/utils/monacoSpec/ - 合并 index.css + yakitUI.scss + yakitLib.scss 为 styles/index.css (三者均为纯 CSS 无 SCSS 语法,加载顺序保持 antd 在前) - 清理空文件/死文件:app.module.scss、unusedApis.js、tailwind.config.js、logo.svg - 移除未使用的 tailwindcss 依赖
hubin4826
force-pushed
the
cra-to-vite8
branch
from
August 10, 2026 06:41
e97aa1f to
beeefe7
Compare
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
根目录、主渲染端、Link 端统一钉死 vite/vitest;升级根目录 jest-dom/jsdom 以适配 Vitest 4;移除未使用的 vite-tsconfig-paths,并忽略 junit 报告产物。
Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates the Electron renderer (and related tooling) from CRA/react-app-rewired to Vite 8, updating build/test/dev workflows and associated configs to match the new bundling/runtime model (MPA main/aux, Rolldown config, updated Vitest setup, and renderer-specific polyfills).
Changes:
- Replace CRA build/dev wiring with Vite 8 configs, scripts, and CI updates (including MPA main/aux entries and build artifact verification).
- Update Vitest to v4 with a new shared setup file and renderer-specific Vitest/Vite configuration.
- Refactor renderer entrypoints/assets/styles (aux window entry, Monaco workers, global CSS consolidation) and adjust a few type definitions to remove legacy TS suppressions.
Reviewed changes
Copilot reviewed 55 out of 70 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| vitest.config.ts | Point Vitest setup to new setupVitest.ts and simplify reporter typing. |
| package.json | Update dev script, perf bench flags, CI lint invocation, and upgrade Vite/Vitest/jsdom/testing libs. |
| app/renderer/src/main/yakit-aux.html | Convert aux HTML to Vite-style static paths and add module entry script. |
| app/renderer/src/main/vitest.config.mts | Add renderer-local Vitest config with aliasing and jsdom setup. |
| app/renderer/src/main/vite.config.mts | Add Vite 8 renderer config (MPA, env defines, polyfills, deps optimization, build outputs). |
| app/renderer/src/main/tsconfig.json | Switch to moduleResolution: bundler and exclude src/alibaba/**. |
| app/renderer/src/main/tailwind.config.js | Remove Tailwind config (Tailwind usage removed from global entry CSS). |
| app/renderer/src/main/src/yakitUI.scss | Remove legacy SCSS (moved into global CSS bundle). |
| app/renderer/src/main/src/yakitLib.scss | Remove legacy SCSS (moved into global CSS bundle). |
| app/renderer/src/main/src/vite-env.d.ts | Add Vite ImportMetaEnv typings and module declaration for xterm CSS. |
| app/renderer/src/main/src/utils/monacoSpec/setupMonacoWorkers.ts | Add Vite ?worker-based Monaco worker setup and explicit Monaco CSS import. |
| app/renderer/src/main/src/utils/envfile.tsx | Align env access to Vite define strategy (process.env.REACT_APP_*). |
| app/renderer/src/main/src/utils/ConfigSystemProxy.tsx | Remove TS suppression; rely on File.path typing. |
| app/renderer/src/main/src/unusedApis.js | (Present in PR file list) Reserved/placeholder file for unused API tracking. |
| app/renderer/src/main/src/types/global.d.ts | Update NewApp type import path and add File.path?: string augmentation. |
| app/renderer/src/main/src/styles/index.css | Replace Tailwind directives with consolidated global CSS (incl. migrated utility classes). |
| app/renderer/src/main/src/setupVitest.ts | Add Vitest global setup (jest-dom/vitest + window.yakitBridge stub). |
| app/renderer/src/main/src/setupTests.ts | Remove CRA/Jest setup file. |
| app/renderer/src/main/src/reportWebVitals.ts | Remove CRA web-vitals helper. |
| app/renderer/src/main/src/react-app-env.d.ts | Remove CRA react-scripts type references and redundant module declarations. |
| app/renderer/src/main/src/pages/yakRunner/test/yakRunnerAiCodePatchApply.test.ts | Update Vitest mock typing for compatibility with newer Vitest/TS. |
| app/renderer/src/main/src/pages/plugins/manage/PluginManage.tsx | Remove TS suppression tied to file path typing. |
| app/renderer/src/main/src/pages/pluginHub/pluginUploadModal/PluginUploadModal.tsx | Switch upload file typing to DOM File, add missing file.path guard, add PluginImageTextarea import. |
| app/renderer/src/main/src/pages/pluginEditor/pluginImageTextarea/PluginImageTextarea.tsx | Switch image file typing to DOM File and remove legacy fs FileItem usage. |
| app/renderer/src/main/src/pages/MainOperator.tsx | Type avatar upload param as File and guard missing file.path. |
| app/renderer/src/main/src/pages/codec/NewCodec.tsx | Remove TS suppression tied to file path typing. |
| app/renderer/src/main/src/pages/assetViewer/ReportViewerPage.tsx | Replace html-docx-js usage with html-docx-js-typescript asBlob flow and runtime type check. |
| app/renderer/src/main/src/pages/assetViewer/reportRenders/markdownRender.scss | Remove stale header comment while retaining scoped Tailwind-preflight-like styles. |
| app/renderer/src/main/src/pages/ai-re-act/hooks/test/stubs/electronBridgeStub.ts | Expand electronBridge stub exports to match current bridge surface. |
| app/renderer/src/main/src/newApp/NewApp.tsx | Convert internal imports to @/ aliases and update lazy import paths. |
| app/renderer/src/main/src/newApp/ChildNewApp.tsx | Convert internal imports to @/ aliases. |
| app/renderer/src/main/src/newApp/ChildNewApp.module.scss | Add styles for child window layout and wrappers. |
| app/renderer/src/main/src/logo.svg | Remove CRA default logo asset. |
| app/renderer/src/main/src/index.tsx | Update entry to Vite structure (new NewApp path, global CSS order, Monaco worker setup, remove web-vitals). |
| app/renderer/src/main/src/index.css | Remove legacy global CSS (replaced by src/styles/index.css). |
| app/renderer/src/main/src/hook/useVirtualTableHook/useVirtualTableHookType.ts | Constrain DataKey generic to string. |
| app/renderer/src/main/src/hook/useHttpVirtualTableHook/useHttpVirtualTableHookType.ts | Constrain DataKey generic to string and convert params interface to intersection type. |
| app/renderer/src/main/src/hook/useHoldGRPCStream/useHoldGRPCStreamType.ts | Add typed stream result/state definitions for GRPC stream holding hooks. |
| app/renderer/src/main/src/hook/useHoldBatchGRPCStream/useHoldBatchGRPCStreamType.ts | Add typed batch GRPC stream definitions and task status model. |
| app/renderer/src/main/src/components/DataExport/toExcel.tsx | Replace xlsx-style with xlsx-js-style and type bookType as BookType. |
| app/renderer/src/main/src/components/configNetwork/ConfigNetworkPage.tsx | Remove TS suppression tied to file path typing (but leaves an unused variable to fix). |
| app/renderer/src/main/src/auxWindow/aux-entry.tsx | Update aux entry to import antd CSS and initialize Monaco workers. |
| app/renderer/src/main/src/app.module.scss | (Present in PR file list) Styles module retained alongside Vite migration changes. |
| app/renderer/src/main/scripts/verify-renderer-build-artifacts.mjs | Add build artifact smoke-check script for Electron production loading. |
| app/renderer/src/main/scripts/cli.js | Migrate renderer CLI to Vite commands and introduce explicit viteModeMap. |
| app/renderer/src/main/public/robots.txt | Remove CRA default robots.txt. |
| app/renderer/src/main/public/manifest.json | Remove CRA web app manifest. |
| app/renderer/src/main/postcss.config.js | Add autoprefixer config (CRA previously provided it implicitly). |
| app/renderer/src/main/paths.json | Adjust TS path mapping to @/* -> ./src/*. |
| app/renderer/src/main/package.json | Migrate renderer dependencies/scripts from CRA to Vite/Vitest and set Node engine floor. |
| app/renderer/src/main/index.html | Convert main HTML to Vite entry style and update static asset references. |
| app/renderer/src/main/config-overrides.js | Remove CRA/customize-cra webpack overrides. |
| app/renderer/src/main/.env.development | Add dev-only env guidance and default REACT_APP_DEVTOOL=true. |
| app/renderer/engine-link-startup/vitest.config.ts | Resolve root dir via import.meta.url and adjust alias resolution. |
| app/renderer/engine-link-startup/vite.config.ts | Resolve root dir via import.meta.url and migrate build config to rolldownOptions. |
| app/renderer/engine-link-startup/package.json | Upgrade Vite/Vitest/jsdom and align plugin versions with Vite 8 toolchain. |
| AGENTS.md | Update project dev guide to reflect Vite 8 renderer and improved yarn dev behavior. |
| .gitignore | Ignore junit report output and TS build info files. |
| .github/workflows/pull-request-test.yml | Align Node version and replace npx-based eslint/tsc invocations with yarn binaries. |
| .github/workflows/publish-se-oss.yml | Bump workflow Node version to match new renderer engine requirements. |
| .github/workflows/gen-multi-render.yml | Bump workflow Node version to match renderer toolchain. |
| .github/workflows/gen-multi-link-render.yml | Bump workflow Node version to match link-render toolchain. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
1157
to
1161
| beforeUpload={(f) => { | ||
| const file_name = f.name | ||
| // @ts-expect-error 类型定义不完整,需要忽略此行 | ||
| const path: string = f?.path || '' | ||
| if (path.length > 0) { | ||
| setChromePath(path) |
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.