vitejs/vite · error · AggregateError
oxc transform error
Error message
oxc transform error
What it means
AggregateError thrown while scanning entries: oxc's synchronous transform (`transformSync`) is applied to a non-JS file (e.g. TS/JSX) before running glob-import rewriting, and the transform emitted one or more errors. scan.ts:431 wraps them with the message 'oxc transform error'. It indicates the source could not be transpiled by oxc during dependency discovery.
Solutions
- Upgrade Vite (which bundles oxc) to pick up newer syntax support.
- Simplify or fix the syntax in the offending entry file; locate it via the AggregateError's inner errors.
- Review `optimizeDeps.rolldownOptions.transform` jsx settings; remove overrides that conflict.
- Exclude the problematic entry from scanning via `optimizeDeps.entries` or by excluding the dep.
- If a dependency ships unsupported syntax, pre-build it or pin a compatible version.
Example fix
// before: optimizeDeps.transform forces jsx preset that breaks the file
export default defineConfig({
optimizeDeps: { rolldownOptions: { transform: { jsx: 'react' } } },
})
// after
export default defineConfig({
optimizeDeps: { rolldownOptions: { transform: { jsx: { runtime: 'automatic' } } } },
}) Defensive patterns
Strategy: try-catch
Validate before calling
import { transformSync } from 'oxc-parser'
import fs from 'node:fs'
function assertOxcTransformable(file: string, lang: 'jsx' | 'tsx' | 'ts') {
const res = transformSync(file, fs.readFileSync(file, 'utf8'), { lang, tsconfig: false })
if (res.errors.length) throw new Error(`${file} fails oxc transform: ${res.errors[0].message}`)
}
// run over TS/JSX entries during a prebuild Try / catch
try {
await server.listen()
} catch (e) {
if (e instanceof AggregateError && e.message === 'oxc transform error') {
const detail = (e.errors ?? []).map((er: any) => er.message).join('; ')
console.error('oxc transform failed during scan:', detail)
}
throw e
} Prevention
- Keep Vite updated to bundle a recent oxc that supports your syntax.
- Avoid experimental TS/JSX syntax the bundled oxc does not support.
- Validate optimizeDeps.rolldownOptions.transform.jsx against supported presets before use.
When it happens
Trigger: In `doTransformGlobImport` (scan.ts:417), when `loader !== 'js'`, `transformSync(id, contents, { jsx: jsxOptions, lang: loader, tsconfig: false })` runs. If `result.errors.length > 0`, the AggregateError is thrown. Occurs for .ts/.tsx/.jsx entries that contain syntax oxc rejects under the configured jsx/lang options.
Common situations: TypeScript/JSX syntax newer than the bundled oxc version supports. Decorators, satisfies operator, or other syntax not enabled. Custom jsx options (`optimizeDeps.rolldownOptions.transform.jsx`) that conflict with the file. Malformed source. Version skew between Vite and the oxc binary.
Related errors
- oxc transform error
- Unable to parse: .
- Could not resolve " " imported by " ". Is it installed?
- Failed to load `transformWithEsbuild`. It is deprecated and…
- failed to resolve rolldownOptions.input value
AI-assisted analysis of vitejs/vite@b4d66fee14 (2026-08-11).
Data as JSON: /api/errors/39ae53d343233a86.
Report an issue: GitHub.
Appendix: source
Thrown at packages/vite/src/node/optimizer/scan.ts:431
id: path,
external: !entries.includes(path),
})
const doTransformGlobImport = async (
contents: string,
id: string,
loader: Loader,
) => {
let transpiledContents: string
// transpile because `transformGlobImport` only expects js
if (loader !== 'js') {
const result = transformSync(id, contents, {
...(jsxOptions !== undefined ? { jsx: jsxOptions } : {}),
lang: loader,
tsconfig: false,
})
if (result.errors.length > 0) {
throw new AggregateError(result.errors, 'oxc transform error')
}
transpiledContents = result.code
} else {
transpiledContents = contents
}
const result = await transformGlobImport(
transpiledContents,
id,
environment.config.root,
resolve,
)
return result?.s.toString() || transpiledContents
}
const scripts: Record<
string,View on GitHub (pinned to b4d66fee14)