Back to all fixes
CuratedTypeScriptVite 8local

build.target: 'es2019' ignored — optional chaining left in output under rolldown-vite

Problem

Setting `build.target: 'es2019'` (or `rolldownOptions.transform.target`) in a Vite config using rolldown-vite has no effect: the output still contains optional-chaining (`?.`) syntax that should have been downleveled for es2019. Classic Vite + Rollup + esbuild correctly strips it for the same config. In `build.lib` multi-format builds (es + cjs), the transform was additionally observed to apply only to the cjs output file, not the es one.

Solution

typescript
Fixed since rolldown-vite v7.1.17 — upgrade and `build.target` is honored for both format outputs. On earlier versions, work around it by driving rolldown's own minify/compress options directly:
```js
build: {
  target: 'es2019',
  rollupOptions: {
    output: {
      minify: {
        codegen: true,
        compress: { target: 'es2019' },
        mangle: true
      }
    }
  }
}
```
If you still see un-downleveled syntax for specific external libraries after upgrading, treat it as a separate issue — the maintainers asked for a fresh reproduction rather than reopening this one.