diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-02-10 15:06:12 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-10 23:06:12 +0800 |
commit | f5659f292b796539a0960887f601b3f08c856bb7 (patch) | |
tree | 14299a0f478900b6aa056d7a5f22394b9e7091a7 | |
parent | c6e287331d8bf547e1d8dc578847224b137e866b (diff) | |
download | tracifyjs-f5659f292b796539a0960887f601b3f08c856bb7.tar.gz tracifyjs-f5659f292b796539a0960887f601b3f08c856bb7.zip |
enhance `collapse_vars` (#4637)
-rw-r--r-- | lib/compress.js | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/compress.js b/lib/compress.js index 94719afa..8b5b020d 100644 --- a/lib/compress.js +++ b/lib/compress.js @@ -2170,6 +2170,8 @@ merge(Compressor.prototype, { } } if (expr.value) extract_candidates(expr.value); + } else if (expr instanceof AST_Yield) { + if (expr.expression) extract_candidates(expr.expression); } hit_stack.pop(); } @@ -2197,6 +2199,7 @@ merge(Compressor.prototype, { if (parent instanceof AST_Switch) return node; if (parent instanceof AST_Unary) return node; if (parent instanceof AST_VarDef) return node; + if (parent instanceof AST_Yield) return node; return null; } @@ -2307,6 +2310,7 @@ merge(Compressor.prototype, { if (parent instanceof AST_Switch) return find_stop_unused(parent, level + 1); if (parent instanceof AST_Unary) return find_stop_unused(parent, level + 1); if (parent instanceof AST_VarDef) return check_assignment(parent.name); + if (parent instanceof AST_Yield) return node; return null; function check_assignment(lhs) { |