diff --git a/packages/babel-plugin-minify-mangle-names/src/fixup-var-scoping.js b/packages/babel-plugin-minify-mangle-names/src/fixup-var-scoping.js index 61adfdfb9..73ea14b3f 100644 --- a/packages/babel-plugin-minify-mangle-names/src/fixup-var-scoping.js +++ b/packages/babel-plugin-minify-mangle-names/src/fixup-var-scoping.js @@ -7,7 +7,8 @@ module.exports = function(mangler) { if (path.node.kind !== "var") { return; } - const fnScope = path.scope.getFunctionParent(); + const fnScope = + path.scope.getFunctionParent() || path.scope.getProgramParent(); const bindingIds = path.getOuterBindingIdentifierPaths(); for (const name in bindingIds) {