diff options
author | Mihai Bazon <mihai.bazon@gmail.com> | 2015-03-14 11:22:28 +0200 |
---|---|---|
committer | Mihai Bazon <mihai.bazon@gmail.com> | 2015-03-14 11:22:28 +0200 |
commit | ea3430102cf87b01b1e1bef275e2a8b8c8a70988 (patch) | |
tree | 0bbae0a90fc485e177b3ca71e3566ed8b04fe5f9 /tools | |
parent | 9de7199b88edb37753a36a9688d34a4be801f41b (diff) | |
download | tracifyjs-ea3430102cf87b01b1e1bef275e2a8b8c8a70988.tar.gz tracifyjs-ea3430102cf87b01b1e1bef275e2a8b8c8a70988.zip |
Add property name mangler
We only touch properties that are present in an object literal, or which are
assigned to. Example:
x = { foo: 1 };
x.bar = 2;
x["baz"] = 3;
x[cond ? "qwe" : "asd"] = 4;
console.log(x.stuff);
The names "foo", "bar", "baz", "qwe" and "asd" will be mangled, and the
resulting mangled names will be used for the same properties throughout the
code. The "stuff" will not be, since it's just referenced but never
assigned to.
This *will* break most of the code out there, but could work on carefully
written code: do not use eval, do not define methods or properties by
walking an array of names, etc. Also, a comprehensive list of exclusions
needs to be passed, to avoid mangling properties that are standard in
JavaScript, DOM, used in external libraries etc.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/node.js | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/node.js b/tools/node.js index 1ae69da8..af540e0c 100644 --- a/tools/node.js +++ b/tools/node.js @@ -33,7 +33,8 @@ var FILES = exports.FILES = [ "../lib/output.js", "../lib/compress.js", "../lib/sourcemap.js", - "../lib/mozilla-ast.js" + "../lib/mozilla-ast.js", + "../lib/propmangle.js" ].map(function(file){ return fs.realpathSync(path.join(path.dirname(__filename), file)); }); |