fix(css): lightningcss minify failed when build.target: 'es6'#21933
Merged
sapphi-red merged 1 commit intovitejs:mainfrom Mar 19, 2026
Merged
fix(css): lightningcss minify failed when build.target: 'es6'#21933sapphi-red merged 1 commit intovitejs:mainfrom
build.target: 'es6'#21933sapphi-red merged 1 commit intovitejs:mainfrom
Conversation
…s `es6`
## Repro
Running the following commands:
```sh
npx -y create-vite@latest -t vanilla --no-interactive
cd vite-project
npm i
echo 'export default { build: { target: "es6" } }' > vite.config.js
npm run build
```
will produce the following output:
```log
> [email protected] build
> vite build
vite v8.0.0 building client environment for production...
✓ 9 modules transformed.
✗ Build failed in 76ms
error during build:
Build failed with 1 error:
[plugin vite:css-post]
Error: [lightningcss minify] Unsupported target "es6"
at convertTargets (file:///D:/a/vite-project/node_modules/vite/dist/node/chunks/node.js:21916:9)
at minifyCSS (file:///D:/a/vite-project/node_modules/vite/dist/node/chunks/node.js:21172:13)
at async finalizeCss (file:///D:/a/vite-project/node_modules/vite/dist/node/chunks/node.js:21016:36)
at async Promise.all (index 1)
at async Object.run (file:///D:/a/vite-project/node_modules/vite/dist/node/chunks/node.js:2437:22)
at async PluginContextImpl.renderChunk (file:///D:/a/vite-project/node_modules/vite/dist/node/chunks/node.js:20555:19)
at async plugin (file:///D:/a/vite-project/node_modules/rolldown/dist/shared/bindingify-input-options-Cu7pt6SZ.mjs:1211:16)
at async plugin.<computed> (file:///D:/a/vite-project/node_modules/rolldown/dist/shared/bindingify-input-options-Cu7pt6SZ.mjs:1570:12)
at aggregateBindingErrorsIntoJsError (file:///D:/a/vite-project/node_modules/rolldown/dist/shared/error-CP8smW_P.mjs:48:18)
at unwrapBindingResult (file:///D:/a/vite-project/node_modules/rolldown/dist/shared/error-CP8smW_P.mjs:18:128)
at #build (file:///D:/a/vite-project/node_modules/rolldown/dist/shared/rolldown-build-4YnQkA76.mjs:3311:34)
at async buildEnvironment (file:///D:/a/vite-project/node_modules/vite/dist/node/chunks/node.js:32794:64)
at async Object.build (file:///D:/a/vite-project/node_modules/vite/dist/node/chunks/node.js:33216:19)
at async Object.buildApp (file:///D:/a/vite-project/node_modules/vite/dist/node/chunks/node.js:33213:153)
at async CAC.<anonymous> (file:///D:/a/vite-project/node_modules/vite/dist/node/cli.js:778:3) {
errors: [Getter/Setter]
}
```
This only occurs when `config.build.target` is `es6`. It will not occur with `es2015`.
The reason js bundling works correctly is that oxc specifically supports the string `es6` along with `es2015`:
https://github.com/oxc-project/oxc/blob/c481b2fc7423cbeaff7cfbded4e569618e3e4bda/crates/oxc_syntax/src/es_target.rs#L31
Using `target: 'es6', cssMinify: 'lightningcss'` in vite 7 also produces the same error. And since `cssMinify: 'lightningcss'` is the default behavior in vite 8, to reduce migration regressions, I suggest supporting `es6` as an alias of `es2015` for the `convertTargets()` method of plugin css.
This patch can also be safely backported to vite 7.
bluwy
approved these changes
Mar 19, 2026
Member
bluwy
left a comment
There was a problem hiding this comment.
Makes sense to me 👍 I don't think we have to backport this yet since lightningcss support in vite 7 is experimental and they could migrate to the full es2015 string instead.
config.build.target is es6build.target: 'es6'
renovate bot
added a commit
to andrei-picus-tink/auto-renovate
that referenced
this pull request
Mar 31, 2026
| datasource | package | from | to | | ---------- | ------- | ----- | ----- | | npm | vite | 7.3.1 | 8.0.3 | ## [v8.0.3](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-803-2026-03-26-small) ##### Features - update rolldown to 1.0.0-rc.12 ([#22024](vitejs/vite#22024)) ([84164ef](vitejs/vite@84164ef)) ##### Bug Fixes - **html:** cache unfiltered CSS list to prevent missing styles across entries ([#22017](vitejs/vite#22017)) ([5464190](vitejs/vite@5464190)) - **module-runner:** handle non-ascii characters in base64 sourcemaps ([#21985](vitejs/vite#21985)) ([77c95bf](vitejs/vite@77c95bf)) - **module-runner:** skip re-import if the runner is closed ([#22020](vitejs/vite#22020)) ([ee2c2cd](vitejs/vite@ee2c2cd)) - **optimizer:** scan is not resolving sub path import if used in a glob import ([#22018](vitejs/vite#22018)) ([ddfe20d](vitejs/vite@ddfe20d)) - **ssr:** ssrTransform incorrectly rewrites `meta` identifier inside `import.meta` when a binding named `meta` exists ([#22019](vitejs/vite#22019)) ([cff5f0c](vitejs/vite@cff5f0c)) ##### Miscellaneous Chores - **deps:** bump picomatch from 4.0.3 to 4.0.4 ([#22027](vitejs/vite#22027)) ([7e56003](vitejs/vite@7e56003)) ##### Tests - **html:** add tests for `getCssFilesForChunk` ([#22016](vitejs/vite#22016)) ([43fbbf9](vitejs/vite@43fbbf9)) ## [v8.0.2](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-802-2026-03-23-small) ##### Features - update rolldown to 1.0.0-rc.11 ([#21998](vitejs/vite#21998)) ([ff91c31](vitejs/vite@ff91c31)) ##### Bug Fixes - **deps:** update all non-major dependencies ([#21988](vitejs/vite#21988)) ([9b7d150](vitejs/vite@9b7d150)) ##### Miscellaneous Chores - **deps:** update dependency [@vitejs/devtools](https://github.com/vitejs/devtools) to ^0.1.5 ([#21992](vitejs/vite#21992)) ([b2dd65b](vitejs/vite@b2dd65b)) ## [v8.0.1](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#small-801-2026-03-19-small) ##### Features - update rolldown to 1.0.0-rc.10 ([#21932](vitejs/vite#21932)) ([b3c067d](vitejs/vite@b3c067d)) ##### Bug Fixes - **bundled-dev:** properly disable `inlineConst` optimization ([#21865](vitejs/vite#21865)) ([6d97142](vitejs/vite@6d97142)) - **css:** lightningcss minify failed when `build.target: 'es6'` ([#21933](vitejs/vite#21933)) ([5fcce46](vitejs/vite@5fcce46)) - **deps:** update all non-major dependencies ([#21878](vitejs/vite#21878)) ([6dbbd7f](vitejs/vite@6dbbd7f)) - **dev:** always use ESM Oxc runtime ([#21829](vitejs/vite#21829)) ([d323ed7](vitejs/vite@d323ed7)) - **dev:** handle concurrent restarts in `_createServer` ([#21810](vitejs/vite#21810)) ([40bc729](vitejs/vite@40bc729)) - handle `+` symbol in package subpath exports during dep optimization ([#21886](vitejs/vite#21886)) ([86db93d](vitejs/vite@86db93d)) - improve `no-cors` request block error ([#21902](vitejs/vite#21902)) ([5ba688b](vitejs/vite@5ba688b)) - use precise regexes for transform filter to avoid backtracking ([#21800](vitejs/vite#21800)) ([dbe41bd](vitejs/vite@dbe41bd)) - **worker:** `require(json)` result should not be wrapped ([#21847](vitejs/vite#21847)) ([0672fd2](vitejs/vite@0672fd2)) - **worker:** make worker output consistent with client and SSR ([#21871](vitejs/vite#21871)) ([69454d7](vitejs/vite@69454d7)) ##### Miscellaneous Chores - add changelog rearrange script ([#21835](vitejs/vite#21835)) ([efef073](vitejs/vite@efef073)) - **deps:** bump required `@vitejs/devtools` version to 0.1+ ([#21925](vitejs/vite#21925)) ([12932f5](vitejs/vite@12932f5)) - **deps:** update rolldown-related dependencies ([#21787](vitejs/vite#21787)) ([1af1d3a](vitejs/vite@1af1d3a)) - rearrange 8.0 changelog ([8e05b61](vitejs/vite@8e05b61)) - rearrange 8.0 changelog ([#21834](vitejs/vite#21834)) ([86edeee](vitejs/vite@86edeee)) ## [v8.0.0](https://github.com/vitejs/vite/blob/HEAD/packages/vite/CHANGELOG.md#800-2026-03-12) ##### Features - update rolldown to 1.0.0-rc.9 ([#21813](vitejs/vite#21813)) ([f05be0e](vitejs/vite@f05be0e)) - warn when `vite-tsconfig-paths` plugin is detected ([#21781](vitejs/vite#21781)) ([ada493e](vitejs/vite@ada493e)) ##### Bug Fixes - **deps:** update all non-major dependencies ([#21786](vitejs/vite#21786)) ([eaa4352](vitejs/vite@eaa4352))
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Repro
Running the following commands:
will produce the following output:
This only occurs when
config.build.targetises6. It will not occur withes2015.The reason js bundling works correctly is that oxc specifically supports the string
es6along withes2015:https://github.com/oxc-project/oxc/blob/c481b2fc7423cbeaff7cfbded4e569618e3e4bda/crates/oxc_syntax/src/es_target.rs#L31
fn from_str(s: &str) -> Result<Self, Self::Err> { match s.cow_to_ascii_lowercase().as_ref() { "es5" => Err(String::from("ES5 is not yet supported.")), + "es6" | "es2015" => Ok(Self::ES2015), "es2016" => Ok(Self::ES2016),Using
target: 'es6', cssMinify: 'lightningcss'in vite 7 also produces the same error. And sincecssMinify: 'lightningcss'is the default behavior in vite 8, to reduce migration regressions, I suggest supportinges6as an alias ofes2015for theconvertTargets()method of plugin css.This patch can also be safely backported to vite 7.