Skip to content

Commit 4370d91

Browse files
authored
refactor(plugin-legacy): improve default polyfill (#8312)
1 parent 01b5ebf commit 4370d91

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

packages/plugin-legacy/src/index.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,7 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] {
6363
const facadeToLegacyPolyfillMap = new Map()
6464
const facadeToModernPolyfillMap = new Map()
6565
const modernPolyfills = new Set<string>()
66-
// System JS relies on the Promise interface. It needs to be polyfilled for IE 11. (array.iterator is mandatory for supporting Promise.all)
67-
const DEFAULT_LEGACY_POLYFILL = [
68-
'core-js/modules/es.promise',
69-
'core-js/modules/es.array.iterator'
70-
]
71-
const legacyPolyfills = new Set(DEFAULT_LEGACY_POLYFILL)
66+
const legacyPolyfills = new Set<string>()
7267

7368
if (Array.isArray(options.modernPolyfills)) {
7469
options.modernPolyfills.forEach((i) => {
@@ -150,11 +145,13 @@ function viteLegacyPlugin(options: Options = {}): Plugin[] {
150145

151146
// legacy bundle
152147
if (legacyPolyfills.size || genDynamicFallback) {
153-
if (!legacyPolyfills.has('es.promise')) {
154-
// check if the target needs Promise polyfill because SystemJS relies
155-
// on it
156-
await detectPolyfills(`Promise.resolve()`, targets, legacyPolyfills)
157-
}
148+
// check if the target needs Promise polyfill because SystemJS relies on it
149+
// https://github.com/systemjs/systemjs#ie11-support
150+
await detectPolyfills(
151+
`Promise.resolve(); Promise.all();`,
152+
targets,
153+
legacyPolyfills
154+
)
158155

159156
isDebug &&
160157
console.log(

0 commit comments

Comments
 (0)