Skip to content

Commit

Permalink
fix(plugin-legacy): move polyfills in plugin post
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Melén authored and TobiasMelen committed May 3, 2021
1 parent 38dd448 commit babd45a
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 babd45a

Please sign in to comment.