From 01119dc32820d4a75a5552ae96da408e53fa8aad Mon Sep 17 00:00:00 2001 From: Ulrich Stark <8657779+ulrichstark@users.noreply.github.com> Date: Wed, 26 Aug 2026 21:35:53 +0200 Subject: [PATCH] chore: delete unused `esbuildPlugin` --- packages/vite/src/node/plugins/esbuild.ts | 63 ----------------------- 1 file changed, 63 deletions(-) diff --git a/packages/vite/src/node/plugins/esbuild.ts b/packages/vite/src/node/plugins/esbuild.ts index 0c73f20130c202..d6b3dc39215f4e 100644 --- a/packages/vite/src/node/plugins/esbuild.ts +++ b/packages/vite/src/node/plugins/esbuild.ts @@ -18,7 +18,6 @@ import type { ViteDevServer } from '../server' import { combineSourcemaps, createDebugger, - createFilter, ensureWatchedFile, generateCodeFrame, } from '../utils' @@ -31,7 +30,6 @@ const IIFE_BEGIN_RE = /(?:const|var)\s+\S+\s*=\s*\(?function\([^()]*\)\s*\{\s*"use strict";/ const validExtensionRE = /\.\w+$/ -const jsxExtensionsRE = /\.(?:j|t)sx\b/ // the final build should always support dynamic import and import.meta. // if they need to be polyfilled, plugin-legacy should be used. @@ -275,67 +273,6 @@ export async function transformWithEsbuild( } } -export function esbuildPlugin(config: ResolvedConfig): Plugin { - const options = config.esbuild as ESBuildOptions - const { jsxInject, include, exclude, ...esbuildTransformOptions } = options - - const filter = createFilter(include || /\.(m?ts|[jt]sx)$/, exclude || /\.js$/) - - // Remove optimization options for dev as we only need to transpile them, - // and for build as the final optimization is in `buildEsbuildPlugin` - const transformOptions: EsbuildTransformOptions = { - target: 'esnext', - ...esbuildTransformOptions, - minify: false, - minifyIdentifiers: false, - minifySyntax: false, - minifyWhitespace: false, - treeShaking: false, - // keepNames is not needed when minify is disabled. - // Also transforming multiple times with keepNames enabled breaks - // tree-shaking. (#9164) - keepNames: false, - supported: { - ...defaultEsbuildSupported, - ...esbuildTransformOptions.supported, - }, - } - - let server: ViteDevServer | undefined - - return { - name: 'vite:esbuild', - configureServer(_server) { - server = _server - }, - async transform(code, id) { - if (filter(id) || filter(cleanUrl(id))) { - const result = await transformWithEsbuild( - code, - id, - transformOptions, - undefined, - config, - server?.watcher, - ) - if (result.warnings.length) { - result.warnings.forEach((m) => { - this.warn(prettifyMessage(m, code)) - }) - } - if (jsxInject && jsxExtensionsRE.test(id)) { - result.code = jsxInject + ';' + result.code - } - return { - code: result.code, - map: result.map, - moduleType: 'js', - } - } - }, - } -} - const rollupToEsbuildFormatMap: Record< string, EsbuildTransformOptions['format'] | undefined