Skip to content

Commit f40efef

Browse files
authored
refactor: delete unused esbuildPlugin (vitejs#23381)
1 parent 33d0e98 commit f40efef

1 file changed

Lines changed: 0 additions & 63 deletions

File tree

packages/vite/src/node/plugins/esbuild.ts

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import type { ViteDevServer } from '../server'
1818
import {
1919
combineSourcemaps,
2020
createDebugger,
21-
createFilter,
2221
ensureWatchedFile,
2322
generateCodeFrame,
2423
} from '../utils'
@@ -31,7 +30,6 @@ const IIFE_BEGIN_RE =
3130
/(?:const|var)\s+\S+\s*=\s*\(?function\([^()]*\)\s*\{\s*"use strict";/
3231

3332
const validExtensionRE = /\.\w+$/
34-
const jsxExtensionsRE = /\.(?:j|t)sx\b/
3533

3634
// the final build should always support dynamic import and import.meta.
3735
// if they need to be polyfilled, plugin-legacy should be used.
@@ -275,67 +273,6 @@ export async function transformWithEsbuild(
275273
}
276274
}
277275

278-
export function esbuildPlugin(config: ResolvedConfig): Plugin {
279-
const options = config.esbuild as ESBuildOptions
280-
const { jsxInject, include, exclude, ...esbuildTransformOptions } = options
281-
282-
const filter = createFilter(include || /\.(m?ts|[jt]sx)$/, exclude || /\.js$/)
283-
284-
// Remove optimization options for dev as we only need to transpile them,
285-
// and for build as the final optimization is in `buildEsbuildPlugin`
286-
const transformOptions: EsbuildTransformOptions = {
287-
target: 'esnext',
288-
...esbuildTransformOptions,
289-
minify: false,
290-
minifyIdentifiers: false,
291-
minifySyntax: false,
292-
minifyWhitespace: false,
293-
treeShaking: false,
294-
// keepNames is not needed when minify is disabled.
295-
// Also transforming multiple times with keepNames enabled breaks
296-
// tree-shaking. (#9164)
297-
keepNames: false,
298-
supported: {
299-
...defaultEsbuildSupported,
300-
...esbuildTransformOptions.supported,
301-
},
302-
}
303-
304-
let server: ViteDevServer | undefined
305-
306-
return {
307-
name: 'vite:esbuild',
308-
configureServer(_server) {
309-
server = _server
310-
},
311-
async transform(code, id) {
312-
if (filter(id) || filter(cleanUrl(id))) {
313-
const result = await transformWithEsbuild(
314-
code,
315-
id,
316-
transformOptions,
317-
undefined,
318-
config,
319-
server?.watcher,
320-
)
321-
if (result.warnings.length) {
322-
result.warnings.forEach((m) => {
323-
this.warn(prettifyMessage(m, code))
324-
})
325-
}
326-
if (jsxInject && jsxExtensionsRE.test(id)) {
327-
result.code = jsxInject + ';' + result.code
328-
}
329-
return {
330-
code: result.code,
331-
map: result.map,
332-
moduleType: 'js',
333-
}
334-
}
335-
},
336-
}
337-
}
338-
339276
const rollupToEsbuildFormatMap: Record<
340277
string,
341278
EsbuildTransformOptions['format'] | undefined

0 commit comments

Comments
 (0)