Skip to content

feat!: 升级 Babel 8、默认 ESM 与 tsdown 双产物配置#1004

Merged
sonofmagic merged 14 commits into
mainfrom
codex/babel8-tsdown
Jul 21, 2026
Merged

feat!: 升级 Babel 8、默认 ESM 与 tsdown 双产物配置#1004
sonofmagic merged 14 commits into
mainfrom
codex/babel8-tsdown

Conversation

@sonofmagic

@sonofmagic sonofmagic commented Jul 20, 2026

Copy link
Copy Markdown
Owner

变更摘要

  • 将核心 Babel 工具链升级到 Babel 8,同时隔离保留 Taro、MPX、React Native 管理的 Babel 7 链路
  • packages/*packages-runtime/* 全部设为默认 type: module,公开包继续提供 ESM 与 CommonJS 双入口
  • 迁移后的 ESM 产物统一使用 .js,CommonJS 产物统一使用 .cjs,CLI 与 Webpack/Rspack loader 同步采用明确扩展名
  • 按产物格式拆分 tsdown 依赖策略:ESM 外置可直接消费的生产依赖,CJS 只内联同步 require() 无法加载的 ESM-only 依赖图
  • 补齐包元数据、条件导出、声明文件 specifier、Babel parse/traverse、tsdown 配置与临时 tarball 兼容性覆盖
  • 修复 uni-app Web hot-update 页面探针:将浏览器接收更新与服务端编译稳定阶段分离,避免重复修改 uni-app CSS 入口
  • 从 Webpack compilation 的 chunk/asset 图判断模块边界,避免把 chunk bootstrap require() 误判为源码链接;原生 JS/WXS 仍保留输出模块图语义
  • 核心完整语义统一使用 Babel 8;watch/serve 在 AST 语义约束允许时默认使用 OXC 快路径,普通 build 保持单一 Babel 解析器;遇到 source map、模块图、ignore 调用、tagged template 或不支持输入时自动回退 Babel
  • 增加中文 major Changeset,记录 Babel 8、Node.js 下限、默认 ESM 和物理 .cjs 产物变化

性能结果

MPX Tailwind CSS v4 的真实 watch 短矩阵中:

  • Babel 7 基线 tasks.js 中位数:约 151.7ms
  • 当前分支 tasks.js 中位数:约 92.4ms
  • JS 插件阶段下降约 39%
  • 插件阶段总耗时中位数从 1206ms 降到 1122ms
  • 构建与端到端 HMR 同时改善,没有通过放宽性能门禁掩盖回归
  • 真实 strict Taro Vite build 插件中位数:2643ms -> 2629ms
  • 真实 strict Taro Webpack build 峰值内存:约 1701MB -> 1660MB
  • 性能门禁会拒绝被 taro-build-guard 跳过的空跑样本,确保采集真实 compilation

验证结果

  • pnpm build:pkgs:27/27 通过
  • pnpm test:core:2999 通过,29 跳过
  • pnpm test:plugins:1158 通过,6 跳过
  • pnpm typecheck:通过
  • pnpm test:release:通过
  • pnpm --filter weapp-tailwindcss build:ESM/CJS 双产物构建通过
  • pnpm --filter weapp-tailwindcss lint:通过
  • pnpm install --frozen-lockfile:通过
  • 性能报告门禁单测:18/18 通过
  • uni-app Vite Web 页面探针:3/3 通过,包含 Iconify bracket class 热更新
  • Web HMR:18/18 通过
  • watch-HMR 单测:103 通过
  • core、typography、debug、theme 包 tsd:通过
  • 11 个公开包的临时 pack 安装验证:158 个 require、dynamic importrequire.resolveimport.meta.resolve 检查通过
  • CJS 产物扫描:没有同步外置 require() Babel 8、htmlparser2、obug 或 magic-string
  • 完整 pnpm e2e:static 39 个文件通过、3 个跳过;222 个测试通过、9 个跳过;hot-update 8/8 通过
  • HBuilderX:两个模板的 mp-weixin 编译与 Web/HMR 验证通过
  • MPX、Taro Webpack/Vite、uni-app Vite、weapp-vite、Gulp、website、Node API 与 HBuilderX 的 CJS/ESM demo 矩阵通过

已知基线问题

  • HBuilderX 较宽的 mp 脚本还包含 mp-baidu,该链路目前会因等待 main.wxss 超时;本次要求的 mp-weixin 与 Web 链路均通过
  • typography 现有插件快照失败已在 main 上复现,本次没有更新该基线

@changeset-bot

changeset-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: adddbf5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 16 packages
Name Type
weapp-tailwindcss Major
@weapp-tailwindcss/debug-uni-app-x Patch
@weapp-tailwindcss/init Patch
@weapp-tailwindcss/logger Patch
@weapp-tailwindcss/postcss Patch
@weapp-tailwindcss/reset Patch
@weapp-tailwindcss/shared Patch
@weapp-tailwindcss/typography Patch
tailwindcss-config Patch
theme-transition Patch
weapp-style-injector Patch
@weapp-tailwindcss/build-all Patch
@weapp-tailwindcss/website Patch
@weapp-tailwindcss/experimental Patch
tailwindcss-injector Patch
wetw Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@sonofmagic sonofmagic changed the title feat!: upgrade Babel 8 and default packages to ESM feat!: 升级 Babel 8、默认 ESM 与 tsdown 双产物配置 Jul 21, 2026
@sonofmagic
sonofmagic merged commit 8d9cc88 into main Jul 21, 2026
70 of 71 checks passed
@sonofmagic sonofmagic mentioned this pull request Jul 21, 2026
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