Skip to content

Commit 5fcce46

Browse files
authored
fix(css): lightningcss minify failed when build.target: 'es6' (#21933)
1 parent a30d5e7 commit 5fcce46

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

packages/vite/src/node/__tests__/plugins/css.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@ describe('convertTargets', () => {
274274
safari: 852224,
275275
})
276276
})
277+
278+
test('supports es6 as an alias of es2015', () => {
279+
expect(convertTargets('es6')).toStrictEqual(convertTargets('es2015'))
280+
})
277281
})
278282

279283
describe('getEmptyChunkReplacer', () => {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3479,7 +3479,7 @@ const esMap: Record<number, string[]> = {
34793479
],
34803480
}
34813481

3482-
const esRE = /es(\d{4})/
3482+
const esRE = /es(6|\d{4})/
34833483
const versionRE = /\d/
34843484

34853485
const convertTargetsCache = new Map<
@@ -3497,7 +3497,7 @@ export const convertTargets = (
34973497
const entriesWithoutES = arraify(esbuildTarget).flatMap((e) => {
34983498
const match = esRE.exec(e)
34993499
if (!match) return e
3500-
const year = Number(match[1])
3500+
const year = match[1] === '6' ? 2015 : Number(match[1])
35013501
if (!esMap[year]) throw new Error(`Unsupported target "${e}"`)
35023502
return esMap[year]
35033503
})

0 commit comments

Comments
 (0)