{"id":"9b6a50f4c6b3edf8","repo":"vitejs/vite","slug":"unsupported-target-e","errorCode":null,"errorMessage":"Unsupported target \"${e}\"","messagePattern":"Unsupported target \"(.+?)\"","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vite/src/node/plugins/css.ts","lineNumber":3622,"sourceCode":"const versionRE = /\\d/\n\nconst convertTargetsCache = new Map<\n  string | string[],\n  LightningCSSOptions['targets']\n>()\nexport const convertTargets = (\n  esbuildTarget: string | string[] | false,\n): LightningCSSOptions['targets'] => {\n  if (!esbuildTarget) return {}\n  const cached = convertTargetsCache.get(esbuildTarget)\n  if (cached) return cached\n  const targets: LightningCSSOptions['targets'] = {}\n\n  const entriesWithoutES = arraify(esbuildTarget).flatMap((e) => {\n    const match = esRE.exec(e)\n    if (!match) return e\n    const year = match[1] === '6' ? 2015 : Number(match[1])\n    if (!esMap[year]) throw new Error(`Unsupported target \"${e}\"`)\n    return esMap[year]\n  })\n\n  for (const entry of entriesWithoutES) {\n    if (entry === 'esnext') continue\n    const index = entry.search(versionRE)\n    if (index >= 0) {\n      const browser = map[entry.slice(0, index)]\n      if (browser === false) continue // No mapping available\n      if (browser) {\n        const [major, minor = 0] = entry\n          .slice(index)\n          .split('.')\n          .map((v) => parseInt(v, 10))\n        if (!isNaN(major) && !isNaN(minor)) {\n          const version = (major << 16) | (minor << 8)\n          if (!targets[browser] || version < targets[browser]!) {\n            targets[browser] = version","sourceCodeStart":3604,"sourceCodeEnd":3640,"githubUrl":"https://github.com/vitejs/vite/blob/89620f09afcfef6b35e7bb8660132ab5b4d0cd3b/packages/vite/src/node/plugins/css.ts#L3604-L3640","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nexport default defineConfig({ build: { target: 'es2014' } });\n// after\nexport default defineConfig({ build: { target: 'es2015' } });","handlingStrategy":"validation","validationCode":"const SUPPORTED_ES_YEARS = new Set([2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025]);\n\nfunction validateEsTarget(target) {\n  for (const t of [].concat(target)) {\n    const m = /^es(\\d{4}|6)$/.exec(t);\n    if (m) {\n      const year = m[1] === '6' ? 2015 : Number(m[1]);\n      if (!SUPPORTED_ES_YEARS.has(year)) throw new Error(`Unsupported ES target: ${t}`);\n    }\n  }\n}\n// validateEsTarget(config.build.target);","typeGuard":"function isSupportedEsTarget(t) {\n  const m = /^es(\\d{4}|6)$/.exec(t);\n  if (!m) return false;\n  const year = m[1] === '6' ? 2015 : Number(m[1]);\n  return new Set([2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025]).has(year);\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["css","lightningcss","build-target","config"],"analyzedSha":"89620f09afcfef6b35e7bb8660132ab5b4d0cd3b","analyzedAt":"2026-08-03T19:28:02.920Z","schemaVersion":2}