vitejs/vite · error · Error
Unsupported target "${e}"
Error message
Unsupported target "${e}" What it means
Thrown by `convertTargets` (which maps esbuild-style targets to lightningcss targets) when an `es*` target's year is not in Vite's `esMap`. The map covers ES2015 through ES2025; any other ES year (e.g. `es2014`, `es2026`) cannot be converted and is rejected.
Source
Thrown at packages/vite/src/node/plugins/css.ts:3622
const versionRE = /\d/
const convertTargetsCache = new Map<
string | string[],
LightningCSSOptions['targets']
>()
export const convertTargets = (
esbuildTarget: string | string[] | false,
): LightningCSSOptions['targets'] => {
if (!esbuildTarget) return {}
const cached = convertTargetsCache.get(esbuildTarget)
if (cached) return cached
const targets: LightningCSSOptions['targets'] = {}
const entriesWithoutES = arraify(esbuildTarget).flatMap((e) => {
const match = esRE.exec(e)
if (!match) return e
const year = match[1] === '6' ? 2015 : Number(match[1])
if (!esMap[year]) throw new Error(`Unsupported target "${e}"`)
return esMap[year]
})
for (const entry of entriesWithoutES) {
if (entry === 'esnext') continue
const index = entry.search(versionRE)
if (index >= 0) {
const browser = map[entry.slice(0, index)]
if (browser === false) continue // No mapping available
if (browser) {
const [major, minor = 0] = entry
.slice(index)
.split('.')
.map((v) => parseInt(v, 10))
if (!isNaN(major) && !isNaN(minor)) {
const version = (major << 16) | (minor << 8)
if (!targets[browser] || version < targets[browser]!) {
targets[browser] = versionView on GitHub (pinned to 89620f09af)
Solutions
- Use a supported ES year: one of es2015–es2025 (es6 maps to 2015).
- Upgrade Vite — newer ES years are added as lightningcss support lands.
- Switch to explicit browser targets (e.g. `chrome100`) instead of ES versions if you only need broad support.
- Set `build.target`/CSS target to `'esnext'` to skip conversion.
Example fix
// before
export default defineConfig({ build: { target: 'es2014' } });
// after
export default defineConfig({ build: { target: 'es2015' } }); Defensive patterns
Strategy: validation
Validate before calling
const SUPPORTED_ES_YEARS = new Set([2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025]);
function validateEsTarget(target) {
for (const t of [].concat(target)) {
const m = /^es(\d{4}|6)$/.exec(t);
if (m) {
const year = m[1] === '6' ? 2015 : Number(m[1]);
if (!SUPPORTED_ES_YEARS.has(year)) throw new Error(`Unsupported ES target: ${t}`);
}
}
}
// validateEsTarget(config.build.target); Type guard
function isSupportedEsTarget(t) {
const m = /^es(\d{4}|6)$/.exec(t);
if (!m) return false;
const year = m[1] === '6' ? 2015 : Number(m[1]);
return new Set([2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025]).has(year);
} Prevention
- Stick to ES years covered by your Vite version (es2015–es2025).
- Use `'esnext'` if you don't need a specific floor.
- Upgrade Vite before adopting newly-released ES targets.
When it happens
Trigger: Setting `build.target` / `css.lightningcss.targets` to an `esYYYY` string whose year has no entry in `esMap` (line 3622). The regex `esRE` captures the year, and `esMap[year]` is undefined.
Common situations: Using a future ES version not yet supported by the installed Vite (e.g. `es2026` on an older Vite), a typo like `es2014` or `es5`, or copy-pasted browserlist targets that resolve to an unsupported ES year.
Related errors
- Unsupported target "${entry}"
- When "build.cssCodeSplit: false" is set, "rolldownOptions.in
- Failed to load PostCSS config: ${e}
- Unknown lang: ${lang}
- Unsupported dependency type: ${dep.type}
AI-assisted analysis of vitejs/vite@89620f09af (2026-08-03).
Data as JSON: /data/errors/9b6a50f4c6b3edf8.json.
Report an issue: GitHub.