diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-06-29 12:48:34 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-29 12:48:34 +0800 |
commit | bdeadffbf582b393dbc14a45b3e69ddf16f47690 (patch) | |
tree | 44575bdd928b43ddcdc630f2cd898786dbbd3172 /bin | |
parent | 5e6f26445f932a180890be4792dab574e07cbb0f (diff) | |
download | tracifyjs-bdeadffbf582b393dbc14a45b3e69ddf16f47690.tar.gz tracifyjs-bdeadffbf582b393dbc14a45b3e69ddf16f47690.zip |
improve usability of name cache under `minify()` (#2176)
fixes #2174
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/uglifyjs | 27 |
1 files changed, 2 insertions, 25 deletions
diff --git a/bin/uglifyjs b/bin/uglifyjs index f4feb39a..68d67c2f 100755 --- a/bin/uglifyjs +++ b/bin/uglifyjs @@ -106,17 +106,8 @@ if (program.mangleProps) { if (typeof options.mangle != "object") options.mangle = {}; options.mangle.properties = program.mangleProps; } -var cache; if (program.nameCache) { - cache = JSON.parse(read_file(program.nameCache, "{}")); - if (options.mangle) { - if (typeof options.mangle != "object") options.mangle = {}; - options.mangle.cache = to_cache("vars"); - if (options.mangle.properties) { - if (typeof options.mangle.properties != "object") options.mangle.properties = {}; - options.mangle.properties.cache = to_cache("props"); - } - } + options.nameCache = JSON.parse(read_file(program.nameCache, "{}")); } if (program.output == "ast") { options.output = { @@ -266,9 +257,7 @@ function run() { print(result.code); } if (program.nameCache) { - fs.writeFileSync(program.nameCache, JSON.stringify(cache, function(key, value) { - return value instanceof UglifyJS.Dictionary ? value.toObject() : value; - })); + fs.writeFileSync(program.nameCache, JSON.stringify(options.nameCache)); } if (result.timings) for (var phase in result.timings) { print_error("- " + phase + ": " + result.timings[phase].toFixed(3) + "s"); @@ -381,18 +370,6 @@ function parse_source_map() { } } -function to_cache(key) { - if (cache[key]) { - cache[key].props = UglifyJS.Dictionary.fromObject(cache[key].props); - } else { - cache[key] = { - cname: -1, - props: new UglifyJS.Dictionary() - }; - } - return cache[key]; -} - function skip_key(key) { return skip_keys.indexOf(key) >= 0; } |