{"id":"e509cdfcb8f91115","repo":"vitejs/vite","slug":"failed-to-load-transformwithesbuild-it-is-depre","errorCode":null,"errorMessage":"Failed to load `transformWithEsbuild`. It is deprecated and it now requires esbuild to be installed separately. If you are a package author, please migrate to `transformWithOxc` instead.","messagePattern":"Failed to load `transformWithEsbuild`\\. It is deprecated and it now requires esbuild to be installed separately\\. If you are a package author, please migrate to `transformWithOxc` instead\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/vite/src/node/plugins/esbuild.ts","lineNumber":224,"sourceCode":"    ...options,\n    loader,\n    tsconfigRaw,\n  }\n\n  // Some projects in the ecosystem are calling this function with an ESBuildOptions\n  // object and esbuild throws an error for extra fields\n  // @ts-expect-error include exists in ESBuildOptions\n  delete resolvedOptions.include\n  // @ts-expect-error exclude exists in ESBuildOptions\n  delete resolvedOptions.exclude\n  // @ts-expect-error jsxInject exists in ESBuildOptions\n  delete resolvedOptions.jsxInject\n\n  let transform: typeof import('esbuild').transform\n  try {\n    transform = (await importEsbuild()).transform\n  } catch (e) {\n    throw new Error(\n      'Failed to load `transformWithEsbuild`. ' +\n        'It is deprecated and it now requires esbuild to be installed separately. ' +\n        'If you are a package author, please migrate to `transformWithOxc` instead.',\n      { cause: e },\n    )\n  }\n\n  if (!ignoreEsbuildWarning) {\n    warnTransformWithEsbuildUsageOnce()\n  }\n\n  try {\n    const result = await transform(code, resolvedOptions)\n    let map: SourceMap\n    if (inMap && resolvedOptions.sourcemap) {\n      const nextMap = JSON.parse(result.map)\n      nextMap.sourcesContent = []\n      map = combineSourcemaps(filename, [","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/vitejs/vite/blob/89620f09afcfef6b35e7bb8660132ab5b4d0cd3b/packages/vite/src/node/plugins/esbuild.ts#L206-L242","documentation":"Thrown by the deprecated `transformWithEsbuild` API when the `esbuild` package cannot be dynamically imported. Vite no longer bundles esbuild, so calling this legacy helper requires the project to install esbuild itself. The message directs package authors to migrate to `transformWithOxc`.","triggerScenarios":"Calling `transformWithEsbuild(code, filename)` (or a plugin that calls it) when `esbuild` is not resolvable — the `importEsbuild()` dynamic import throws and is caught, then re-thrown with this message and `{ cause: e }`.","commonSituations":"A third-party Vite plugin still calling `transformWithEsbuild`; code migrated from an older Vite that bundled esbuild; explicitly using `transformWithEsbuild` in config without installing esbuild.","solutions":["Run `npm i -D esbuild` if you genuinely need the legacy transform.","Migrate the call site from `transformWithEsbuild` to `transformWithOxc` (the message's recommendation).","If a plugin triggers it, update/replace that plugin or open an issue with the author to migrate.","Stop calling the deprecated helper directly — use Vite's built-in TS/JSX pipeline."],"exampleFix":"// before\nimport { transformWithEsbuild } from 'vite';\nconst out = await transformWithEsbuild(code, 'a.ts', { loader: 'ts' });\n// after\nimport { transformWithOxc } from 'vite';\nconst out = await transformWithOxc(code, 'a.ts', { typescript: {} });","handlingStrategy":"validation","validationCode":"import { createRequire } from 'node:module';\nconst require = createRequire(import.meta.url);\n\nfunction ensureEsbuildOrMigrate() {\n  try { require.resolve('esbuild'); }\n  catch { throw new Error('esbuild not installed — install it or migrate to transformWithOxc'); }\n}\n// call only if you intentionally use transformWithEsbuild","typeGuard":null,"tryCatchPattern":"try {\n  await transformWithEsbuild(code, 'a.ts');\n} catch (e) {\n  if (/Failed to load `transformWithEsbuild`/.test(e.message)) {\n    await installMissing('esbuild'); // or switch to transformWithOxc\n  }\n  throw e;\n}","preventionTips":["Migrate off `transformWithEsbuild` to `transformWithOxc`.","If you must keep it, declare `esbuild` as a devDependency.","Audit third-party plugins for deprecated esbuild usage."],"tags":["esbuild","oxc","deprecation","dependency","transform"],"analyzedSha":"89620f09afcfef6b35e7bb8660132ab5b4d0cd3b","analyzedAt":"2026-08-03T19:28:02.920Z","schemaVersion":2}