From dbb3dce6eff752924e08ee75364987f9dd9924a9 Mon Sep 17 00:00:00 2001 From: Thiago Arrais Date: Mon, 16 Sep 2019 13:38:52 -0300 Subject: [PATCH] Move namespace check to main injector --- packages/babel-plugin-inject-polyfills/src/index.js | 6 +++++- packages/babel-polyfill-provider-corejs3/src/index.js | 9 --------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/packages/babel-plugin-inject-polyfills/src/index.js b/packages/babel-plugin-inject-polyfills/src/index.js index 3ab900ff..180f61e2 100644 --- a/packages/babel-plugin-inject-polyfills/src/index.js +++ b/packages/babel-plugin-inject-polyfills/src/index.js @@ -201,7 +201,11 @@ export default declare((api, options: Options, dirname: string) => { const key = resolveKey(path.get("property"), path.node.computed); if (!key || key === "prototype") return; - const source = resolveSource(path.get("object")); + const object = path.get("object"); + const binding = object.scope.getBinding(object.node.name); + if (binding && binding.path.isImportNamespaceSpecifier()) return; + + const source = resolveSource(object); return property(source.id, key, source.placement, path); }, diff --git a/packages/babel-polyfill-provider-corejs3/src/index.js b/packages/babel-polyfill-provider-corejs3/src/index.js index 1c54a1bf..34118a0b 100644 --- a/packages/babel-polyfill-provider-corejs3/src/index.js +++ b/packages/babel-polyfill-provider-corejs3/src/index.js @@ -119,15 +119,6 @@ export default (( }, usagePure(meta, utils, path) { - const isNamespaced = path => { - if (!path.node) return false; - const binding = path.scope.getBinding(path.node.name); - if (!binding) return false; - return binding.path.isImportNamespaceSpecifier(); - }; - - if (isNamespaced(path.get("object"))) return false; - if (meta.kind === "in") { if (meta.key === "Symbol.iterator") { path.replaceWith(