新增特性时间轴
Which major new features did we introduce in each Babel version? This page includes a very short summary for each minor release, or you can read the full changelog on GitHub! Additionally, use this timeline to track some other important efforts, such as the babel-polyfills project.
Babel 7.24.0
- Support for the JSON modules Stage 3 proposal
Babel 7.23.0
- Support for the Decorator Metadata Stage 3 proposal
- Support for the Source Phase Import Stage 3 proposal
- Support for the Deferred Import Evaluation Stage 2 proposal
- Support for the Optional Chaining Assignment proposal
- Support for rewriting
.ts
extensions in imports
Babel 7.22.0
- Enable the Stage 4 RegExp
v
flag proposal by default - Support for the explicit resource management proposal Stage 3 proposal, including the async version
JavaScript
{
await using db = connect(databaseURL);
let user = await db.getUserById(userId);
await db.createPost(user.name, "Hi! :)");
} // Automatically close the db - Support for the updates of the decorators proposal that reached consensus in the March 2023 and May 2023 TC39 meetings
- Parsing support for the Stage 3 import attributes proposal, previously known as "import assertions"
JavaScript
import data from "./data.json" with { type: "json" };
- Enable the Stage 4 RegExp
Babel 7.21.0
- TypeScript 5.0 support
- Support for the updates of the decorators proposal that reached consensus in the January 2023 TC39 meeting
- Support for the inline RegExp modifiers Stage 3 proposal
JavaScript
/(?i-m:a.)/m.exec("a\nAb"); // ["Ab"]
Babel 7.20.0
- TypeScript 4.9 support
- Parser support for the explicit resource management Stage 2 proposal
JavaScript
{
using handle = openFile(name, "w+");
write(handle, "Hi!\n");
write(handle, ":)\n");
} // Automatically close the file - Parser support for the import reflection Stage 2 proposal
JavaScript
import module mod from "./mod.js";
// later ...
import(mod);
babel-loader 9.0.0
Babel 7.19.0
- Support for the Stage 3 version of the decorators proposal
- Transform support for the duplicate named capturing groups Stage 3 proposal
JavaScript
/(?<year>\d\d\d\d)-(?<month>\d\d)|(?<month>\d\d)-(?<year>\d\d\d\d)/
Babel 7.18.0
- TypeScript 4.7 support
- Transform support for the Private destructuring Stage 2 proposal
JavaScript
class A {
#x = 2;
method() {
const { #x: x } = this;
}
} - No more need to manually include the
regenerator-runtime
helper when compiling generators
Babel 7.17.0
- Support for the new version of the decorators Stage 2 proposal
JavaScript
class A {
@reactive #x = 2;
@logger
method() {
this.#x++;
}
} - Support for the RegExp set notation and properties of strings Stage 2 proposal
JavaScript
/[\p{RGI_Emoji}&&[\0-\uFFFF]]/v;
- Parser support for the private destructuring Stage 2 proposal
JavaScript
class A {
#x = 2;
method() {
const { #x: x } = this;
}
}
- Support for the new version of the decorators Stage 2 proposal
Babel 7.16.0
- Enable the class static blocks Stage 4 proposal by default
JavaScript
class A {
static {
initialize(A);
}
} - TypeScript 4.5 support
- Support ESLint 8 in
@babel/eslint-parser
.
- Enable the class static blocks Stage 4 proposal by default
Babel 7.15.0
- Enable parsing for the top-level
await
Stage 4 proposal by defaultJavaScriptimport db from "db";
await db.connect(); - Enable the Private Brand Checks Stage 4 proposal by default
JavaScript
class A {
static { initialize(A); } // static block
#field;
is(obj) {
return #field in obj; // private brand check
}
} - Support the "Hack-style" pipeline operator Stage 2 proposal
JavaScript
const result = "World" |> `Hello, ${%}!` |> alert(%);
- TypeScript 4.4 support
- Enable parsing for the top-level
Babel 7.14.0
- Enable the Class Fields, Private Methods and Static Class Features Stage 4 proposals by default
- Add the Private Brand Checks and Static Class Blocks proposals to
@babel/preset-env
'sshippedProposals
JavaScriptclass A {
static { initialize(A); } // static block
#field;
is(obj) {
return #field in obj; // private brand check
}
} - Support for the
async do
expressions proposalJavaScriptlet valP = async do {
2 + await computeIt();
}; - Support for the
importInterop: "node"
option in@babel/plugin-transform-modules-commonjs
, to aligh Babel with the Node.js behavior - TypeScript 4.3 support
Babel 7.13.0
- Top-level
targets
option (RFC) - Granular compiler assumptions (docs, RFC)
- Support for the Records and Tuples proposals
JavaScript
let rec = #{ x: 1 };
let tup = #[1, 2, 3]; - 支持 TypeScript 4.2
- Top-level
Babel 7.12.0
- Support for the class static blocks proposal
JavaScript
class A {
static { initialize(A); }
} - Support for imports and exports string names
JavaScript
let happy = "wooo!";
export { happy as "😃" }; - Parser support for the Import Assertions proposal
JavaScript
import json from "./foo.json" assert { type: "json" };
- 支持 TypeScript 4.1
- Support for the class static blocks proposal
Babel 7.11.0
- Enable the Logical Assignment and Numeric Separator Stage 4 proposals by default
- Parser support for the Decimal proposal
JavaScript
console.assert(0.1m + 0.2m === 0.3m);
- TypeScript 4.0 support
@babel/eslint-parser
Babel 7.10.0
- Enable parser support for the
import.meta
Stage 4 proposal by default - Support for the Ergonomic brand checks for Private Fields proposal
JavaScript
class Car {
#plate;
race(other) {
if (#plate in other) console.log("Racing against another car!");
}
}
- Enable parser support for the
babel-polyfills
Babel 7.9.0
- 在
@babel/preset-env
中新增bugfixes
选项, 以支持更灵活地解决游览器漏洞,而不是重新编译整个特性。 - 支持 TypeScript 3.8
- 支持 Flow
declare
类字段。 - 自动支持全新的 JSX 运行环境
- 在
Babel 7.8.0
- 默认支持 Optional Chaining 和 Nullish Coalescing 等 4 级提案
- 支持
.mjs
文件类型
Babel 7.7.0
- Parser support for the top-level
await
proposalJavaScriptimport db from "./database.js";
await db.connect(); - 在
@babel/parser
为早期错误添加错误恢复支持。 - 支持
.json
and.cjs
文件类型 - 支持 TypeScript 3.7
- Parser support for the top-level
Babel 7.6.0
- Support for static private accessors, part of the
static class features proposal
JavaScript
class Dog {
static get #className() { return "Dog"; }
}
- Support for static private accessors, part of the
static class features proposal
Babel 7.5.0
- Support for the F# pipeline operator proposal
JavaScript
num |> add(2) |> double
- 支持 TypeScript
namespace
- Support for the F# pipeline operator proposal
Babel 7.4.0
- Support for injecting
core-js@3
polyfills - Support for the Partial Application proposal
JavaScript
strings.map(parseInt(?));
- Support for static private methods, part of the
static class features proposal
JavaScript
class Dog {
static #register() { /* ... */ }
} - 支持 TypeScript 3.4
- Support for injecting
Babel 7.3.0
- Support for instance private accessors, part of the
private methods proposal
JavaScript
class Dog {
get #randomId() { return Math.random(); }
} - Support for the smart pipeline operator proposal
JavaScript
num |> add(2, #) |> double
- 在正则表达式中支持
named capturing groups
in regular expressions
JavaScript
str.match({String.raw`/^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})$/`})
- 支持 TypeScript 3.2 和 2.9
- Support for instance private accessors, part of the
private methods proposal
Babel 7.2.0
- Support for instance private methods, part of the private methods proposal
JavaScript
class Dog {
#bark() { console.log("Mew!") }
}
- Support for instance private methods, part of the private methods proposal
Babel 7.1.0
- Support for the decorators proposal, as it was specified in September 2018
JavaScript
class Person {
@autoIncrement age;
} - Support for static private fields, part of the static class features proposal
JavaScript
class Person {
static #classId = 3;
}
- Support for the decorators proposal, as it was specified in September 2018
Babel 7
此处列出了许多变化,因为它们是两年内将要发布的内容。
- Drop support for un-maintained Node versions: 0.10, 0.12, 4, 5
- Switch to scoped packages (
babel-core
to@babel/core
) - Remove yearly presets (
@babel/preset-es2015
) and Stage presets (@babel/preset-stage-0
) (blog post). - Added "pure" (
/*#__PURE__*/
) annotation support in certain cases. (Implemented later as @babel/helper-annotate-as-pure - Add project-wide
babel.config.js
config file (docs) andoverrides
config option. - Added
"useBuiltIns: "usage"
to@babel/preset-env
- Support TypeScript via
@babel/preset-typescript
- Support JSX Fragments
<></>
- Support a ton of TC39 proposals:
- Unicode Property Regex
- JSON Superset
new.target
- Class Private Instance Fields (
class A { #b = 2 }
) - Optional Catch Binding
try { throw 0 } catch { do() }
- BigInt (syntax only)
import.meta
(syntax only) (import.meta.url
)- Numeric Separators (
1_000
) function.sent
- Optional Chaining (
a?.b
) - Logical Assignment Operators (
a &&= b; a ||= b
) - Nullish Coalescing Operator (
a ?? b
) - Pipeline Operator (
a |> b
) - Throw Expressions (
() => throw new Error("a")
)