We just released a new minor version of Babel!
This 7.11 release includes:
preset-env
support for Logical Assignments (??=
), Numeric Separators (1_2
) and Namespace re-exports (export * as ns from ...
)- TypeScript 4.0 support
- Parser support for the Stage-1 Decimal proposal (
7.11m
) - An environment flag to print the resolved Babel configuration for a given file (
BABEL_SHOW_CONFIG_FOR
)
In addition to this, we are now releasing the successor of babel-eslint
: @babel/eslint-parser
!
You can read the whole changelog on GitHub.
Also if you have any questions or something you want to discuss, we've enabled GitHub Discussions on our repository!
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!
ECMAScript 2021 support (#11864)
During the last meeting, TC39 moved both the logical assignment and numeric separator proposals to Stage 4! Babel already had support these proposals via the @babel/plugin-proposal-logical-assignment-operators
and @babel/plugin-proposal-numeric-separators
plugins. They are now included in @babel/preset-env
and compiled based on your targets, like any other ECMAScript feature.
Logical Assignment
Logical assignment offers a shorthand notation combining logical operators and assignment expression:
this.disabled ??= false;
this.disabled ?? (this.disabled = false);
clicked &&= !isDoubleClicked();
clicked = clicked && !isDoubleClicked();
hasDups ||= (prev === cur);
if (!hasDup) hasDups = (prev === cur);
Numeric Separator
The numeric separator (_
) is a character you can insert between digits in numeric literals to help with visual separation:
1_000_000_000
0.000_000_000_1
Export namespace from (#11849)
An imported module can be re-exported as a new namespace:
export * as ns from "mod";
This was already included in ECMAScript 2020, but it wasn't supported by @babel/preset-env
yet.
Since version 7.11, @babel/preset-env
skips @babel/plugin-proposal-export-namespace-from
if the caller
supports it: this can leave export * as ns
as-is to be directly processed by the bundlers. Note: babel-loader
and @rollup/plugin-babel
don't yet tell Babel they supports this syntax, but we are working on it with the relevant maintainers.
If { modules: false }
is set, Babel will assume that the transpiled code will be run in engines that have native ESM support. export * as ns
will be compiled based on targets
, like any other ECMAScript feature.
If you intend to bundle the transpiled code, please remove { modules: false }
option. By default preset-env
will determine the module transforms from caller
data passed from babel-loader
and @rollup/plugin-babel
.
{
"presets": [
["@babel/env", {
"targets": ["defaults"],
- "modules": false,
}]
}