diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2017-11-13 00:59:41 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-13 00:59:41 +0800 |
commit | 2ac5086831f17ae93f1cfec9b7375b8ae19915ca (patch) | |
tree | c913b12c8feedd4315e9cd0042afcd6a12044cd1 /lib | |
parent | c6cfa04d10c648dc1ccdf7ac6369f4162f0a46dc (diff) | |
download | tracifyjs-2ac5086831f17ae93f1cfec9b7375b8ae19915ca.tar.gz tracifyjs-2ac5086831f17ae93f1cfec9b7375b8ae19915ca.zip |
fix `top_retain` on `hoist_props` (#2474)
fixes #2473
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js index 54ac3d75..0635c41d 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -2769,6 +2769,7 @@ merge(Compressor.prototype, { AST_Scope.DEFMETHOD("hoist_properties", function(compressor){ var self = this; if (!compressor.option("hoist_props") || compressor.has_directive("use asm")) return self; + var top_retain = self instanceof AST_Toplevel && compressor.top_retain || return_false; var defs_by_id = Object.create(null); var var_names = Object.create(null); self.enclosed.forEach(function(def) { @@ -2784,6 +2785,7 @@ merge(Compressor.prototype, { && !(def = sym.definition()).escaped && !def.single_use && !def.direct_access + && !top_retain(def) && (value = sym.fixed_value()) === node.value && value instanceof AST_Object) { var defs = new Dictionary(); |