Set sane defaults when mangle_props=2

This commit is contained in:
Shrey Banga 2016-06-13 15:17:28 -07:00
parent 51ed9b80c9
commit af42bbe976
2 changed files with 24 additions and 12 deletions

View File

@ -136,11 +136,13 @@ The available options are:
--mangle-props Mangle property names (default `0`). Set to
`true` or `1` to mangle all property names. Set
to `2` to only mangle unquoted property names.
Use the `keep_quoted_props` beautifier option to
preserve the quotes around property names and set
the `properties` compressor option to `false` to
prevent rewriting quoted properties with dot
notation.
This also enables the `keep_quoted_props`
beautifier option to preserve the quotes around
property names and disables the `properties`
compressor option to prevent rewriting quoted
properties with dot notation. You can override
these by setting them explicitly on the command
line.
--mangle-regex Only mangle property names matching the regex
--name-cache File to hold mangled names mappings
--pure-funcs List of functions that can be safely removed if

View File

@ -212,12 +212,26 @@ if (ARGS.quotes === true) {
ARGS.quotes = 3;
}
if (ARGS.mangle_props === true) {
ARGS.mangle_props = 1;
}
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
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;
@ -387,10 +401,6 @@ async.eachLimit(files, 1, function (file, cb) {
TOPLEVEL = TOPLEVEL.wrap_enclose(arg_parameter_list);
}
if (ARGS.mangle_props === true) {
ARGS.mangle_props = 1;
}
if (ARGS.mangle_props || ARGS.name_cache) (function(){
var reserved = RESERVED ? RESERVED.props : null;
var cache = readNameCache("props");