今天发布 Babel 8:仅支持 ESM,放弃 ES5 默认,同时提供顺畅的迁移路径
今天我们发布了 Babel 8。距离我们发布 Babel 7 已经有 8 年了。这绝不是没有原因的。
🌐 Today we are releasing Babel 8. It's been 8 years since we released Babel 7. And that's not without reason.
在过去的八年里,JavaScript 生态系统发生了很大变化。除了 Babel,SWC 和 Oxc 也成为了替代的 JavaScript 编译器,而 JavaScript 语言本身也随着新特性和提案的发展而演变(其中很多在标准化之前都曾在 Babel 中进行原型设计和测试!)。
🌐 Over these past 8 years, the JavaScript ecosystem has changed significantly. In addition to Babel, SWC and Oxc have emerged as alternative JavaScript compilers, and the JavaScript language itself has evolved with new features and proposals (many of which were prototyped and tested in Babel before being standardized!).
你可能会想,Babel 因此变得不那么重要了。但现实并非如此。Babel 的下载量从 2018 年每周 170 万次增长到了本周(2026 年 6 月)每周 6.51 亿次。在过去的一年里,Babel 的每周下载量翻了一番。
🌐 You might imagine that Babel became less relevant because of that. But reality begs to differ. Babel has grown from 1.7 million weekly downloads in 2018, to 651 million weekly downloads this week (Jun 2026). Babel has doubled its weekly download counts in the last year.
这种使用方式对我们的用户带来了巨大的责任。Babel 在全球的许多构建管道中都有使用,即使是很小的破坏性更改,也可能导致数十万开发者无法发布他们的代码。这就是为什么我们在过去八年里没有做过带有破坏性更改的重大版本更新,也就是为什么我们对 Babel 8 采取非常谨慎的做法。
🌐 This usage comes with a huge responsibility to our users. Babel is used in so many build pipelines across the world that even minor breaking changes can cause hundreds of thousands of developers to be blocked from shipping their code. That's why we've not done a major release with breaking changes in 8 years, and why we are taking a very careful approach to Babel 8.
今天的发布版本并没有很多新功能。实际上,它相比 Babel 7 没有新增功能。相反,我们是在从核心上对 Babel 进行现代化改造,让它为接下来的 8 年做好准备。Babel 8 现在仅支持 ESM,为所有 Babel 包提供 TypeScript 类型,并且默认不再编译到 ES5 和 CommonJS。
🌐 Today's release is not one with many features. In fact, it has no new features over Babel 7. Instead, we are modernizing Babel at its core, to make it ready for the next 8 years. Babel 8 is now ESM-only, ships TypeScript types for all Babel packages, and also no longer compiles to ES5 and CommonJS by default.
我们这样做是为了推动 JavaScript 生态的发展。绝大多数用户都在使用支持 ES6 及以上的浏览器。IE11 的日子早已过去,是时候向前看了。Babel 8 现在以现代浏览器为目标,这是一个不断变化的目标。随着新功能被广泛支持,Babel 会自动停止对它们的编译(从而减少你的打包大小!)。
🌐 We are doing this to push the JavaScript ecosystem forward. The vast majority of users are on browsers that support ES6 and above. The days of IE11 are long over, so it's time to move on. Babel 8 now targets the evergreen browsers, a moving target. As new features become available widely, Babel will automatically stop compiling them away (reducing your bundle sizes!).
随着 require(esm) 支持现在在所有 LTS 版本的 Node.js 上可用,ESM-only 的变化也是一个自然而然的进步。它让我们可以现代化 Babel 代码库并减少包的大小,同时不会影响那些仍在自己代码中使用 CommonJS 的用户。
🌐 With require(esm) support now available in all LTS versions of Node.js, the ESM-only change is also a natural step forward. It allows us to modernize the Babel codebase and reduce its package sizes, while not breaking users who are still using CommonJS in their own code.
现在所有 Babel 包都提供了 TypeScript 类型,这意味着你现在可以在 TypeScript 项目中使用 Babel 的编程 API,而不需要安装 @types/babel__* 包。
🌐 TypeScript types are now available for all Babel packages, which means that you can now use Babel's programmatic API in your TypeScript projects without having to install @types/babel__* packages.
Babel 8 是对 Babel 7 的渐进式改进,尽量减少用户需要经历的破坏性变化。对于还记得 Babel 5 到 Babel 6 和 Babel 6 到 Babel 7 迁移的人来说:别担心,这次会更简单!
🌐 Babel 8 is an incremental improvement over Babel 7, trying to minimize the amount of breakage that users have to go through. For those of you that remember the Babel 5 to Babel 6 and Babel 6 to Babel 7 migrations: don't worry, this time it will be simpler!
在进入更新日志之前,我们想再跟你说一件事。我们,Babel 核心团队,由黄俊亮、liuxingbaoyu和Nicolò Ribaudo组成,非常感谢这些年来所有支持这个项目的公司,也正是有了你们,这次的发布才得以实现。不过,遗憾的是,Babel 所收到的捐赠和赞助金额在过去几年里一直在稳步下降。 关于这意味着什么,以及你和你的组织如何提供帮助,我们在下面的资金部分有更多说明。
🌐 Before getting on with the changelog, we want to tell you one more thing. We, the Babel core team, consisting of Huáng Jùnliàng, liuxingbaoyu, and Nicolò Ribaudo, are incredibly grateful to all the companies that have supported the project over the years, and that have made this release possible. However, the amount of donations and sponsorships that Babel has been receiving has unfortunately been steadily decreasing over the past few years. We say more about what that means, and how you and your organization can help, in the Funding section below.
重大更新变化
🌐 Major Breaking Changes
Babel 8 只支持 ESM
🌐 Babel 8 is ESM-only
Babel 现在以 ESM 形式发布,需要 Node.js 22、24、26 或更高版本。
🌐 Babel now ships as ESM, and requires Node.js 22, 24, 26, or newer.
Node.js 20 和 25 在今年早些时候已经达到生命周期结束,将不再收到任何安全修复:如果你正在使用这些版本,甚至更早的版本,我们强烈建议你升级到受支持的 Node.js 版本。
🌐 Node.js 20 and 25 reached end-of-life earlier this year, and will not receive any more security fixes: if you are using any of those versions, or even older ones, we strongly recommend you upgrade to a supported version of Node.js.
默认停止编译到 ES5
🌐 Stop compiling to ES5 by default
在 Babel 8 中,@babel/preset-env 不再默认将你的代码编译成 ES5。相反,我们依赖 Browserslist 的 defaults 查询,截至今天,这大致意味着默认使用 ES2023。注意,这个目标是不断变化的,随着用户更新到更现代的浏览器,它会自动更新。
🌐 In Babel 8, @babel/preset-env no longer compiles your code to ES5 by default. Instead, we rely on Browserslist's defaults query, which as of today means roughly defaulting to ES2023. Note that this is a moving target, and it will automatically change over time as users update to newer browsers.
Babel 仍然允许你编译到 ES5(对于某些特性甚至可以编译到 ES3),但你需要在配置中明确地定义你的 targets。
🌐 Babel still allows you to compile to ES5 (even to ES3, for some features), but you'll need to explicitly define your targets in your configuration.
作为这次变化的一部分,@babel/preset-env 现在默认编译为 ESM,而不是 CommonJS。
🌐 As part of this change, @babel/preset-env also defaults to compiling to ESM rather than to CommonJS.
不再推荐使用 loose 和 spec 选项
🌐 Deprecate loose and spec options
Babel 很久以来就支持 loose 和 spec 选项,无论是在 @babel/preset-env 里还是在单独的插件中。这些选项用于调整规范遵循度和输出大小/性能之间的平衡,但它们实际上是如何改变编译代码的语义的,通常并不清楚。
🌐 Babel has for a long time supported loose and spec options, both in @babel/preset-env and in individual plugins. They were used to tweak the balance between spec compliance and output size/performance, but it was often unclear how they were actually changing semantics of compiled code.
在 Babel 8 中,我们将会从 @babel/preset-env 中_移除_它们,并从各个插件中_弃用_它们。取而代之,你应该使用 assumptions,它可以让你对想要做出的权衡有更细粒度的控制。
🌐 In Babel 8, we are removing them from @babel/preset-env and deprecating them from individual plugins. Instead, you should use assumptions, which give you fine-grained control over what tradeoffs you want to make.
如果你目前正在使用 @babel/preset-env 的 loose 或 spec 选项,我们强烈建议你在迁移到 Babel 8 之前先迁移到 assumptions(它们从 Babel 7.13.0 开始支持)。你可以在文档中找到基于 assumptions 的等效配置。
🌐 If you are currently using @babel/preset-env's loose or spec options, we highly recommend you migrate to assumptions before migrating to Babel 8 (they have been supported since Babel 7.13.0). You can find the equivalent assumptions-based configuration in the docs.
把 polyfill 注入提取到单独的包里
🌐 Extract polyfill injection to separate packages
在2020年,我们启动了babel-polyfills项目,它可以让我们在转译代码时更好地控制Babel如何注入polyfill。最初的目标是希望其他polyfill维护者也能实现自己版本的polyfill注入器,但实际上core-js还是唯一得到良好支持的。
🌐 In 2020 we started the babel-polyfills project, which allows better control over how Babel injects polyfills while transpiling your code. The original goal was that other polyfill maintainers would be able to implement their own version of the polyfill injector, but in practice core-js remained the only one properly supported.
在 Babel 8 中,我们将从 @babel/plugin-transform-runtime 和 @babel/preset-env 中移除 corejs/useBuiltIns 选项,转而使用 babel-plugin-polyfill-corejs3,它提供了一种集中方式来控制 core-js 注入。
🌐 In Babel 8, we are removing the corejs/useBuiltIns options from @babel/plugin-transform-runtime and @babel/preset-env in favor of babel-plugin-polyfill-corejs3, which provides a centralized way of controlling core-js injection.
我们建议你在更新到 Babel 8 之前迁移到这个新插件。
🌐 We recommend you migrate to this new plugin before updating to Babel 8.
其他重大变化
🌐 Other breaking changes
还有一份大量的其他重大更改列表:大多数应用只会受到其中少数几项的影响。你可以在升级到 Babel 8指南中找到完整的迁移文档。
🌐 There is a large list of additional breaking changes: most applications will be affected by a few of them. You can find the full migration docs in the Upgrade to Babel 8 guide.
如果你正在开发一个内部嵌入了 Babel 的工具,或者你维护 Babel 插件和预设,你也可以阅读 升级到 Babel 8(API) 指南。
🌐 If you are developing a tool that internally embeds Babel, or if you maintain Babel plugins and presets, you can read the Upgrade to Babel 8 (API) guide too.
资金
🌐 Funding
Babel 核心团队想再次表达我们对多年来支持这个项目的所有公司以及让这次发布成为可能的公司表示感谢。
🌐 The Babel core team wants to reiterate how thankful we are for all the companies that have supported the project over the years, and that have made this release possible.
我们特别想感谢德国的Sovereign Tech Agency,感谢他们在过去一年提供的重要资金支持,同时也感谢Igalia在过去几年贡献的工程时间。我们还想感谢tidelift (Sonar)在安全相关资金上的帮助,以及在OpenCollective和GitHub Sponsors上赞助我们的所有公司和个人。
🌐 We would like to especially thank Germany's Sovereign Tech Agency, for their significant financial support in the last year, and to Igalia for contributing engineering time over the past few years. We would also like to thank tidelift (Sonar) for help with security-related funding, and to all the companies and individuals that are sponsoring us on OpenCollective and GitHub Sponsors.
我们需要你的帮助!
🌐 We need your help!
不幸的是,过去几年的捐款持续在下降。如果不是主权技术机构的支持(预计很快就会结束)以及Igalia的支持,我们可能无法继续确保项目所需的高质量标准。
🌐 Unfortunately, donations in the past few years have been steadily decreasing. If it wasn't for the Sovereign Tech Agency's support, which is scheduled to end soon, and Igalia's, we would not have been able to continue guaranteeing the high quality bar that the project needs to meet.

