现象:生产 https://ck.yydd.ai:8443 打开任意页面都是白屏,连登录页都进不去。 控制台报 `BinReplenishMonitor is not defined`,一个 /api 请求都没发出去。 根因:PR #74 新增「缺货补货监控」时,在 router/index.jsx 的路由表里写了 `element: renderLazyComponent(BinReplenishMonitor)`,但没有像其它 22 个页面那样 在文件顶部补 `const BinReplenishMonitor = lazy(() => import('../pages/BinReplenishMonitor'))`。 该行在模块顶层求值 → 加载即抛 ReferenceError → 整个 React 应用挂掉。 `vite build` 不会报错(未声明标识符在 JS 里是合法语法),所以一路构建通过、部署后白屏。 PR #75 只补了后端的 binReplenishRoutes 引入,前端的这处漏声明一直没人发现。 修复: 1. router/index.jsx 补上 lazy 声明,并留下注释说明「漏一个就是全站白屏」。 2. 新增 frontend/scripts/verify-router-lazy.mjs,静态扫描 router/index.jsx: 凡是 renderLazyComponent(X) 用到的 X,必须在同文件有 `const X = lazy(` 声明, 否则构建直接失败并指出缺少的组件名与行号。已挂到 `npm run build` 前置。 验证: - 该检查对修复前的 origin/main 版本报错并准确指出 `BinReplenishMonitor (router/index.jsx:143)`;对修复后版本通过(23 used / 23 declared)。 - eslint 通过;vite build 成功(4270 modules / 34s)。 - playwright 真渲染:修复前 /login 白屏 + pageerror;修复后 /login 完整渲染登录表单 (123 字、3 个输入框),两个业务路由正常回到登录引导,无致命错误。
44 lines
1.3 KiB
JSON
44 lines
1.3 KiB
JSON
{
|
|
"name": "frontend",
|
|
"private": true,
|
|
"version": "0.0.0",
|
|
"type": "module",
|
|
"scripts": {
|
|
"test": "node --test test/*.test.mjs",
|
|
"prebuild": "node ./scripts/write-build-version.mjs",
|
|
"dev": "node ./scripts/write-build-version.mjs && vite --configLoader native",
|
|
"build": "node ./scripts/verify-router-lazy.mjs && vite build && node ./scripts/verify-planning-entry.mjs",
|
|
"check": "npm run lint && npm test && npm run build",
|
|
"verify:router-lazy": "node ./scripts/verify-router-lazy.mjs",
|
|
"verify:public-build": "node ./scripts/verify-public-build.mjs",
|
|
"lint": "eslint .",
|
|
"preview": "vite preview"
|
|
},
|
|
"dependencies": {
|
|
"@ant-design/icons": "^6.1.0",
|
|
"@cubejs-client/core": "^1.6.6",
|
|
"@cubejs-client/react": "^1.6.6",
|
|
"antd": "^5.29.3",
|
|
"axios": "^1.13.3",
|
|
"echarts": "^6.0.0",
|
|
"echarts-for-react": "^3.0.6",
|
|
"jszip": "^3.10.1",
|
|
"react": "^19.2.0",
|
|
"react-dom": "^19.2.0",
|
|
"react-router-dom": "^7.13.0",
|
|
"recharts": "^3.7.0",
|
|
"tslib": "^2.8.1"
|
|
},
|
|
"devDependencies": {
|
|
"@eslint/js": "^9.39.1",
|
|
"@types/react": "^19.2.5",
|
|
"@types/react-dom": "^19.2.3",
|
|
"@vitejs/plugin-react": "^5.1.1",
|
|
"eslint": "^9.39.1",
|
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
"eslint-plugin-react-refresh": "^0.4.24",
|
|
"globals": "^16.5.0",
|
|
"vite": "7.2.7"
|
|
}
|
|
}
|