@@ -33,6 +33,14 @@ const IIFE_BEGIN_RE =
3333const validExtensionRE = / \. \w + $ /
3434const jsxExtensionsRE = / \. (?: j | t ) s x \b /
3535
36+ // the final build should always support dynamic import and import.meta.
37+ // if they need to be polyfilled, plugin-legacy should be used.
38+ // plugin-legacy detects these two features when checking for modern code.
39+ export const defaultEsbuildSupported = {
40+ 'dynamic-import' : true ,
41+ 'import-meta' : true ,
42+ }
43+
3644let server : ViteDevServer
3745
3846export interface ESBuildOptions extends TransformOptions {
@@ -235,6 +243,10 @@ export function esbuildPlugin(config: ResolvedConfig): Plugin {
235243 // Also transforming multiple times with keepNames enabled breaks
236244 // tree-shaking. (#9164)
237245 keepNames : false ,
246+ supported : {
247+ ...defaultEsbuildSupported ,
248+ ...esbuildTransformOptions . supported ,
249+ } ,
238250 }
239251
240252 return {
@@ -360,12 +372,8 @@ export function resolveEsbuildTranspileOptions(
360372 loader : 'js' ,
361373 target : target || undefined ,
362374 format : rollupToEsbuildFormatMap [ format ] ,
363- // the final build should always support dynamic import and import.meta.
364- // if they need to be polyfilled, plugin-legacy should be used.
365- // plugin-legacy detects these two features when checking for modern code.
366375 supported : {
367- 'dynamic-import' : true ,
368- 'import-meta' : true ,
376+ ...defaultEsbuildSupported ,
369377 ...esbuildOptions . supported ,
370378 } ,
371379 }
0 commit comments