Babel 中文文档
  • 印记中文
  • 文档
  • 配置
  • 试用
  • 视频
  • 博客
  • 赞助
  • 团队
  • GitHub

›All Blog Posts

All Blog Posts

  • 7.19.0 Released: Stage 3 decorators and more RegExp features!
  • 7.18.0 Released: Destructuring private elements and TypeScript 4.7
  • 7.17.0 Released: RegExp 'v' mode and ... 🥁 decorators!
  • 7.16.0 发布: ESLint 8 和 TypeScript 4.5
  • 7.15.0 发布:支持 Hack-style 管道, TypeScript 枚举常量和 Rhino 目标
  • Babel is used by millions, so why are we running out of money?
  • 7.14.0 Released: New class features enabled by default, TypeScript 4.3, and better CommonJS interop
  • 7.13.0 Released: Records and Tuples, granular compiler assumptions, and top-level targets
  • 7.12.0 Released: TypeScript 4.1, strings as import/export names, and class static blocks
  • 7.11.0 Released: ECMAScript 2021 support in preset-env, TypeScript 4.0 support, printing config and the future of `babel-eslint`
  • The State of babel-eslint
  • 7.10.0 Released: Class Fields in preset-env, '#private in' checks and better React tree-shaking
  • 7.9.0 Released: Smaller preset-env output, Typescript 3.8 support and a new JSX transform
  • 7.8.0 Released: ECMAScript 2020, .mjs configuration files and @babel/cli improvements
  • Babel's Funding Plans
  • 7.7.0 Released: Error recovery and TypeScript 3.7
  • 7.6.0 Released: Private static accessors and V8 intrinsic syntax
  • 7.5.0 Released: dynamic import and F# pipelines
  • The Babel Podcast
  • 7.4.0 Released: core-js 3, static private methods and partial application
  • 7.3.0 Released: Named capturing groups, private instance accessors and smart pipelines
  • 7.2.0 发布:私有实例方法(Private Instance Methods)
  • 在 Babel 中支持 TC39 标准的装饰器
  • 7.1.0 Released: Decorators, Private Static Fields
  • Babel 7 发布
  • Removing Babel's Stage Presets
  • What's Happening With the Pipeline (|>) Proposal?
  • Announcing Babel's New Partnership with trivago!
  • On Consuming (and Publishing) ES2015+ Packages
  • Nearing the 7.0 Release
  • Babel Turns Three
  • Planning for 7.0
  • Zero-config code transformation with babel-plugin-macros
  • Contributing to Babel: Three Lessons to Remember
  • Personal Experiences at Babel #1 — A PR with Unusually High Number of Reviews
  • Babel and Summer of Code 2017
  • Upgrade to Babel 7 (moved)
  • Upgrade to Babel 7 for Tool Authors (WIP)
  • 6.23.0 Released
  • The State of Babel
  • 6.19.0 Released
  • 6.18.0 Released
  • 6.16.0 Released
  • Babili (babel-minify)
  • 6.14.0 Released
  • Babel Doctor
  • Setting up Babel 6
  • 6.0.0 Released
  • React on ES6+
  • Function Bind Syntax
  • 5.0.0 Released
  • Babel 喜爱 React
  • 并非出生而逐渐走向灭亡
  • 2to3
  • 6to5 + esnext

7.19.0 Released: Stage 3 decorators and more RegExp features!

September 5, 2022

Babel Team

We just published Babel 7.19.0!

This release updates our implementation of the decorators proposal, which reached Stage 3 in March. It also includes support for the new duplicate named capturing groups proposal for regular expressions.

You can read the whole changelog on GitHub.

If you or your company want to support Babel and the evolution of JavaScript, 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! As a volunteer-driven project, we rely on the community's support to fund our efforts in supporting the wide range of JavaScript users. Reach out at team@babeljs.io if you'd like to discuss more!

Highlights

New default values

Given the stabilization of the decorators and Record and Tuple proposal, we set some default values for their parser plugin options:

  • decorators/@babel/plugin-proposal-decorators's decoratorsBeforeExport now defaults to false;
  • recordAndTuple/@babel/plugin-proposal-record-and-tuple's syntaxType option now defaults to hash.

These options will be removed in Babel 8.

Stage 3 decorators (#14836)

The decorators proposal was promoted to Stage 3 with some minor but observable changes. You can enable the new version using the "version": "2022-03" option of @babel/plugin-proposal-decorators:

{
  "plugins": [
    ["@babel/plugin-proposal-decorators", {
        "version": "2022-03"
    }]
  ]
}

If you are migrating from the 2021-12 version, the following breaking changes might affect you:

  • the initialize method of the object returned by accessor decorators has been renamed to init;
  • the isPrivate and isStatic properties of the context parameter received by the decorators (the second one) have been renamed to private and static;
  • the context parameter now always has an access property, regardless of the decorated element type;
  • support for metadata (getMetadata/setMetadata) has been removed and postponed to a future proposal;
  • @(expression)()-style decorators are disallowed, and you must use @(expression());
  • decorators are applied in the following order, instead of in a single pass:
    1. static method decorators
    2. proto method decorators
    3. static field decorators
    4. instance field decorators
    5. class decorators.

If you are migrating from an older version of the proposal, we suggest reading the full README. 😉

💡 TypeScript plans to implement this version of the proposal. After almost a decade, it will be possible to write decorators without worrying if they will be compiled by Babel or tsc!

RegExp duplicate named capturing groups (#14805)

Babel now supports the RegExp duplicate named capturing groups proposal, which allows re-using the same group name in alternative RegExp branches:

const dateRE = /(?<year>\d\d\d\d)-(?<month>\d\d)|(?<month>\d\d)-(?<year>\d\d)/;

console.log("2022-12".match(dateRE).groups); // { year: "2022", month: "12" }
console.log("12-2022".match(dateRE).groups); // { year: "2022", month: "12" }

You can enable this proposal using the @babel/plugin-proposal-duplicate-named-capturing-groups-regex plugin:

{
  "plugins": ["@babel/proposal-duplicate-named-capturing-groups-regex"]
}

Babel relies on different third-party packages to transform regular expressions: this is possible thanks to the maintainers of regjsparser, regjsgen and regexpu-core who took time to review our pull requests!

Recent Posts
  • Highlights
    • New default values
    • Stage 3 decorators (#14836)
    • RegExp duplicate named capturing groups (#14805)
Babel 中文文档
文档
学习 ES2015
社区
视频用户Stack OverflowSlack 频道Twitter
更多
博客GitHub 组织GitHub 仓库Website 仓库旧版网址 6.x旧版网址 5.x