Skip to content

Commit

Permalink
Remove old Mangle renamer (#109)
Browse files Browse the repository at this point in the history
* Comment out old mangler

+ Remove unused renamer
+ #106

* Remove old renamer

* Remove updateRefs comment
  • Loading branch information
boopathi authored and kangax committed Aug 29, 2016
1 parent e306bf1 commit 0f1e9ab
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 190 deletions.
52 changes: 2 additions & 50 deletions packages/babel-plugin-minify-mangle-names/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const Renamer = require("./renamer");

module.exports = ({ types: t }) => {
const hop = Object.prototype.hasOwnProperty;

Expand Down Expand Up @@ -123,7 +121,7 @@ module.exports = ({ types: t }) => {
// TODO:
// re-enable this
// resetNext();
mangler.renameNew(scope, b, next);
mangler.rename(scope, b, next);
});
}
});
Expand All @@ -134,7 +132,7 @@ module.exports = ({ types: t }) => {
// this.updateReferences();
}

renameNew(scope, oldName, newName) {
rename(scope, oldName, newName) {
const binding = scope.getBinding(oldName);

// rename at the declaration level
Expand Down Expand Up @@ -171,52 +169,6 @@ module.exports = ({ types: t }) => {
node.name = newName;
}
}

// update references
// TODO
}

rename(scope, oldName, newName) {
const binding = scope.getBinding(oldName);
if (!binding) {
throw new Error("Binding not found - " + oldName);
}
new Renamer(binding, oldName, newName).rename();

this.referencesToUpdate.set(oldName, {
scope,
referenced: false
});
}

updateReferences() {
const mangler = this;

this.program.traverse({
Identifier(path) {
const { node } = path;
if (
path.parentPath.isMemberExpression({ property: node }) ||
path.parentPath.isObjectProperty({key: node})
) return;

mangler.referencesToUpdate.forEach((ref, oldName) => {
if (node.name === oldName) {
mangler.referencesToUpdate.get(oldName).referenced = true;
}
});
}
});

this.referencesToUpdate.forEach((ref, oldName) => {
if (ref.referenced) return;

let current = ref.scope;
do {
current.references[oldName] = false;
}
while (current = current.parent);
});
}
}

Expand Down
140 changes: 0 additions & 140 deletions packages/babel-plugin-minify-mangle-names/src/renamer.js

This file was deleted.

0 comments on commit 0f1e9ab

Please sign in to comment.