aboutsummaryrefslogtreecommitdiff
path: root/lib/compress.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2017-03-23 06:49:49 +0800
committerGitHub <noreply@github.com>2017-03-23 06:49:49 +0800
commitc0f3feae9f251abbea5ae1198e1a6784dd3261f7 (patch)
tree2ed4fbc646f4b8798e515a6a50003216a080a7a6 /lib/compress.js
parenta00040dd93083548aa065c5ae8942e3c2600cbbe (diff)
downloadtracifyjs-c0f3feae9f251abbea5ae1198e1a6784dd3261f7.tar.gz
tracifyjs-c0f3feae9f251abbea5ae1198e1a6784dd3261f7.zip
introduce compressor.info() (#1633)
report the following only when `options.warnings = "verbose"` - unused elements due to inlining - collpased variables
Diffstat (limited to 'lib/compress.js')
-rw-r--r--lib/compress.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 41612ad7..a8fbb8b3 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -131,6 +131,11 @@ merge(Compressor.prototype, {
}
return node;
},
+ info: function() {
+ if (this.options.warnings == "verbose") {
+ AST_Node.warn.apply(AST_Node, arguments);
+ }
+ },
warn: function(text, props) {
if (this.options.warnings) {
// only emit unique warnings
@@ -664,7 +669,7 @@ merge(Compressor.prototype, {
// Further optimize statement after substitution.
stat.reset_opt_flags(compressor);
- compressor.warn("Collapsing " + (is_constant ? "constant" : "variable") +
+ compressor.info("Collapsing " + (is_constant ? "constant" : "variable") +
" " + var_name + " [{file}:{line},{col}]", node.start);
CHANGED = true;
return value;
@@ -1828,7 +1833,7 @@ merge(Compressor.prototype, {
sym.__unused = true;
if (trim) {
a.pop();
- compressor.warn("Dropping unused function argument {name} [{file}:{line},{col}]", {
+ compressor[sym.unreferenced() ? "warn" : "info"]("Dropping unused function argument {name} [{file}:{line},{col}]", {
name : sym.name,
file : sym.start.file,
line : sym.start.line,
@@ -1843,7 +1848,7 @@ merge(Compressor.prototype, {
}
if (drop_funcs && node instanceof AST_Defun && node !== self) {
if (!(node.name.definition().id in in_use_ids)) {
- compressor.warn("Dropping unused function {name} [{file}:{line},{col}]", {
+ compressor[node.name.unreferenced() ? "warn" : "info"]("Dropping unused function {name} [{file}:{line},{col}]", {
name : node.name.name,
file : node.name.start.file,
line : node.name.start.line,
@@ -1867,7 +1872,7 @@ merge(Compressor.prototype, {
compressor.warn("Side effects in initialization of unused variable {name} [{file}:{line},{col}]", w);
return true;
}
- compressor.warn("Dropping unused variable {name} [{file}:{line},{col}]", w);
+ compressor[def.name.unreferenced() ? "warn" : "info"]("Dropping unused variable {name} [{file}:{line},{col}]", w);
return false;
});
// place uninitialized names at the start