后端建立 TypeScript 构建链路

This commit is contained in:
yml
2026-05-21 13:36:38 +08:00
parent 25671078d6
commit 1476522ab5
18 changed files with 798 additions and 101 deletions
+10 -6
View File
@@ -36,22 +36,25 @@ Linux 部署:
```bash
npm install
npm run build
npm run browser:install:linux
npm run start
```
后端渐进 TypeScript 迁移已经开始,当前可执行
后端渐进 TypeScript 迁移已经进入源码和构建双轨模式
```bash
npm run typecheck
npm run build
npm test
```
第一阶段目前先检查
当前约定
- `src/config/runtime.js`
- `src/types/**/*.js`
后续会逐步扩大到更多 routes / services / repositories,而不会先改成需要编译产物的运行模式。
- 开发:`npm run dev` 使用 `tsx watch` 直接运行 `src`,并额外监听 `config`
- 数据库迁移:`npm run db:migrate` 使用 `tsx`
- 生产:`npm run build` 输出 `dist``npm run start` 运行 `dist/index.js`
- 新增或迁移后端模块优先使用 `.ts`
## 配置
@@ -122,6 +125,7 @@ npm run typecheck
- 后端容器启动时执行 `npm install``npm run dev`
- OCR 子服务会在容器里执行 `pip install -e /app/subservices/ocr-worker`
- 所以平时改 `src/`、改 OCR Python、改 `.env`,一般都不需要重建镜像
- 生产镜像会在 build 阶段编译后端并只复制 `dist``config` 和运行依赖
只有下面几类改动通常还需要 `docker compose -f docker-compose.dev.yml up -d --build backend`