From 1a23c304de43a0afb6b0aaf226709485c2965ac0 Mon Sep 17 00:00:00 2001 From: David BRETIN Date: Wed, 8 Feb 2017 09:50:06 +0100 Subject: [PATCH 1/3] Add "mangle-prefix" arguments Pass the value || "" to method mangle_properties via option --- bin/uglifyjs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/uglifyjs b/bin/uglifyjs index 8cb2f0df..7ed51b7a 100755 --- a/bin/uglifyjs +++ b/bin/uglifyjs @@ -74,6 +74,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("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-prefix", "Prefix of the mangle properties") .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("dump-spidermonkey-ast", "Dump SpiderMonkey AST to stdout.") @@ -110,6 +111,7 @@ You need to pass an argument to this option to specify the name that your module .string("p") .string("prefix") .string("name-cache") + .string("mangle-prefix") .array("reserved-file") .array("pure-funcs") @@ -421,6 +423,7 @@ async.eachLimit(files, 1, function (file, cb) { only_cache : !ARGS.mangle_props, regex : regex, ignore_quoted : ARGS.mangle_props == 2, + prefix : ARGS.mangle_prefix || "", debug : typeof ARGS.mangle_props_debug === "undefined" ? false : ARGS.mangle_props_debug }); writeNameCache("props", cache); From fddd6ba387e1a130fb181724dc5701b33fa8a70b Mon Sep 17 00:00:00 2001 From: David BRETIN Date: Wed, 8 Feb 2017 09:51:25 +0100 Subject: [PATCH 2/3] Add prefix for mangle name properties --- lib/propmangle.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/propmangle.js b/lib/propmangle.js index 44902bca..105dc813 100644 --- a/lib/propmangle.js +++ b/lib/propmangle.js @@ -78,6 +78,7 @@ function find_builtins() { } function mangle_properties(ast, options) { + console.log(options); options = defaults(options, { reserved : null, cache : null, @@ -227,7 +228,7 @@ function mangle_properties(ast, options) { // (filled with quoted properties when ignore_quoted set). Make sure we add this // check so we don't collide with a quoted name. do { - mangled = base54(++cache.cname); + mangled = options.prefix + base54(++cache.cname); } while (!can_mangle(mangled) || (ignore_quoted && mangled in ignored)); } From 2862b36e478106ca6b9812888a875e310cb6401d Mon Sep 17 00:00:00 2001 From: David BRETIN Date: Wed, 8 Feb 2017 09:59:49 +0100 Subject: [PATCH 3/3] Update propmangle.js --- lib/propmangle.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/propmangle.js b/lib/propmangle.js index 105dc813..28a1cade 100644 --- a/lib/propmangle.js +++ b/lib/propmangle.js @@ -78,7 +78,6 @@ function find_builtins() { } function mangle_properties(ast, options) { - console.log(options); options = defaults(options, { reserved : null, cache : null,