Skip to content

Commit

Permalink
allow es2024 as a target environment
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Jun 29, 2024
1 parent 6475aea commit ab9b002
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
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).
* Allow `es2024` as a target environment
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`.
## 0.21.5
* Fix `Symbol.metadata` on classes without a class decorator ([#3781](https://github.com/evanw/esbuild/issues/3781))
Expand Down
3 changes: 3 additions & 0 deletions compat-table/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,9 @@ import('./kangax').then(kangax => {
js.ArbitraryModuleNamespaceNames.ES = { 2022: { force: true } }
js.RegexpMatchIndices.ES = { 2022: { force: true } }

// ES2024 features
js.RegexpSetNotation.ES = { 2024: { force: true } }

// This is a problem specific to Internet Explorer. See https://github.com/tc39/ecma262/issues/1440
for (const engine in engines) {
if (engine as Engine !== 'ES' && engine as Engine !== 'IE') {
Expand Down
4 changes: 3 additions & 1 deletion internal/compat/js_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,9 @@ var jsTable = map[JSFeature]map[Engine][]versionRange{
Opera: {{start: v{51, 0, 0}}},
Safari: {{start: v{11, 1, 0}}},
},
RegexpSetNotation: {},
RegexpSetNotation: {
ES: {{start: v{2024, 0, 0}}},
},
RegexpStickyAndUnicodeFlags: {
// Note: The latest version of "IE" failed 6 tests including: RegExp "y" and "u" flags: "u" flag
// Note: The latest version of "Rhino" failed 4 tests including: RegExp "y" and "u" flags: "u" flag
Expand Down
1 change: 1 addition & 0 deletions pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ const (
ES2021
ES2022
ES2023
ES2024
)

type Loader uint16
Expand Down
2 changes: 2 additions & 0 deletions pkg/api/api_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@ func validateFeatures(log logger.Log, target Target, engines []Engine) (compat.J
constraints[compat.ES] = compat.Semver{Parts: []int{2022}}
case ES2023:
constraints[compat.ES] = compat.Semver{Parts: []int{2023}}
case ES2024:
constraints[compat.ES] = compat.Semver{Parts: []int{2024}}
case ESNext, DefaultTarget:
default:
panic("Invalid target")
Expand Down
1 change: 1 addition & 0 deletions pkg/cli/cli_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,7 @@ func parseTargets(targets []string, arg string) (target api.Target, engines []ap
"es2021": api.ES2021,
"es2022": api.ES2022,
"es2023": api.ES2023,
"es2024": api.ES2024,
}

outer:
Expand Down
2 changes: 1 addition & 1 deletion scripts/js-api-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6824,7 +6824,7 @@ class Foo {
check('es2021', `x2 = /y/d`, `x2 = new RegExp("y", "d");\n`),

// RegExpSetNotation
check('esnext', `x1 = /[\\p{White_Space}&&\\p{ASCII}]/v`, `x1 = /[\\p{White_Space}&&\\p{ASCII}]/v;\n`),
check('es2024', `x1 = /[\\p{White_Space}&&\\p{ASCII}]/v`, `x1 = /[\\p{White_Space}&&\\p{ASCII}]/v;\n`),
check('es2022', `x2 = /[\\p{White_Space}&&\\p{ASCII}]/v`, `x2 = new RegExp("[\\\\p{White_Space}&&\\\\p{ASCII}]", "v");\n`),
])
},
Expand Down

0 comments on commit ab9b002

Please sign in to comment.