前端性能问题根因在于 Bun bundler 无法有效 code split、CSS
tree-shake 和产出优化的前端资源。经多轮 Bun 原生优化尝试
均无明显效果后,决定将前端构建迁回 Vite。
主要变更:
- 前端构建:从 Bun HTML import bundling 切换为 Vite build
(Rolldown code splitting、vendor chunk、CSS 优化)
- 开发模式:从 Bun fullstack 单进程 HMR 切换为 Vite dev
server + Bun API server 双进程(:5173 + :3000)
- 生产构建:三步流水线(Vite build → code generation →
Bun compile),通过 `import with { type: "file" }` 嵌入前端资源
- 静态资源服务:从 Bun HTML import manifest 切换为自定义
serveStaticAsset 函数,支持 SPA fallback 和正确的 Cache-Control
- Server 接口:BootstrapOptions 和 StartServerOptions 增加
staticAssets? 可选参数
- 文档更新:DEVELOPMENT.md 和 README.md 反映新的开发模式,
主 specs 同步 delta 变更
新增能力:
- static-asset-embedding: 构建时资源扫描与 code generation、
运行时静态资源服务
- vite-frontend-bundling: Vite 构建配置、code splitting 策略、
CSS 处理
60 lines
1.9 KiB
JSON
60 lines
1.9 KiB
JSON
{
|
|
"name": "dial-server",
|
|
"type": "module",
|
|
"private": true,
|
|
"scripts": {
|
|
"dev": "bun run scripts/dev.ts",
|
|
"dev:server": "bun --watch src/server/dev.ts",
|
|
"dev:web": "bunx --bun vite --host",
|
|
"build": "bun run scripts/build.ts",
|
|
"lint": "eslint .",
|
|
"format": "prettier . --write",
|
|
"schema": "bun run scripts/generate-config-schema.ts",
|
|
"schema:check": "bun run scripts/generate-config-schema.ts --check",
|
|
"check": "bun run schema:check && bun run typecheck && bun run lint && bun test",
|
|
"verify": "bun run check && bun run build",
|
|
"test": "bun test",
|
|
"clean": "bun run scripts/clean.ts",
|
|
"typecheck": "tsc --noEmit",
|
|
"prepare": "husky"
|
|
},
|
|
"devDependencies": {
|
|
"@commitlint/cli": "^21.0.0",
|
|
"@commitlint/config-conventional": "^21.0.0",
|
|
"@eslint/js": "^10.0.1",
|
|
"@tanstack/react-query-devtools": "^5.100.10",
|
|
"@types/bun": "^1.3.13",
|
|
"@types/react": "^19.2.14",
|
|
"@types/react-dom": "^19.2.3",
|
|
"@vitejs/plugin-react": "^6.0.2",
|
|
"eslint": "^10.3.0",
|
|
"eslint-config-prettier": "^10.1.8",
|
|
"eslint-import-resolver-typescript": "^4.4.4",
|
|
"eslint-plugin-import": "^2.32.0",
|
|
"eslint-plugin-perfectionist": "^5.9.0",
|
|
"eslint-plugin-prettier": "^5.5.5",
|
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
"eslint-plugin-react-refresh": "^0.5.2",
|
|
"husky": "^9.1.7",
|
|
"lint-staged": "^17.0.4",
|
|
"prettier": "^3.8.3",
|
|
"typescript": "^6.0.3",
|
|
"typescript-eslint": "^8.59.2",
|
|
"vite": "^8.0.13"
|
|
},
|
|
"dependencies": {
|
|
"@sinclair/typebox": "^0.34.49",
|
|
"@tanstack/react-query": "^5.100.10",
|
|
"@xmldom/xmldom": "^0.9.10",
|
|
"ajv": "^8.20.0",
|
|
"cheerio": "^1.2.0",
|
|
"es-toolkit": "^1.46.1",
|
|
"react": "^19.2.6",
|
|
"react-dom": "^19.2.6",
|
|
"recharts": "^3.8.1",
|
|
"tdesign-icons-react": "^0.6.4",
|
|
"tdesign-react": "^1.16.9",
|
|
"xpath": "^0.0.34"
|
|
}
|
|
}
|