{"record":{"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/b4d66fee14d970f45b8a6f3d7d6aee73ca9b88ab/packages/vite/src/node/plugins/esbuild.ts#L206-L242","documentation":"transformWithEsbuild is a deprecated escape hatch that now dynamically imports the 'esbuild' package. If that import throws (module not found / resolution failure), Vite rethrows with this message and the original error as cause. Vite itself migrated its default transform pipeline to oxc, so esbuild is no longer a transitive dependency.","triggerScenarios":"Calling transformWithEsbuild(code, id) directly (e.g. a plugin or user config overriding esbuild transform), or having optimizeDeps.esbuildOptions / build target code paths that still route through the esbuild plugin, when 'esbuild' is not installed in node_modules.","commonSituations":"Upgrading to a Vite version that dropped the bundled esbuild, copying an old plugin that calls transformWithEsbuild, or a custom plugin using esbuild for JSX stripping. Package authors hitting this are explicitly told to migrate.","solutions":["Migrate the calling code to transformWithOxc (the current Vite default) — recommended for package authors.","If you must keep esbuild, install it explicitly: `npm install esbuild` (or add to dependencies).","Remove any config that forces the esbuild plugin back into the pipeline (e.g. custom build.target shenanigans) unless esbuild is present.","Audit third-party plugins for transformWithEsbuild usage and update them."],"exampleFix":"// before\nimport { transformWithEsbuild } from 'vite'\nconst res = await transformWithEsbuild(code, id)\n// after\nimport { transformWithOxc } from 'vite'\nconst res = await transformWithOxc(code, id)","handlingStrategy":"validation","validationCode":"// Check esbuild availability before calling\nasync function canUseEsbuild() {\n  try { await import('esbuild'); return true } catch { return false }\n}\nif (!await canUseEsbuild()) throw new Error('Install esbuild or migrate to transformWithOxc')","typeGuard":null,"tryCatchPattern":"try {\n  return await transformWithEsbuild(code, id, options)\n} catch (e) {\n  if (/Failed to load `transformWithEsbuild`/.test(e.message)) {\n    return await transformWithOxc(code, id) // fallback path\n  }\n  throw e\n}","preventionTips":["Migrate plugins to transformWithOxc to avoid the dependency entirely.","Add esbuild to package.json dependencies if you must keep the old API.","Audit plugins after major Vite upgrades for deprecated transform calls."],"tags":["esbuild","oxc","deprecation","dependencies"],"backgroundTag":null,"analyzedSha":"b4d66fee14d970f45b8a6f3d7d6aee73ca9b88ab","analyzedAt":"2026-08-11T11:49:19.515Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}