aboutsummaryrefslogtreecommitdiff
path: root/bin/uglifyjs
diff options
context:
space:
mode:
authorShrey Banga <shrey@quip.com>2016-05-05 13:44:59 -0700
committerRichard van Velzen <rvanvelzen1@gmail.com>2016-06-19 21:13:31 +0200
commite645ba84cfc950183a222c2cce2ea6b94fe51226 (patch)
tree9ca5d7b1d55c36adb14f0468d4442f2a3a0aeb2d /bin/uglifyjs
parent6c99816855b650c6804a67f4891c339a3e8970f4 (diff)
downloadtracifyjs-e645ba84cfc950183a222c2cce2ea6b94fe51226.tar.gz
tracifyjs-e645ba84cfc950183a222c2cce2ea6b94fe51226.zip
Respect quote style in object literals
The option added in fbbaa42ee55a7f753f7cab9b1a905ccf73cf26d5 wasn't being respected inside object literals, so quoted property names would still be stripped out with this option. This is mostly a corner-case, but useful when the output is passed to something like the Closure compiler, where quoted property names can be used to prevent mangling.
Diffstat (limited to 'bin/uglifyjs')
-rwxr-xr-xbin/uglifyjs24
1 files changed, 18 insertions, 6 deletions
diff --git a/bin/uglifyjs b/bin/uglifyjs
index 45c92b50..b7009426 100755
--- a/bin/uglifyjs
+++ b/bin/uglifyjs
@@ -69,7 +69,7 @@ You need to pass an argument to this option to specify the name that your module
.describe("quotes", "Quote style (0 - auto, 1 - single, 2 - double, 3 - original)")
.describe("reserved-file", "File containing reserved names")
.describe("reserve-domprops", "Make (most?) DOM properties reserved for --mangle-props")
- .describe("mangle-props", "Mangle property names")
+ .describe("mangle-props", "Mangle property names (0 - disabled, 1 - mangle all properties, 2 - mangle unquoted properies)")
.describe("mangle-regex", "Only mangle property names matching the regex")
.describe("name-cache", "File to hold mangled names mappings")
.describe("pure-funcs", "List of functions that can be safely removed if their return value is not used")
@@ -125,7 +125,6 @@ You need to pass an argument to this option to specify the name that your module
.boolean("noerr")
.boolean("bare-returns")
.boolean("keep-fnames")
- .boolean("mangle-props")
.boolean("reserve-domprops")
.wrap(80)
@@ -213,12 +212,24 @@ if (ARGS.quotes === true) {
ARGS.quotes = 3;
}
+if (ARGS.mangle_props === true) {
+ ARGS.mangle_props = 1;
+} else if (ARGS.mangle_props === "unquoted") {
+ ARGS.mangle_props = 2;
+}
+
var OUTPUT_OPTIONS = {
beautify : BEAUTIFY ? true : false,
preamble : ARGS.preamble || null,
quote_style : ARGS.quotes != null ? ARGS.quotes : 0
};
+if (ARGS.mangle_props == 2) {
+ OUTPUT_OPTIONS.keep_quoted_props = true;
+ if (COMPRESS && !("properties" in COMPRESS))
+ COMPRESS.properties = false;
+}
+
if (ARGS.screw_ie8) {
if (COMPRESS) COMPRESS.screw_ie8 = true;
if (MANGLE) MANGLE.screw_ie8 = true;
@@ -401,10 +412,11 @@ async.eachLimit(files, 1, function (file, cb) {
}
TOPLEVEL = UglifyJS.mangle_properties(TOPLEVEL, {
- reserved : reserved,
- cache : cache,
- only_cache : !ARGS.mangle_props,
- regex : regex
+ reserved : reserved,
+ cache : cache,
+ only_cache : !ARGS.mangle_props,
+ regex : regex,
+ ignore_quoted : ARGS.mangle_props == 2
});
writeNameCache("props", cache);
})();