javascript - UglifyJS Don't Mangle Specific Associative Array -


all our webservices passed our xhr via associative array. ie:

new xhr({"year": 2015, "week": 6}, ...); 

all our scripts added single file, , uglified via (essentially mangle , compress except our entry point):

uglifyjs --mangle toplevel --screw-ie8 --compress --mangle-regex="/(?s)^((?!$$).)*$/" --reserve-domprops --reserved-file reserved -- input 

the problem is, year , week field keep getting obfuscated. tried putting $$ infront, have $$year , $$week. work, added regex argument uglifyjs command above. trying negate lookup, mangle properties except $$ @ start (can set of characters, using $$ starting point).

my questions:

  1. is best way it? there way in uglifyjs ignore associative arrays?
  2. is regex right? i've tried escaping 2 dollar signs, i've tried __ instead of $$ several other attempts (note: regex not good)
  3. if regex wrong, there somewhere detail method creating valid regex?

edit: resolved. needed use this:

uglifyjs --mangle toplevel --screw-ie8 --mangle-props --mangle-regex="/^((?!\$\$).)*$/" --reserve-domprops --reserved-file reserved -- input > output 

i ran uglifyjs v2.4.10 these arguments:

uglifyjs src.js --mangle toplevel --screw-ie8 --compress --reserve-domprops --mangle-regex="/(?s)^((?!$$).)*$/" 

and converted this:

(function(lib){     var xhr = new xhr({"year": 2015, "week": 6});     xhr.run(); })(library); 

to this:

!function(r){var e=new xhr({year:2015,week:6});e.run()}(library); 

i unable other options work properly.

which version using?


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -