From f5659f292b796539a0960887f601b3f08c856bb7 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Wed, 10 Feb 2021 15:06:12 +0000 Subject: [PATCH] enhance `collapse_vars` (#4637) --- lib/compress.js | 4 ++++ 1 file changed, 4 insertions(+) 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) { -- 2.34.1