Skip to content

Commit 43150e3

Browse files
authored
fix(plugin-legacy): move polyfills in plugin post, fixes #2786 and #2781 (#3023)
1 parent 13d41d8 commit 43150e3

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

packages/plugin-legacy/index.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -533,17 +533,13 @@ function isLegacyOutput(options) {
533533
function recordAndRemovePolyfillBabelPlugin(polyfills) {
534534
return ({ types: t }) => ({
535535
name: 'vite-remove-polyfill-import',
536-
visitor: {
537-
Program: {
538-
exit(path) {
539-
path.get('body').forEach((p) => {
540-
if (t.isImportDeclaration(p)) {
541-
polyfills.add(p.node.source.value)
542-
p.remove()
543-
}
544-
})
536+
post({ path }) {
537+
path.get('body').forEach((p) => {
538+
if (t.isImportDeclaration(p)) {
539+
polyfills.add(p.node.source.value)
540+
p.remove()
545541
}
546-
}
542+
})
547543
}
548544
})
549545
}

0 commit comments

Comments
 (0)