Skip to content

Commit ab9b002

Browse files
committed
allow es2024 as a target environment
1 parent 6475aea commit ab9b002

File tree

7 files changed

+15
-2
lines changed

7 files changed

+15
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
2929
TypeScript 5.5 subtly changes the way `await using` behaves. This release updates esbuild to match these changes in TypeScript. You can read more about these changes in [microsoft/TypeScript#58624](https://github.com/microsoft/TypeScript/pull/58624).
3030
31+
* Allow `es2024` as a target environment
32+
33+
The ECMAScript 2024 specification was just approved, so it has been added to esbuild as a possible compilation target. You can read more about the features that it adds here: [https://2ality.com/2024/06/ecmascript-2024.html](https://2ality.com/2024/06/ecmascript-2024.html). The only addition that's relevant for esbuild is the regular expression `/v` flag. With `--target=es2024`, regular expressions that use the `/v` flag will now be passed through untransformed instead of being transformed into a call to `new RegExp`.
34+
3135
## 0.21.5
3236
3337
* Fix `Symbol.metadata` on classes without a class decorator ([#3781](https://github.com/evanw/esbuild/issues/3781))

compat-table/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,9 @@ import('./kangax').then(kangax => {
392392
js.ArbitraryModuleNamespaceNames.ES = { 2022: { force: true } }
393393
js.RegexpMatchIndices.ES = { 2022: { force: true } }
394394

395+
// ES2024 features
396+
js.RegexpSetNotation.ES = { 2024: { force: true } }
397+
395398
// This is a problem specific to Internet Explorer. See https://github.com/tc39/ecma262/issues/1440
396399
for (const engine in engines) {
397400
if (engine as Engine !== 'ES' && engine as Engine !== 'IE') {

internal/compat/js_table.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,9 @@ var jsTable = map[JSFeature]map[Engine][]versionRange{
792792
Opera: {{start: v{51, 0, 0}}},
793793
Safari: {{start: v{11, 1, 0}}},
794794
},
795-
RegexpSetNotation: {},
795+
RegexpSetNotation: {
796+
ES: {{start: v{2024, 0, 0}}},
797+
},
796798
RegexpStickyAndUnicodeFlags: {
797799
// Note: The latest version of "IE" failed 6 tests including: RegExp "y" and "u" flags: "u" flag
798800
// Note: The latest version of "Rhino" failed 4 tests including: RegExp "y" and "u" flags: "u" flag

pkg/api/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ const (
133133
ES2021
134134
ES2022
135135
ES2023
136+
ES2024
136137
)
137138

138139
type Loader uint16

pkg/api/api_impl.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,8 @@ func validateFeatures(log logger.Log, target Target, engines []Engine) (compat.J
307307
constraints[compat.ES] = compat.Semver{Parts: []int{2022}}
308308
case ES2023:
309309
constraints[compat.ES] = compat.Semver{Parts: []int{2023}}
310+
case ES2024:
311+
constraints[compat.ES] = compat.Semver{Parts: []int{2024}}
310312
case ESNext, DefaultTarget:
311313
default:
312314
panic("Invalid target")

pkg/cli/cli_impl.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,7 @@ func parseTargets(targets []string, arg string) (target api.Target, engines []ap
981981
"es2021": api.ES2021,
982982
"es2022": api.ES2022,
983983
"es2023": api.ES2023,
984+
"es2024": api.ES2024,
984985
}
985986

986987
outer:

scripts/js-api-tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6824,7 +6824,7 @@ class Foo {
68246824
check('es2021', `x2 = /y/d`, `x2 = new RegExp("y", "d");\n`),
68256825

68266826
// RegExpSetNotation
6827-
check('esnext', `x1 = /[\\p{White_Space}&&\\p{ASCII}]/v`, `x1 = /[\\p{White_Space}&&\\p{ASCII}]/v;\n`),
6827+
check('es2024', `x1 = /[\\p{White_Space}&&\\p{ASCII}]/v`, `x1 = /[\\p{White_Space}&&\\p{ASCII}]/v;\n`),
68286828
check('es2022', `x2 = /[\\p{White_Space}&&\\p{ASCII}]/v`, `x2 = new RegExp("[\\\\p{White_Space}&&\\\\p{ASCII}]", "v");\n`),
68296829
])
68306830
},

0 commit comments

Comments
 (0)