diff options
author | Mihai Bazon <mihai@bazon.net> | 2013-12-10 19:44:41 +0200 |
---|---|---|
committer | Mihai Bazon <mihai@bazon.net> | 2013-12-10 19:44:41 +0200 |
commit | dc5f70eab5cf89f1046482e97267030b3bbf2b66 (patch) | |
tree | 8792530da0b3947c8739b9b387a2fae2de519642 /lib/compress.js | |
parent | df8c5623af1afff5fffc6af49ceda5da16f95d54 (diff) | |
download | tracifyjs-dc5f70eab5cf89f1046482e97267030b3bbf2b66.tar.gz tracifyjs-dc5f70eab5cf89f1046482e97267030b3bbf2b66.zip |
Add `drop_console` option to the compressor
Diffstat (limited to 'lib/compress.js')
-rw-r--r-- | lib/compress.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js index 4c52f4dd..2a8b4c2e 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -70,6 +70,7 @@ function Compressor(options, false_by_default) { pure_funcs : null, negate_iife : !false_by_default, screw_ie8 : false, + drop_console : false, warnings : true, global_defs : {} @@ -1773,6 +1774,14 @@ merge(Compressor.prototype, { return make_node(AST_Undefined, self).transform(compressor); } } + if (compressor.option("drop_console")) { + if (self.expression instanceof AST_PropAccess && + self.expression.expression instanceof AST_SymbolRef && + self.expression.expression.name == "console" && + self.expression.expression.undeclared()) { + return make_node(AST_Undefined, self).transform(compressor); + } + } return self.evaluate(compressor)[0]; }); |