From babd45a619d7f3e41bbdb7e4207c0b5a4817de28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Mel=C3=A9n?= Date: Thu, 15 Apr 2021 19:43:24 +0200 Subject: [PATCH] fix(plugin-legacy): move polyfills in plugin post --- packages/plugin-legacy/index.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/plugin-legacy/index.js b/packages/plugin-legacy/index.js index 0ecf2bd67b2ad5..60dee775aaa5d2 100644 --- a/packages/plugin-legacy/index.js +++ b/packages/plugin-legacy/index.js @@ -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() } - } + }) } }) }