Skip to content

Commit

Permalink
add unicode-sets-regex to preset-env (#2785)
Browse files Browse the repository at this point in the history
* add unicode-sets-regex to preset-env

* move `regexpUnicodeSets` to latest ECMAScript features

* Update docs/parser.md

---------

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
  • Loading branch information
JLHwung and nicolo-ribaudo committed May 26, 2023
1 parent 1f3bc9d commit 45510f9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion docs/parser.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ require("@babel/parser").parse("code", {

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

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

#### Plugins options
Expand Down
2 changes: 2 additions & 0 deletions docs/plugin-proposal-unicode-sets-regex.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ title: "@babel/plugin-proposal-unicode-sets-regex"
sidebar_label: unicode-sets-regex
---

> **NOTE**: This plugin is included in `@babel/preset-env`, in [ES2024](https://github.com/tc39/proposals/blob/master/finished-proposals.md)
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.

## Example
Expand Down
6 changes: 5 additions & 1 deletion website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ module.exports = {
id: "babel-preset-env",
},
items: [
{
type: "category",
label: "ES2024",
items: ["babel-plugin-proposal-unicode-sets-regex"],
},
{
type: "category",
label: "ES2022",
Expand Down Expand Up @@ -227,7 +232,6 @@ module.exports = {
"babel-plugin-proposal-record-and-tuple",
"babel-plugin-proposal-regexp-modifiers",
"babel-plugin-proposal-throw-expressions",
"babel-plugin-proposal-unicode-sets-regex",
],
},
};

0 comments on commit 45510f9

Please sign in to comment.