diff options
author | kzc <kzc@users.noreply.github.com> | 2017-03-02 02:11:40 -0500 |
---|---|---|
committer | Alex Lam S.L <alexlamsl@gmail.com> | 2017-03-02 15:11:40 +0800 |
commit | ee3b39b909c279a0115c7562cab2c9b37fb37c21 (patch) | |
tree | eec94f77b7187dd161d077f3b4478143cf67577f /lib | |
parent | 9699ffb1afc8bead9fbc3643c6b90b14169ef02c (diff) | |
download | tracifyjs-ee3b39b909c279a0115c7562cab2c9b37fb37c21.tar.gz tracifyjs-ee3b39b909c279a0115c7562cab2c9b37fb37c21.zip |
optimize trivial IIFEs returning constants (#1530)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 6 |
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)) { |