This commit is contained in:
David BRETIN 2017-04-11 01:11:30 +00:00 committed by GitHub
commit c55f1863a8
2 changed files with 4 additions and 1 deletions

View File

@ -73,6 +73,7 @@ You need to pass an argument to this option to specify the name that your module
.describe("reserve-domprops", "Make (most?) DOM properties reserved for --mangle-props") .describe("reserve-domprops", "Make (most?) DOM properties reserved for --mangle-props")
.describe("mangle-props", "Mangle property names (0 - disabled, 1 - mangle all properties, 2 - mangle unquoted properies)") .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("mangle-regex", "Only mangle property names matching the regex")
.describe("mangle-prefix", "Prefix of the mangle properties")
.describe("name-cache", "File to hold mangled names mappings") .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") .describe("pure-funcs", "List of functions that can be safely removed if their return value is not used")
.describe("dump-spidermonkey-ast", "Dump SpiderMonkey AST to stdout.") .describe("dump-spidermonkey-ast", "Dump SpiderMonkey AST to stdout.")
@ -109,6 +110,7 @@ You need to pass an argument to this option to specify the name that your module
.string("p") .string("p")
.string("prefix") .string("prefix")
.string("name-cache") .string("name-cache")
.string("mangle-prefix")
.array("reserved-file") .array("reserved-file")
.array("pure-funcs") .array("pure-funcs")
@ -452,6 +454,7 @@ function done() {
only_cache : !ARGS.mangle_props, only_cache : !ARGS.mangle_props,
regex : regex, regex : regex,
ignore_quoted : ARGS.mangle_props == 2, ignore_quoted : ARGS.mangle_props == 2,
prefix : ARGS.mangle_prefix || "",
debug : typeof ARGS.mangle_props_debug === "undefined" ? false : ARGS.mangle_props_debug debug : typeof ARGS.mangle_props_debug === "undefined" ? false : ARGS.mangle_props_debug
}); });
writeNameCache("props", cache); writeNameCache("props", cache);

View File

@ -235,7 +235,7 @@ function mangle_properties(ast, options) {
// (filled with quoted properties when ignore_quoted set). Make sure we add this // (filled with quoted properties when ignore_quoted set). Make sure we add this
// check so we don't collide with a quoted name. // check so we don't collide with a quoted name.
do { do {
mangled = base54(++cache.cname); mangled = options.prefix + base54(++cache.cname);
} while (!can_mangle(mangled) || (ignore_quoted && mangled in ignored)); } while (!can_mangle(mangled) || (ignore_quoted && mangled in ignored));
} }