{"record":{"id":"9b6a50f4c6b3edf8","repo":"vitejs/vite","slug":"unsupported-target-e","errorCode":null,"errorMessage":"Unsupported target \"${e}\"","messagePattern":"Unsupported target \"(.+?)\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vite/src/node/plugins/css.ts","lineNumber":3628,"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":3610,"sourceCodeEnd":3646,"githubUrl":"https://github.com/vitejs/vite/blob/b4d66fee14d970f45b8a6f3d7d6aee73ca9b88ab/packages/vite/src/node/plugins/css.ts#L3610-L3646","documentation":"Thrown by `convertTargets` (the bridge from esbuild-style build targets to Lightning CSS targets) when a target like `esXXXX` has a year not in the supported esMap (currently 2015/2016/2017/2018/2019/2020/2021/2022/2023/2024). css.ts:3628 throws with the offending target string. Only happens when Vite uses Lightning CSS for minification/targeting.","triggerScenarios":"`build.target` or `css.lightningcss.targets` includes `es<year>` (matched by `/es(6|\\d{4})/`) where the year is not a key in esMap. E.g. `es2025`, `es2014`, `es2018` is fine but a future/unknown year throws. Reached via the `convertTargets` cache-miss path at line 3628.","commonSituations":"Setting `build.target: 'es2025'` before the bundled Vite supports it. Typo like `es0215`. Copying a target from a newer Vite version into an older one. Lightning CSS enabled (`css.transformer: 'lightningcss'`) with a target Vite's esMap does not yet know.","solutions":["Use a supported ES year: 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, or 2024.","Upgrade Vite to a version whose esMap includes the year you need.","Use `'esnext'` (skipped at line 3633) if you do not need a pinned year.","Switch `css.transformer` off `'lightningcss'` to bypass convertTargets entirely.","Replace `es<year>` with explicit browser targets (chromeXX, firefoxXX, safariXX, edgeXX)."],"exampleFix":"// before\nexport default defineConfig({\n  build: { target: 'es2025' }, // not in esMap yet\n})\n\n// after\nexport default defineConfig({\n  build: { target: 'es2024' },\n})","handlingStrategy":"validation","validationCode":"const SUPPORTED_ES = new Set([2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024])\nfunction assertEsTarget(target: string | string[]) {\n  for (const t of Array.isArray(target) ? target : [target]) {\n    const m = /^es(6|\\d{4})$/.exec(t)\n    if (m) {\n      const year = m[1] === '6' ? 2015 : Number(m[1])\n      if (!SUPPORTED_ES.has(year)) throw new Error(`Unsupported ES target '${t}'; supported years: ${[...SUPPORTED_ES].join(', ')}`)\n    }\n  }\n}","typeGuard":"function isSupportedEsTarget(t: string): boolean {\n  const m = /^es(6|\\d{4})$/.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]).has(year)\n}","tryCatchPattern":"try {\n  await build()\n} catch (e) {\n  if (e instanceof Error && /Unsupported target/.test(e.message)) {\n    console.error('build.target contains an unsupported ES year; use a supported year or esnext.')\n  }\n  throw e\n}","preventionTips":["Pin build.target to a supported ES year from Vite's esMap, or use 'esnext'.","Upgrade Vite when adopting newer ES years (es2025+).","Unit-test config target values against the supported set in CI."],"tags":["css","lightningcss","build-target","config"],"backgroundTag":null,"analyzedSha":"b4d66fee14d970f45b8a6f3d7d6aee73ca9b88ab","analyzedAt":"2026-08-11T11:49:19.515Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}