build: adopt esbuild for frontend bundling (build:web → public/build/)

- esbuild dev dep; build:web/dev:web bundle public/main.ts → public/build/main.js
- gitignore public/build/; tsconfig.web.json now typecheck-only
- frontend build convention documented in PLAN §1, DISPATCH, ARCHITECTURE §5
- resolves the T1 deferred decision
This commit is contained in:
Yaojia Wang
2026-06-16 07:36:01 +02:00
parent 987cab8eb7
commit 409b208928
8 changed files with 38 additions and 18 deletions

View File

@@ -27,9 +27,7 @@
- **Wave**: W0(T1 ✓)→ 下一步 **T2**(冻结 `src/types.ts`)
- **任务**: T2 — 共享类型契约,完成后 W0 全部 commit,即可放开 W1 并行
- **下一步**: 派 `module-builder`(sonnet)执行 T2,或主会话直接做;依据 ARCHITECTURE §3
- **阻塞**: 无。但有 1 个待决项(非阻塞):**前端浏览器打包策略未定**(tsconfig.web 当前只类型检查,
不产出可被浏览器加载的 JS;main.ts 引 @xterm 裸导入需 bundler/import-map/CDN)。需在 **T11/T14 前**决定,
建议加 esbuild 作为 `build:web`
- **阻塞**: 无。(前端打包待决项**已解决**:选 esbuild,已装好并接好 `build:web`/`dev:web`,约定写入 PLAN §1。)
- **最后更新**: 2026-06-16
---
@@ -117,11 +115,20 @@
2. 依赖解析到较新主版本(express 5 / xterm 6 / typescript 6 / vitest 4):**T7/T11/T14/T15 注意 API 差异**
(express 5 路由、xterm 6 import 形态)。
3. 加了 PLAN 未列的脚本 `dev`/`typecheck``postinstall`(便利 + 必需修复),属合理补充,未改 PLAN 意图。
- **遗留 / 待办**(非阻塞,需在 **T11/T14 前**决):**前端浏览器打包未定**`tsconfig.web.json` 现为 `noEmit`(仅类型检查);
`public/main.ts` 裸导入 `@xterm/xterm`,浏览器无法直接解析,需 bundler(建议 esbuild,加 `build:web`)/import-map/CDN 三选一。
建议下一波前由 orchestrator 拍板,若选 esbuild 则**现在补装**(避免后续并发 install)。
- **遗留 / 待办**: 无(原前端打包待决项已解决,见下补记)。
- **commit**: `b126cf0`
### 2026-06-16 · T1 补记 — 前端打包定为 esbuild
- **状态**: `[x]` DONE
- **改动**: 装 `esbuild`(dev);`package.json``build:web`/`dev:web`(打包 `public/main.ts``public/build/main.js`);
`.gitignore` 改忽略 `public/build/`;`tsconfig.web.json` 注释更新为"仅类型检查";前端构建约定写入
`PLAN §1` 并更新 T8/T11/T14 与 `DISPATCH.md``ARCHITECTURE §5`
- **验证**: esbuild 0.28.1;临时入口 `--bundle --format=esm --outdir=public/build``main.js`+`.map`,smoke 通过。
- **决策**: 三选一中选 **esbuild**(极快、零配置、与 node-pty/tsx 生态一致);**现在装好**避免 W1 并发 install。
约定:入口 main.ts、产物 public/build/(已 gitignore)、index.html 用 `<script type=module src=./build/main.js>`、server 静态托管 public/。
- **commit**: (见下次提交)
### 2026-06-15 · T0 项目记录起点(计划就绪)
- **状态**: `[x]` DONE