aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorkzc <kzc@users.noreply.github.com>2017-03-02 02:11:40 -0500
committerAlex Lam S.L <alexlamsl@gmail.com>2017-03-02 15:11:40 +0800
commitee3b39b909c279a0115c7562cab2c9b37fb37c21 (patch)
treeeec94f77b7187dd161d077f3b4478143cf67577f /lib
parent9699ffb1afc8bead9fbc3643c6b90b14169ef02c (diff)
downloadtracifyjs-ee3b39b909c279a0115c7562cab2c9b37fb37c21.tar.gz
tracifyjs-ee3b39b909c279a0115c7562cab2c9b37fb37c21.zip
optimize trivial IIFEs returning constants (#1530)
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js
index ddf2b10d..99235987 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -2690,6 +2690,12 @@ merge(Compressor.prototype, {
}
}
}
+ if (self.args.length == 0
+ && self.expression instanceof AST_Function
+ && self.expression.body[0] instanceof AST_Return
+ && self.expression.body[0].value.is_constant()) {
+ return self.expression.body[0].value;
+ }
if (compressor.option("negate_iife")
&& compressor.parent() instanceof AST_SimpleStatement
&& is_iife_call(self)) {