{"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/89620f09afcfef6b35e7bb8660132ab5b4d0cd3b/packages/vite/src/node/optimizer/scan.ts#L413-L449","documentation":"Thrown by the dependency scanner when oxc's `transformSync` reports errors while transpiling a non-JS entry (TypeScript/JSX) before glob-import transformation. oxc is the fast JS parser Vite uses; syntax problems surface as an `AggregateError` wrapping each diagnostic. The original parse/transform errors are preserved inside the aggregate.","triggerScenarios":"In `doTransformGlobImport`, when `loader !== 'js'`, the file contents are passed to `transformSync(id, contents, { lang: loader, ... })`. If `result.errors.length > 0` (invalid TS/JSX syntax, unsupported syntax for the configured loader, or a malformed file used as a scan entry), the AggregateError is thrown.","commonSituations":"A scan entry contains invalid TypeScript (e.g. experimental decorator syntax without enabling it), a `.tsx`/`.jsx` file with malformed JSX, a non-JS file accidentally listed as an entry, or a new TS syntax version that the bundled oxc version does not yet understand.","solutions":["Open the file referenced by the scan entry and fix the reported syntax error(s).","If using decorators or other experimental syntax, enable the corresponding option in your tsconfig or oxc jsx options.","Remove the offending file from `optimizeDeps.entries` / `rolldownOptions.input` if it should not be scanned.","Inspect `AggregateError.errors` to see each individual oxc diagnostic for the exact line/column."],"exampleFix":"// before — entry file uses decorators without config\n@Component()\nclass App {}\n// after — enable in tsconfig.json\n// \"experimentalDecorators\": true\n@Component()\nclass App {}","handlingStrategy":"try-catch","validationCode":"import { transformSync } from 'oxc-transform';\n\nfunction checkScannableSyntax(file) {\n  const code = readFileSync(file, 'utf8');\n  const lang = file.endsWith('.tsx') ? 'tsx' : file.endsWith('.ts') ? 'ts' : 'jsx';\n  const res = transformSync(file, code, { lang, tsconfig: false });\n  if (res.errors.length) throw new Error(res.errors[0].message);\n}\n// run over each scan entry before build","typeGuard":null,"tryCatchPattern":"try {\n  await transformGlobImport(code, id);\n} catch (e) {\n  if (e instanceof AggregateError && e.message === 'oxc transform error') {\n    for (const inner of e.errors) console.error(id, inner.message);\n  }\n  throw e;\n}","preventionTips":["Lint/typecheck all scan entries in CI before invoking Vite.","Enable experimental syntax options in tsconfig if you use decorators/JSX.","Keep `.ts`/`.tsx` entries valid modules that oxc can parse."],"tags":["dep-optimizer","oxc","transform","syntax","typescript"],"analyzedSha":"89620f09afcfef6b35e7bb8660132ab5b4d0cd3b","analyzedAt":"2026-08-03T19:28:02.920Z","schemaVersion":2}