在下载量方面,我们看到的趋势恰恰相反,下载量一直在增加:Babel 的用户群并没有缩小,我们需要你的帮助来继续维护它。
🌐 We've been seeing the opposite trend when it comes to download counts, which keep increasing over time: Babel's user base is not shrinking, and we need your help to continue maintaining it.
如果你或你的公司想支持 Babel 但不确定如何做,你可以在我们的 Open Collective 上捐款,更棒的是,可以直接和我们一起参与 新的 ECMAScript 提案 的实现!如果你想进一步讨论,请通过 team@babeljs.io 联系我们!
🌐 If you or your company want to support Babel but aren't sure how, you can donate to us on our Open Collective and, better yet, work with us on the implementation of new ECMAScript proposals directly! Reach out at team@babeljs.io if you'd like to discuss more!

@babel/core 从 2020 年到 2026 年的每月下载量。截图来自 npmx.dev 的
@babel/core 统计。Babel 7
随着 Babel 8 变得稳定,我们将停止把修复和新功能回移到 Babel 7。不过,根据我们的安全政策,我们仍会提供一年的安全支持(直到 2027 年 6 月)。
🌐 With Babel 8 becoming stable, we will stop backporting fixes and new features to Babel 7. We will still provide security support for one year (until June 2027), as per our security policy.
如果你需要 Babel 8 中已经发布的功能或修复回迁到 Babel 7,请提交一个 issue 或者通过 team@babeljs.io 联系我们。根据请求的数量,我们可能会根据具体情况考虑回迁某些功能。
🌐 If you need features or fixes that have been released in Babel 8 to be backported to Babel 7, please open an issue or reach out to us at team@babeljs.io. Depending on the amount of requests, we might consider backporting some features on a case-by-case basis.