Skip to content

chore(build): add a modern-only frontend build - #1532

Merged
dataeaseShu merged 1 commit into
mainfrom
chore/frontend-modern-build
Nov 26, 2026
Merged

dataeaseShu merged 1 commit into
mainfrom
chore/frontend-modern-build

Conversation

@dataeaseShu

Copy link
Copy Markdown
Contributor

Summary

  • @vitejs/plugin-legacy 会把整个应用用 Babel 再构建一遍并生成 nomodule 兜底包。但本项目的 build.target 和 legacy targets 都是 Chrome >= 81,Chrome 81 本身支持 ES module,这份兜底基本用不上,却占掉了构建的大部分时间和内存。
  • 用 SQLBOT_LEGACY 环境变量给 legacy 插件加开关,默认仍然开启,老行为不变;新增 build:modern 脚本跳过它。

Measured locally (Apple Silicon, Vite 6.4.3)

命令 vite build 产物
npm run build 55.7s 含 *-legacy-*.js、polyfills-*.js
npm run build:modern 11.4s 无 legacy / polyfills 文件

Usage

  • npm run build:保持现状(含 legacy)
  • npm run build:modern:仅现代包
  • Docker/CI 不改脚本名时可用 SQLBOT_LEGACY=false npm run build

Test plan

  • npm run build 产物与改动前一致(含 legacy 资源)
  • npm run build:modern 能正常产出,浏览器访问无缺失 polyfill 报错(最低 Chrome 81)
  • npx vue-tsc -b、npx eslint vite.config.ts 通过

🤖 Generated with Claude Code

@vitejs/plugin-legacy rebuilds and Babel-transpiles the whole app for a
nomodule fallback the Chrome 81 baseline never uses, and it dominates
build time and memory. Gate it behind SQLBOT_LEGACY and add a
build:modern script so routine builds can skip it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@dataeaseShu
dataeaseShu merged commit 5bb63a9 into main Nov 26, 2026
3 checks passed
@dataeaseShu
dataeaseShu deleted the chore/frontend-modern-build branch November 26, 2026 03:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant