Skip to content

Commit

Permalink
fix(plugin-legacy): move polyfills in plugin post, fixes #2786 and #2781
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasMelen authored May 10, 2021
1 parent 13d41d8 commit 43150e3
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions packages/plugin-legacy/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,17 +533,13 @@ function isLegacyOutput(options) {
function recordAndRemovePolyfillBabelPlugin(polyfills) {
return ({ types: t }) => ({
name: 'vite-remove-polyfill-import',
visitor: {
Program: {
exit(path) {
path.get('body').forEach((p) => {
if (t.isImportDeclaration(p)) {
polyfills.add(p.node.source.value)
p.remove()
}
})
post({ path }) {
path.get('body').forEach((p) => {
if (t.isImportDeclaration(p)) {
polyfills.add(p.node.source.value)
p.remove()
}
}
})
}
})
}
Expand Down

0 comments on commit 43150e3

Please sign in to comment.