Skip to content

Commit 0f61546

Browse files
Merge branch 'main' into proposal-to-transform
2 parents 262a388 + 1a77e37 commit 0f61546

17 files changed

+314
-53
lines changed

docs/parser.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ require("@babel/parser").parse("code", {
211211

212212
| Version | Changes |
213213
| --- | --- |
214+
| `v7.22.0` | Enabled `regexpUnicodeSets` by default |
214215
| `v7.20.0` | Added `explicitResourceManagement`, `importReflection` |
215216
| `v7.17.0` | Added `regexpUnicodeSets`, `destructuringPrivate`, `decoratorAutoAccessors` |
216217
| `v7.15.0` | Added `hack` to the `proposal` option of `pipelineOperator`. Moved `topLevelAwait`, `privateIn` to Latest ECMAScript features |
@@ -243,7 +244,6 @@ require("@babel/parser").parse("code", {
243244
| `partialApplication` ([proposal](https://github.com/babel/proposals/issues/32)) | `f(?, a)` |
244245
| `pipelineOperator` ([proposal](https://github.com/babel/proposals/issues/29)) | <code>a &#124;> b</code> |
245246
| `recordAndTuple` ([proposal](https://github.com/tc39/proposal-record-tuple)) | `#{x: 1}`, `#[1, 2]` |
246-
| `regexpUnicodeSets` ([proposal](https://github.com/tc39/proposal-regexp-set-notation)) | `/[\p{Decimal_Number}--[0-9]]/v;` |
247247
| `throwExpressions` ([proposal](https://github.com/babel/proposals/issues/23)) | `() => throw new Error("")` |
248248

249249
#### Latest ECMAScript features
@@ -269,6 +269,7 @@ You should enable these features only if you are using an older version.
269269
| `optionalCatchBinding` ([proposal](https://github.com/babel/proposals/issues/7)) | `try {throw 0;} catch{do();}` |
270270
| `optionalChaining` ([proposal](https://github.com/tc39/proposal-optional-chaining)) | `a?.b` |
271271
| `privateIn` ([proposal](https://github.com/tc39/proposal-private-fields-in-in)) | `#p in obj` |
272+
| `regexpUnicodeSets` ([proposal](https://github.com/tc39/proposal-regexp-set-notation)) | `/[\p{Decimal_Number}--[0-9]]/v;` |
272273
| `topLevelAwait` ([proposal](https://github.com/tc39/proposal-top-level-await/)) | `await promise` in modules |
273274

274275
#### Plugins options

docs/plugin-proposal-decorators.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ npm install --save-dev @babel/plugin-proposal-decorators
6262
```json title="babel.config.json"
6363
{
6464
"plugins": [
65-
["@babel/plugin-proposal-decorators", { "version": "2023-01" }]
65+
["@babel/plugin-proposal-decorators", { "version": "2023-05" }]
6666
]
6767
}
6868
```
@@ -72,7 +72,7 @@ npm install --save-dev @babel/plugin-proposal-decorators
7272
```js title="JavaScript"
7373
require("@babel/core").transformSync("code", {
7474
plugins: [
75-
["@babel/plugin-proposal-decorators", { version: "2023-01" }],
75+
["@babel/plugin-proposal-decorators", { version: "2023-05" }],
7676
]
7777
});
7878
```
@@ -84,16 +84,18 @@ require("@babel/core").transformSync("code", {
8484

8585
| Version | Changes |
8686
| --- | --- |
87+
| `v7.22.0` | Added support for `version: "2023-05"` |
8788
| `v7.21.0` | Added support for `version: "2023-01"` |
8889
| `v7.19.0` | Added support for `version: "2022-03"` |
8990
| `v7.17.0` | Added the `version` option with support for `"2021-12"`, `"2018-09"` and `"legacy"` |
9091
</details>
9192

9293
### `version`
9394

94-
`"2023-01"`, `"2022-03"`, `"2021-12"`, `"2018-09"` or `"legacy"`.
95+
`"2023-05"`, `"2023-01"`, `"2022-03"`, `"2021-12"`, `"2018-09"` or `"legacy"`.
9596

9697
Selects the decorators proposal to use:
98+
- `"2023-05"` is the proposal version after the updates that reached consensus in the March and May 2023 TC39 meetings, integrating [these changes](https://github.com/pzuraq/ecma262/compare/e86128e13b63a3c2efc3728f76c8332756752b02...c4465e44d514c6c1dba810487ec2721ccd6b08f9).
9799
- `"2023-01"` is the proposal version after the updates that reached consensus in the January 2023 TC39 meeting, integrating [`pzuraq/ecma262#4`](https://github.com/pzuraq/ecma262/pull/4).
98100
- `"2022-03"` is the proposal version that reached consensus for Stage 3 in the March 2022 TC39 meeting. You can read more about it at [`tc39/proposal-decorators@8ca65c046d`](https://github.com/tc39/proposal-decorators/tree/8ca65c046dd5e9aa3846a1fe5df343a6f7efd9f8).
99101
- `"2021-12"` is the proposal version as it was presented to TC39 in Dec 2021. You can read more about it at [`tc39/proposal-decorators@d6c056fa06`](https://github.com/tc39/proposal-decorators/tree/d6c056fa061646178c34f361bad33d583316dc85).
@@ -107,7 +109,7 @@ If you specify the `decoratorsBeforeExport` option, `version` defaults to `"2018
107109
### `decoratorsBeforeExport`
108110

109111
This option:
110-
- is disallowed when using `version: "legacy"`, `version: "2022-03"`, or `version: "2023-01"`;
112+
- is disallowed when using `version: "legacy"`, `version: "2022-03"`, `version: "2023-01"`, or `version: "2023-05"`;
111113
- is required when using `version: "2018-09"`;
112114
- is optional and defaults to `false` when using `version: "2021-12"`.
113115

@@ -155,7 +157,7 @@ If you are already using `@babel/preset-env`, you can safely remove `@babel/plug
155157
"presets": ["@babel/preset-env"],
156158
"plugins": [
157159
- "@babel/plugin-transform-class-properties",
158-
["@babel/plugin-proposal-decorators", { "version": "2023-01" }]
160+
["@babel/plugin-proposal-decorators", { "version": "2023-05" }]
159161
]
160162
}
161163
```
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
id: babel-plugin-proposal-explicit-resource-management
3+
title: "@babel/plugin-proposal-explicit-resource-management"
4+
sidebar_label: explicit-resource-management
5+
---
6+
7+
This plugin enables Babel to transform using declarations `using handler = await read();`.
8+
9+
## Example
10+
11+
```js title="input.js"
12+
using handlerSync = openSync();
13+
await using handlerAsync = await openAsync();
14+
```
15+
16+
will be transformed to
17+
18+
```js title="output.js"
19+
try {
20+
var _stack = [];
21+
var handlerSync = babelHelpers.using(_stack, openSync());
22+
var handlerAsync = babelHelpers.using(_stack, await openAsync(), true);
23+
} catch (_) {
24+
var _error = _;
25+
var _hasError = true;
26+
} finally {
27+
await babelHelpers.dispose(_stack, _error, _hasError);
28+
}
29+
```
30+
31+
[Try it on the REPL](https://babeljs.io/repl#?build=&builtIns=false&corejs=3.28&spec=false&loose=false&code_lz=K4Zwlgdg5gBAFgQwgEwDYFMBOBlAnhAYxgF4YB7AB3Qj0IAoBKAbgCgEB3BMAFxlEliIUGTAEEQ-IqQ5delauMmMmQA&debug=false&forceAllTransforms=false&modules=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=true&presets=react&prettier=false&targets=&externalPlugins=%40babel%2Fplugin-proposal-explicit-resource-management%407.22.0%2C%40babel%2Fplugin-external-helpers%407.18.6&assumptions=%7B%7D).
32+
33+
## Installation
34+
35+
```shell npm2yarn
36+
npm install --save-dev @babel/plugin-proposal-explicit-resource-management
37+
```
38+
39+
## Usage
40+
41+
### With a configuration file (Recommended)
42+
43+
```json title="babel.config.json"
44+
{
45+
"plugins": ["@babel/plugin-proposal-explicit-resource-management"]
46+
}
47+
```
48+
49+
### Via CLI
50+
51+
```sh title="Shell"
52+
babel --plugins @babel/plugin-proposal-explicit-resource-management script.js
53+
```
54+
55+
### Via Node API
56+
57+
```js title="JavaScript"
58+
require("@babel/core").transformSync("code", {
59+
plugins: ["@babel/plugin-proposal-explicit-resource-management"]
60+
});
61+
```
62+
63+
## References
64+
65+
- [Proposal: ECMAScript Explicit Resource Management](https://github.com/tc39/proposal-explicit-resource-management)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
id: babel-plugin-proposal-import-attributes-to-assertions
3+
title: "@babel/plugin-proposal-import-attributes-to-assertions"
4+
sidebar_label: import-attributes-to-assertions
5+
---
6+
7+
:::caution
8+
9+
This plugin will generate code that is not compatible with the current ECMAScript specification or with any currently proposed addition to it. Only use it when you are shipping native ES modules and you need compatibility exclusively with tools that don't support the Import Attributes syntax (`import pkg from "./package.json" with { type: "json" }`) but support the old Import Assertions syntax (`import pkg from "./package.json" assert { type: "json" }`), such as Chrome 91+ and Node.js 17.2+.
10+
11+
:::
12+
13+
## Installation
14+
15+
```shell npm2yarn
16+
npm install --save-dev @babel/plugin-proposal-import-attributes-to-assertions
17+
```
18+
19+
## Usage
20+
21+
### With a configuration file (Recommended)
22+
23+
```json title="babel.config.json"
24+
{
25+
"plugins": ["@babel/plugin-proposal-import-attributes-to-assertions"]
26+
}
27+
```
28+
29+
### Via CLI
30+
31+
```sh title="Shell"
32+
babel --plugins @babel/plugin-proposal-import-attributes-to-assertions script.js
33+
```
34+
35+
### Via Node API
36+
37+
```js title="JavaScript"
38+
require("@babel/core").transformSync("code", {
39+
plugins: ["@babel/plugin-proposal-import-attributes-to-assertions"],
40+
});
41+
```

docs/plugin-proposal-unicode-sets-regex.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ title: "@babel/plugin-proposal-unicode-sets-regex"
44
sidebar_label: unicode-sets-regex
55
---
66

7+
> **NOTE**: This plugin is included in `@babel/preset-env`, in [ES2024](https://github.com/tc39/proposals/blob/master/finished-proposals.md)
8+
79
This plugin transforms regular expressions using the `v` flag, introduced by the [RegExp set notation + properties of strings](https://github.com/tc39/proposal-regexp-set-notation) proposal, to regular expressions that use the `u` flag.
810

911
## Example

docs/plugin-syntax-explicit-resource-management.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,21 @@ sidebar_label: syntax-explicit-resource-management
66

77
> #### Syntax only
88
>
9-
> This plugin only enables Babel to parse this syntax. Babel does not support transforming this syntax
9+
> It's unlikely you want to use this plugin directly as it only enables Babel to parse this syntax. Instead, use [plugin-proposal-explicit-resource-management](plugin-proposal-explicit-resource-management.md) to _both_ parse and transform this syntax.
10+
11+
<details>
12+
<summary>History</summary>
13+
14+
| Version | Changes |
15+
| --- | --- |
16+
| v7.22.0 | Supports `await using` |
17+
</details>
1018

1119
This plugin enables Babel to parse using declarations:
1220

1321
```js title="JavaScript"
1422
using handler = await read();
23+
await using handler = await read();
1524
```
1625

1726
## Installation
@@ -43,3 +52,6 @@ require("@babel/core").transformSync("code", {
4352
plugins: ["@babel/plugin-syntax-explicit-resource-management"]
4453
});
4554
```
55+
56+
## Reference
57+
- [Proposal: ECMAScript Explicit Resource Management](https://github.com/tc39/proposal-explicit-resource-management)

docs/plugin-transform-modules-amd.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,39 @@ require("@babel/core").transformSync("code", {
6868
});
6969
```
7070

71-
### Options
71+
## Options
7272

73-
See options for [`@babel/plugin-transform-modules-commonjs`](https://babeljs.io/docs/en/babel-plugin-transform-modules-commonjs#options).
73+
### `moduleIds`
74+
75+
`boolean` defaults to `!!moduleId`
76+
77+
Added in: `v7.9.0`
78+
79+
Enables module ID generation.
80+
81+
### `moduleId`
82+
83+
`string`
84+
85+
Added in: `v7.9.0`
86+
87+
A hard-coded ID to use for the module. Cannot be used alongside `getModuleId`.
88+
89+
### `getModuleId`
90+
91+
`(name: string) => string`
92+
93+
Added in: `v7.9.0`
94+
95+
Given the babel-generated module name, return the name to use. Returning
96+
a falsy value will use the original `name`.
97+
98+
### `moduleRoot`
99+
100+
`string`
101+
102+
Added in: `v7.9.0`
103+
104+
A root path to include on generated module names.
105+
106+
For options not listed here, see options for [`@babel/plugin-transform-modules-commonjs`](plugin-transform-modules-commonjs.md#options).

docs/plugin-transform-modules-systemjs.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,38 @@ require("@babel/core").transformSync("code", {
7878
plugins: ["@babel/plugin-transform-modules-systemjs"],
7979
});
8080
```
81+
82+
## Options
83+
84+
### `moduleIds`
85+
86+
`boolean` defaults to `!!moduleId`
87+
88+
Added in: `v7.9.0`
89+
90+
Enables module ID generation.
91+
92+
### `moduleId`
93+
94+
`string`
95+
96+
Added in: `v7.9.0`
97+
98+
A hard-coded ID to use for the module. Cannot be used alongside `getModuleId`.
99+
100+
### `getModuleId`
101+
102+
`(name: string) => string`
103+
104+
Added in: `v7.9.0`
105+
106+
Given the babel-generated module name, return the name to use. Returning
107+
a falsy value will use the original `name`.
108+
109+
### `moduleRoot`
110+
111+
`string`
112+
113+
Added in: `v7.9.0`
114+
115+
A root path to include on generated module names.

docs/plugin-transform-modules-umd.md

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,39 @@ require("@babel/core").transformSync("code", {
233233
});
234234
```
235235

236-
### Options
236+
## Options
237237

238-
See options for [`@babel/plugin-transform-modules-commonjs`](https://babeljs.io/docs/en/babel-plugin-transform-modules-commonjs#options).
238+
### `moduleIds`
239+
240+
`boolean` defaults to `!!moduleId`
241+
242+
Added in: `v7.9.0`
243+
244+
Enables module ID generation.
245+
246+
### `moduleId`
247+
248+
`string`
249+
250+
Added in: `v7.9.0`
251+
252+
A hard-coded ID to use for the module. Cannot be used alongside `getModuleId`.
253+
254+
### `getModuleId`
255+
256+
`(name: string) => string`
257+
258+
Added in: `v7.9.0`
259+
260+
Given the babel-generated module name, return the name to use. Returning
261+
a falsy value will use the original `name`.
262+
263+
### `moduleRoot`
264+
265+
`string`
266+
267+
Added in: `v7.9.0`
268+
269+
A root path to include on generated module names.
270+
271+
For options not listed here, see options for [`@babel/plugin-transform-modules-commonjs`](plugin-transform-modules-commonjs.md#options).

docs/plugin-transform-typescript.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,6 @@ Because there are features of the TypeScript language which rely on the full typ
257257

258258
1. Since Babel does not type-check, code which is syntactically correct, but would fail the TypeScript type-checking may successfully get transformed, and often in unexpected or invalid ways.
259259

260-
1. This plugin does not support [`export =`][exin] and [`import =`][exin], because those cannot be compiled to ES.next. These are a TypeScript only form of `import`/`export`.
261-
262-
**Workarounds**:
263-
264-
- Use the plugin [babel-plugin-replace-ts-export-assignment](https://www.npmjs.com/package/babel-plugin-replace-ts-export-assignment) to transform `export =`.
265-
- Convert to using `export default` and `export const`, and `import x, {y} from "z"`.
266-
267260
1. Changes to your `tsconfig.json` are not reflected in babel. The build process will always behave as though [`isolatedModules`][iso-mods] is turned on, there are Babel-native alternative ways to set a lot of the [`tsconfig.json` options](#typescript-compiler-options) however.
268261

269262
1. **Q**: Why doesn't Babel allow export of a `var` or `let`?

0 commit comments

Comments
 (0)