@@ -123,6 +123,20 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] {
123
123
let config : ResolvedConfig
124
124
let targets : Options [ 'targets' ]
125
125
126
+ // browsers supporting ESM + dynamic import + import.meta + async generator
127
+ const modernTargetsEsbuild = [
128
+ 'es2020' ,
129
+ 'edge79' ,
130
+ 'firefox67' ,
131
+ 'chrome64' ,
132
+ 'safari12' ,
133
+ ]
134
+ // same with above but by browserslist syntax
135
+ // es2020 = chrome 80+, safari 13.1+, firefox 72+, edge 80+
136
+ // https://github.com/evanw/esbuild/issues/121#issuecomment-646956379
137
+ const modernTargetsBabel =
138
+ 'edge>=80, firefox>=72, chrome>=80, safari>=13.1, chromeAndroid>=80, iOS>=13.1'
139
+
126
140
const genLegacy = options . renderLegacyChunks !== false
127
141
const genModern = options . renderModernChunks !== false
128
142
if ( ! genLegacy && ! genModern ) {
@@ -188,14 +202,7 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] {
188
202
// Vite's default target browsers are **not** the same.
189
203
// See https://github.com/vitejs/vite/pull/10052#issuecomment-1242076461
190
204
overriddenBuildTarget = config . build . target !== undefined
191
- // browsers supporting ESM + dynamic import + import.meta + async generator
192
- config . build . target = [
193
- 'es2020' ,
194
- 'edge79' ,
195
- 'firefox67' ,
196
- 'chrome64' ,
197
- 'safari12' ,
198
- ]
205
+ config . build . target = modernTargetsEsbuild
199
206
}
200
207
}
201
208
@@ -375,7 +382,7 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] {
375
382
genModern
376
383
) {
377
384
// analyze and record modern polyfills
378
- await detectPolyfills ( raw , { esmodules : true } , modernPolyfills )
385
+ await detectPolyfills ( raw , modernTargetsBabel , modernPolyfills )
379
386
}
380
387
381
388
const ms = new MagicString ( raw )
0 commit comments