babel-plugin-minify-mangle-names
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -63,3 +63,3 @@ "use strict"; | ||
this.program.traverse({ | ||
var collectVisitor = { | ||
// capture direct evals | ||
@@ -72,7 +72,8 @@ CallExpression: function CallExpression(path) { | ||
} | ||
}, | ||
} | ||
}; | ||
if (this.charset.shouldConsider) { | ||
// charset considerations | ||
Identifier: function Identifier(path) { | ||
collectVisitor.Identifier = function Identifier(path) { | ||
var node = path.node; | ||
@@ -84,12 +85,13 @@ | ||
} | ||
}, | ||
}; | ||
// charset considerations | ||
Literal: function Literal(_ref3) { | ||
collectVisitor.Literal = function Literal(_ref3) { | ||
var node = _ref3.node; | ||
mangler.charset.consider(String(node.value)); | ||
} | ||
}); | ||
}; | ||
} | ||
this.program.traverse(collectVisitor); | ||
} | ||
@@ -103,4 +105,2 @@ }, { | ||
Scopable: function Scopable(path) { | ||
if (path.isProgram()) return; | ||
var scope = path.scope; | ||
@@ -133,16 +133,37 @@ | ||
Object.keys(scope.getAllBindings()).filter(function (b) { | ||
var binding = scope.getBinding(b); | ||
var bindings = scope.getAllBindings(); | ||
var names = Object.keys(bindings); | ||
return scope.hasOwnBinding(b) && !binding.path.isLabeledStatement() && !mangler.isBlacklist(b, mangler.blacklist) && (mangler.keepFnames ? !isFunction(binding.path) : true); | ||
}).map(function (b) { | ||
for (var _i = 0; _i < names.length; _i++) { | ||
var oldName = names[_i]; | ||
var binding = bindings[oldName]; | ||
if ( | ||
// already renamed bindings | ||
binding.renamed | ||
// globals | ||
|| mangler.program.scope.bindings[oldName] === binding | ||
// other scope bindings | ||
|| !scope.hasOwnBinding(oldName) | ||
// labels | ||
|| binding.path.isLabeledStatement() | ||
// blacklisted | ||
|| mangler.isBlacklist(oldName) | ||
// function names | ||
|| (mangler.keepFnames ? isFunction(binding.path) : false)) { | ||
continue; | ||
} | ||
var next = void 0; | ||
do { | ||
next = getNext(); | ||
} while (!t.isValidIdentifier(next) || scope.hasBinding(next) || scope.hasGlobal(next) || scope.hasReference(next)); | ||
} while (!t.isValidIdentifier(next) || hop.call(bindings, next) || scope.hasGlobal(next) || scope.hasReference(next)); | ||
// TODO: | ||
// re-enable this | ||
// re-enable this - check above | ||
// resetNext(); | ||
mangler.rename(scope, b, next); | ||
}); | ||
mangler.rename(scope, oldName, next); | ||
// mark the binding as renamed | ||
binding.renamed = true; | ||
} | ||
} | ||
@@ -189,4 +210,4 @@ }); | ||
var refs = binding.referencePaths; | ||
for (var _i = 0; _i < refs.length; _i++) { | ||
var path = refs[_i]; | ||
for (var _i2 = 0; _i2 < refs.length; _i2++) { | ||
var path = refs[_i2]; | ||
var node = path.node; | ||
@@ -193,0 +214,0 @@ |
{ | ||
"name": "babel-plugin-minify-mangle-names", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/babel/babili#readme", |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
11872
4
269