babel-plugin-minify-mangle-names
Advanced tools
Comparing version 0.5.0-alpha.b4285271 to 0.5.0-alpha.b5637c57
@@ -137,3 +137,7 @@ "use strict"; | ||
Object.keys(scope.bindings).forEach(name => { | ||
scopeTracker.addBinding(scope.bindings[name]); | ||
scopeTracker.addBinding(scope.bindings[name]); // add all constant violations as references | ||
scope.bindings[name].constantViolations.forEach(() => { | ||
scopeTracker.addReference(scope, scope.bindings[name], name); | ||
}); | ||
}); | ||
@@ -143,2 +147,23 @@ }, | ||
/** | ||
* This is required because after function name transformation | ||
* plugin (part of es2015), the function name is NOT added to the | ||
* scope's bindings. So to fix this issue, we simply add a hack to | ||
* handle that case - fix it to the scope tree. | ||
* | ||
* Related: | ||
* - https://github.com/babel/minify/issues/829 | ||
*/ | ||
BindingIdentifier(path) { | ||
if ( // the parent has this id as the name | ||
(path.parentPath.isFunctionExpression({ | ||
id: path.node | ||
}) || path.parentPath.isClassExpression({ | ||
id: path.node | ||
})) && // and the id isn't yet added to the scope | ||
!hop.call(path.parentPath.scope.bindings, path.node.name)) { | ||
path.parentPath.scope.registerBinding("local", path.parentPath); | ||
} | ||
}, | ||
/** | ||
* This is necessary because, in Babel, the scope.references | ||
@@ -145,0 +170,0 @@ * does NOT contain the references in that scope. Only the program |
{ | ||
"name": "babel-plugin-minify-mangle-names", | ||
"version": "0.5.0-alpha.b4285271", | ||
"version": "0.5.0-alpha.b5637c57", | ||
"description": "", | ||
@@ -15,4 +15,4 @@ "keywords": [ | ||
"dependencies": { | ||
"babel-helper-mark-eval-scopes": "^0.5.0-alpha.b4285271" | ||
"babel-helper-mark-eval-scopes": "^0.5.0-alpha.b5637c57" | ||
} | ||
} |
@@ -34,3 +34,3 @@ # babel-plugin-minify-mangle-names | ||
```sh | ||
npm install babel-plugin-minify-mangle-names | ||
npm install babel-plugin-minify-mangle-names --save-dev | ||
``` | ||
@@ -37,0 +37,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33263
884