aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorkzc <zaxxon2011@gmail.com>2015-10-07 16:31:57 -0400
committerkzc <zaxxon2011@gmail.com>2015-10-07 16:31:57 -0400
commite870c7db45aca4cb1585d5b10e631ab293e8dc3a (patch)
tree459452c0d71bc33e1765aaa5d762d4afeb56b27e /tools
parent6500f8c52cc75c45a4fac16324d4e531e372874d (diff)
downloadtracifyjs-e870c7db45aca4cb1585d5b10e631ab293e8dc3a.tar.gz
tracifyjs-e870c7db45aca4cb1585d5b10e631ab293e8dc3a.zip
have minify() call figure_out_scope() if needed to produce well formed "use asm" code
Diffstat (limited to 'tools')
-rw-r--r--tools/node.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/node.js b/tools/node.js
index f6048661..7e61d2a1 100644
--- a/tools/node.js
+++ b/tools/node.js
@@ -45,6 +45,7 @@ exports.minify = function(files, options) {
UglifyJS.base54.reset();
// 1. parse
+ var haveScope = false;
var toplevel = null,
sourcesContent = {};
@@ -73,6 +74,7 @@ exports.minify = function(files, options) {
var compress = { warnings: options.warnings };
UglifyJS.merge(compress, options.compress);
toplevel.figure_out_scope();
+ haveScope = true;
var sq = UglifyJS.Compressor(compress);
toplevel = toplevel.transform(sq);
}
@@ -80,11 +82,17 @@ exports.minify = function(files, options) {
// 3. mangle
if (options.mangle) {
toplevel.figure_out_scope(options.mangle);
+ haveScope = true;
toplevel.compute_char_frequency(options.mangle);
toplevel.mangle_names(options.mangle);
}
- // 4. output
+ // 4. scope (if needed)
+ if (!haveScope) {
+ toplevel.figure_out_scope();
+ }
+
+ // 5. output
var inMap = options.inSourceMap;
var output = {};
if (typeof options.inSourceMap == "string") {