Back to all fixes
CuratedExecution-verifiedTypeScriptVite 8local

Oxc minify reformats template-literal strings, inserting literal newlines instead of removing them

Problem

With Vite 8's Oxc-based minifier active (default `build.minify: true`, or any explicit `rolldownOptions.output.minify` object such as `{ mangle: false, compress: true }`), multi-line template-literal strings (e.g. shader source embedded as a template string) come out with literal `\n` sequences preserved/reformatted in the minified output instead of being compacted, producing bloated string output like `"TEST\nTEST\nTEST\nTEST"` where a different minifier would compact it further. This is Oxc's documented behavior (newlines in strings are intentionally not touched by the minifier for safety), but it is a breaking behavior change from the previous terser-based default.

Solution

typescript
Not planned to change on the Oxc/Vite side - per Oxc's own FAQ, newlines-in-strings are left untouched by design (https://oxc.rs/docs/guide/usage/minifier/faq.html#new-lines-in-strings-are-not-removed). The reporter (danrossi) confirmed the working fix is to switch the minifier back to terser for builds containing large embedded string/shader content:
```ts
build: {
  minify: 'terser'
}
```
and to avoid setting any `rolldownOptions.output.minify`/`compress` options, since providing that object is what activates Oxc's string-untouched compression path; leaving `minify` unset or `false` does not trigger the reformatting.