Skip to content

Commit 18dafee

Browse files
committed
fix: useDefineForClassFields: true with ES2022<
1 parent 29a7cc7 commit 18dafee

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

packages/vite/src/node/plugins/oxc.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,12 @@ export async function transformWithOxc(
195195
resolvedOptions.assumptions.setPublicClassFields =
196196
!useDefineForClassFields
197197

198-
// set target to es2022 or lower to enable class property transforms
198+
// set target to es2021 or lower to enable class property transforms
199199
// https://github.com/oxc-project/oxc/issues/6735#issuecomment-2513866362
200200
if (!useDefineForClassFields) {
201201
let set = false
202202
if (!resolvedOptions.target) {
203-
resolvedOptions.target = 'es2022'
203+
resolvedOptions.target = 'es2021'
204204
set = true
205205
} else {
206206
const target = Array.isArray(resolvedOptions.target)
@@ -213,21 +213,21 @@ export async function transformWithOxc(
213213
const esTargetTrimmed = target[esTargetIndex].toLowerCase().slice(2)
214214
if (
215215
esTargetTrimmed === 'next' ||
216-
parseInt(esTargetTrimmed, 10) > 2022
216+
parseInt(esTargetTrimmed, 10) > 2021
217217
) {
218-
target[esTargetIndex] = 'es2022'
218+
target[esTargetIndex] = 'es2021'
219219
set = true
220220
}
221221
} else {
222-
target.push('es2022')
222+
target.push('es2021')
223223
set = true
224224
}
225225
resolvedOptions.target = target
226226
}
227227

228228
if (set) {
229229
warnings.push(
230-
'target was modified to include ES2022' +
230+
'target was modified to include ES2021' +
231231
' because useDefineForClassFields is set to false' +
232232
' and oxc does not support transforming useDefineForClassFields=false for ES2022+ yet',
233233
)

playground/tsconfig-json/__tests__/tsconfig-json.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { transformWithEsbuild } from 'vite'
44
import { describe, expect, test } from 'vitest'
55
import { browserLogs, isServe, serverLogs } from '~utils'
66

7-
test.skip('should respected each `tsconfig.json`s compilerOptions', () => {
7+
test('should respected each `tsconfig.json`s compilerOptions', () => {
88
// main side effect should be called (because of `"verbatimModuleSyntax": true`)
99
expect(browserLogs).toContain('main side effect')
1010
// main base setter should not be called (because of `"useDefineForClassFields": true"`)

0 commit comments

Comments
 (0)