{"record":{"id":"39ae53d343233a86","repo":"vitejs/vite","slug":"oxc-transform-error","errorCode":null,"errorMessage":"oxc transform error","messagePattern":"oxc transform error","errorType":"exception","errorClass":"AggregateError","httpStatus":null,"severity":"error","filePath":"packages/vite/src/node/optimizer/scan.ts","lineNumber":431,"sourceCode":"    id: path,\n    external: !entries.includes(path),\n  })\n\n  const doTransformGlobImport = async (\n    contents: string,\n    id: string,\n    loader: Loader,\n  ) => {\n    let transpiledContents: string\n    // transpile because `transformGlobImport` only expects js\n    if (loader !== 'js') {\n      const result = transformSync(id, contents, {\n        ...(jsxOptions !== undefined ? { jsx: jsxOptions } : {}),\n        lang: loader,\n        tsconfig: false,\n      })\n      if (result.errors.length > 0) {\n        throw new AggregateError(result.errors, 'oxc transform error')\n      }\n      transpiledContents = result.code\n    } else {\n      transpiledContents = contents\n    }\n\n    const result = await transformGlobImport(\n      transpiledContents,\n      id,\n      environment.config.root,\n      resolve,\n    )\n\n    return result?.s.toString() || transpiledContents\n  }\n\n  const scripts: Record<\n    string,","sourceCodeStart":413,"sourceCodeEnd":449,"githubUrl":"https://github.com/vitejs/vite/blob/b4d66fee14d970f45b8a6f3d7d6aee73ca9b88ab/packages/vite/src/node/optimizer/scan.ts#L413-L449","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: optimizeDeps.transform forces jsx preset that breaks the file\nexport default defineConfig({\n  optimizeDeps: { rolldownOptions: { transform: { jsx: 'react' } } },\n})\n\n// after\nexport default defineConfig({\n  optimizeDeps: { rolldownOptions: { transform: { jsx: { runtime: 'automatic' } } } },\n})","handlingStrategy":"try-catch","validationCode":"import { transformSync } from 'oxc-parser'\nimport fs from 'node:fs'\n\nfunction assertOxcTransformable(file: string, lang: 'jsx' | 'tsx' | 'ts') {\n  const res = transformSync(file, fs.readFileSync(file, 'utf8'), { lang, tsconfig: false })\n  if (res.errors.length) throw new Error(`${file} fails oxc transform: ${res.errors[0].message}`)\n}\n// run over TS/JSX entries during a prebuild","typeGuard":null,"tryCatchPattern":"try {\n  await server.listen()\n} catch (e) {\n  if (e instanceof AggregateError && e.message === 'oxc transform error') {\n    const detail = (e.errors ?? []).map((er: any) => er.message).join('; ')\n    console.error('oxc transform failed during scan:', detail)\n  }\n  throw e\n}","preventionTips":["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."],"tags":["optimizer","transform","oxc","jsx","typescript"],"backgroundTag":null,"analyzedSha":"b4d66fee14d970f45b8a6f3d7d6aee73ca9b88ab","analyzedAt":"2026-08-11T11:49:19.515Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}