Skip to main content

7.13.0 发布:记录和元组、细粒度编译器假设,以及顶层目标

· 11 min read

我们刚刚发布了 Babel 7.13.0,这是 2021 年的第一个小版本更新!

🌐 We just published Babel 7.13.0, the first minor release of 2021!

这个版本为 @babel/core 增加了一些重要功能:一个可以在不同插件之间共享的 targets 选项(类似于 @babel/preset-env 的选项)、一个 assumptions 选项,用于精确调整你的配置以生成更小的编译输出,以及对使用原生 ECMAScript 模块编写的插件和预设的支持。

🌐 This release includes some important features to @babel/core: a targets option (similar to @babel/preset-env's one) that can be shared across different plugins, an assumptions option to precisely tune your configuration to produce a smaller compilation output, and support for plugins and presets written using native ECMAScript modules.

Babel 现在支持转换 Records 和 Tuples ECMAScript 提案,这个提案为 JavaScript 带来了不可变数据结构和结构化相等性,同时也支持解析 Module Blocks 提案。

🌐 Babel now supports transforming the Records and Tuples ECMAScript proposal, which brings immutable data structures and structural equality to JavaScript, and parsing the Module Blocks proposal.

此外,我们还增加了对一些新的 Flow 和 TypeScript 功能的支持。

🌐 Additionally, we added support for some new Flow and TypeScript features.

你可以在 GitHub 上查看完整的更新日志。

🌐 You can read the full changelog on GitHub.

7.12.0 发布:TypeScript 4.1、字符串作为导入/导出名称以及类静态块

· 9 min read

我们刚刚发布了 Babel 的一个新小版本!

🌐 We just published a new minor version of Babel!

此版本包含对新的 TypeScript 4.1 测试版功能的支持:模板字面量类型 和 映射类型中的键重映射。

🌐 This release includes support for the new TypeScript 4.1 beta features: template literal types and key remapping in mapped types.

此外,我们实现了两个新的 ECMAScript 提案:类静态块 和 带字符串名称的导入和导出。

🌐 Additionally, we implemented two new ECMAScript proposals: class static blocks and imports and exports with string names.

最后,我们把 @babel/plugin-syntax-module-attributes(以及相应的解析器插件 moduleAttributes)重命名为 @babel/plugin-syntax-import-assertions(和 importAssertions),以配合最近的 提案 更新。旧插件到 Babel 8 都还能用,但现在已经不推荐使用了。

🌐 Lastly, we renamed @babel/plugin-syntax-module-attributes (and the corresponding parser plugin moduleAttributes) to @babel/plugin-syntax-import-assertions (and importAssertions), to match the recent proposal updates. The old plugin will work until Babel 8, but it's deprecated now.

你可以在 GitHub 上阅读完整的更新日志。

🌐 You can read the whole changelog on GitHub.

7.11.0 发布:preset-env 支持 ECMAScript 2021,支持 TypeScript 4.0,打印配置以及 `babel-eslint` 的未来

· 10 min read

我们刚刚发布了 Babel 的一个新小版本!

🌐 We just released a new minor version of Babel!

这个 7.11 版本包括:

🌐 This 7.11 release includes:

  • preset-env 对逻辑赋值(??=)、数字分隔符(1_2)和命名空间重新导出(export * as ns from ...)的支持
  • TypeScript 4.0 支持
  • 解析器对第1阶段 小数提案 (7.11m) 的支持
  • 一个环境标志,用来打印给定文件的已解析 Babel 配置(BABEL_SHOW_CONFIG_FOR)

除此之外,我们现在还发布了 babel-eslint 的继任者:@babel/eslint-parser!

🌐 In addition to this, we are now releasing the successor of babel-eslint: @babel/eslint-parser!

你可以在 GitHub 上阅读完整的更新日志。

🌐 You can read the whole changelog on GitHub.

7.10.0 发布:preset-env 中的类字段、'#private in' 检查以及更好的 React 树摇优化

· 18 min read

我们刚刚发布了 Babel 的一个新小版本!

🌐 We just released a new minor version of Babel!

这个7.10版本包含:

🌐 This 7.10 release includes:

  • 完全支持新的 Stage 1 提案,#prop in obj 检查私有字段的提案。
  • @babel/preset-env 现在可以将 ES2015 风格的 Unicode 转义(\u{Babe1})编译成等效的旧语法(\uDAAA\uDFE1)。
  • 对 Optional Chaining 操作符(?.)的两个改进
  • 解析器支持新的阶段 1 模块属性提案 (import a from "./a.json" with type: "json")。
  • 对 React 代码有更好的 tree-shaking 支持(也就是 React.memo)!
  • 正在搭建 RFCs 仓库和 GitHub Discussions 页面!

你可以在 GitHub 上阅读完整的更新日志。

🌐 You can read the whole changelog on GitHub.

7.9.0 发布:更小的 preset-env 输出、支持 TypeScript 3.8 和新的 JSX 转换

· 16 min read

在准备 Babel 8.0.0 版本(在接下来的几个月里)时,我们刚刚完成了一个新的次要版本的工作,其中包括与 @babel/preset-env、TypeScript 3.8、Flow 和 JSX 相关的更新!

🌐 While preparing the Babel 8.0.0 release (in the next months), we just finished working on a new minor release which includes updates related to @babel/preset-env, TypeScript 3.8, Flow, and JSX!

几个月前,Jason Miller 开始研究 @babel/preset-modules:这是一个实验,旨在在使用 module/nomodule 模式 时大幅减少包的大小。我们很高兴地宣布,它的功能现在已经合并到 @babel/preset-env 了!这意味着它的优化可以应用到所有 preset-env 的目标值,而无需单独的预设。

🌐 A few months ago, Jason Miller started working on @babel/preset-modules: an experiment to greatly reduce bundle sizes when using the module/nomodule pattern. We are excited to announce that its functionality has now been merged into @babel/preset-env! This means that its optimizations can be applied to all preset-env targets values, without a separate preset.

注意:这些优化将在 Babel 8 中默认启用。在 Babel 7.9 中,可以通过向 preset-env 传入选项 { bugfixes: true } 手动启用它们。

这个版本还完全支持 TypeScript 3.8,它引入了显式的仅类型导入和导出(即 export type { foo }),同时也支持 Flow 0.120,它为类字段引入了 declare 修饰符(即 class C { declare foo: string })。

🌐 This release also has full support for TypeScript 3.8, which introduced explicit type-only imports and exports (i.e. export type { foo }), and for Flow 0.120, which introduced the declare modifier for class fields (i.e. class C { declare foo: string }).

我们还与 React 团队合作提供了一个新的 JSX 转换,这将使 React 及类似 React 的库能够通过添加 jsx 函数而不是 React.createElement 来进一步优化 JSX 元素的创建。

🌐 We also worked with the React team to provide a new JSX transform, which will make it possible for React and React-like libraries to further optimize the creation of JSX elements with the addition of the jsx function vs. React.createElement.

最后,@babel/parser 现在支持一个额外的 ECMAScript 提案:Record & Tuple。请注意,这仅仅是解析器支持,转换部分仍在开发中。

🌐 Lastly, @babel/parser now supports an additional ECMAScript proposal: Record & Tuple. Please note that this is only parser support, and the transforms are still being worked on.

你可以在 GitHub 上阅读完整的更新日志。

🌐 You can read the whole changelog on GitHub.

7.8.0 发布:ECMAScript 2020、.mjs 配置文件和 @babel/cli 改进

· 15 min read

这是今年的第一个版本!🎉

🌐 This is the first release of the year! 🎉

Babel 7.8.0 默认支持新的 ECMAScript 2020 特性:你不再需要为 nullish 合并运算符(??)、可选链(?.)和动态 import() 单独启用插件了,只要使用 preset-env 就可以。

🌐 Babel 7.8.0 supports the new ECMAScript 2020 features by default: you don't need to enable individual plugins for nullish coalescing (??), optional chaining (?.) and dynamic import() anymore with preset-env.

我们还完成了将不同的配置文件与 Node.js 原生支持的格式对齐的工作,这个过程我们在 7.7.0 版本 就已经开始了。

🌐 We also finished aligning our different configuration files with the formats natively supported by Node.js, a process that we started in the 7.7.0 release.

最后,Babel 的 CLI 现在支持两个新选项:--out-file-extension 和 --copy-ignored。

🌐 Lastly, Babel's CLI now supports two new options: --out-file-extension and --copy-ignored.

你可以在 GitHub 上阅读完整的更新日志。

🌐 You can read the whole changelog on GitHub.

巴别融资计划

· 14 min read

开源软件最大的优势之一就是它是开放的,任何人都可以免费参与贡献。但这也带来了一个最大的挑战,那就是如何支持一致且可持续的维护。

🌐 One of the greatest strengths of open source software is that it is open and free for anyone to contribute. This also leads to one of its greatest challenges, which is to support consistent, sustainable maintenance.

Babel 不是一家公司。正如在 7.0.0 帖子 中提到的,全员志愿的 Babel 团队(除 Henry 外)一直在尽力管理这个项目,并处理社区的各种期望。我们很高兴能够持续发布新版本,但即使只是跟进已报告的问题也很难,更不用说我们与其他工具的集成、新提案以及对更大生态系统的影响了。

🌐 Babel isn't a company. As mentioned in the 7.0.0 post, the all-volunteer Babel team (sans Henry) has been doing its best to steward the project and handle all the expectations of the community. We're glad that we have continued to make releases, but even keeping up-to-date with reported issues is difficult to manage, let alone our integrations with other tools, new proposals, and effect on the greater ecosystem.

2018年3月,亨利辞去了他的工作,开始努力为Babel争取更多资金。经过大量努力以及社区的支持,团队最终能够资助亨利成为全职维护者。

🌐 In March 2018, Henry left his job to start working on securing more funding for Babel. After a lot of work and support from the community, the team was able to fund Henry as a full-time maintainer.

这对团队来说是一个很大的胜利,但我们发现这还不够。

🌐 This has been a big win for the team, but we're finding that it is not enough.

7.7.0 发布:错误恢复与 TypeScript 3.7

· 17 min read

今天我们发布了 Babel 7.7.0!

🌐 Today we are releasing Babel 7.7.0!

这个版本包括了新的解析器功能,比如顶层 await(await x(),阶段 3)和 Flow enum 声明(Flow 提案)。现在,@babel/parser 还有从某些语法错误中恢复的选项!

🌐 This release includes new parser features like top-level await (await x(), Stage 3) and Flow enum declarations (Flow proposal). And now, @babel/parser has the option of recovering from certain syntax errors!

我们还增加了对 TypeScript 3.7 的支持:Babel 可以解析并转换带有类型注解的私有类字段、使用 declare 关键字定义的公共类字段注解、类型断言函数签名以及 enum 声明中的模板字符串。

🌐 We've also added support for TypeScript 3.7: Babel can parse and transform private class fields with type annotations, public class fields annotations defined using the declare keyword, type assertion function signatures and template literals in enum declarations.

Babel 现在支持三种新的配置文件:babel.config.json、babel.config.cjs 和 .babelrc.cjs,它们的行为和 babel.config.js、.babelrc.js 文件一样。

🌐 Babel now understands three new configuration files: babel.config.json, babel.config.cjs and .babelrc.cjs, which behave the same as babel.config.js and .babelrc.js files.

最后,Babel 7.7.0 比 7.6.0 少用 20% 的内存。

🌐 Lastly, Babel 7.7.0 uses 20% less memory than 7.6.0.

你可以在 GitHub 上阅读完整的更新日志。

🌐 You can read the whole changelog on GitHub.

7.6.0 发布:私有静态访问器和 V8 内部语法

· 8 min read

我们刚刚发布了一个新的小版本 Babel!

🌐 We just released a new minor Babel version!

它包括对类中静态私有访问器的支持,以及对 V8 内部语法的解析器支持。我们还修复了许多长期存在的与 TDZ 处理相关的问题,并改进了对 do 表达式的支持。你可以在 GitHub 上查看完整的更新日志。

🌐 It includes support for static private accessors in classes, and parser support for the V8 intrinsics syntax. We also fixed a bunch of long-standing issues related to TDZ handling, and improved support for do-expressions. You can read the whole changelog on GitHub.