From b92a89f32573e5dea946957b307769202099f8de Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Thu, 7 Jul 2022 14:28:33 +0100 Subject: [PATCH] fix corner case in `conditionals` (#5548) --- lib/ast.js | 4 +++- test/compress/imports.js | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/ast.js b/lib/ast.js index 863406bcac3..0c93edb4199 100644 --- a/lib/ast.js +++ b/lib/ast.js @@ -1428,8 +1428,10 @@ var AST_Import = DEFNODE("Import", "all default path properties quote", { }, _equals: function(node) { return this.path == node.path + && prop_equals(this.all, node.all) && prop_equals(this.default, node.default) - && (this.all ? prop_equals(this.all, node.all) : all_equals(this.properties, node.properties)); + && !this.properties == !node.properties + && (!this.properties || all_equals(this.properties, node.properties)); }, walk: function(visitor) { var node = this; diff --git a/test/compress/imports.js b/test/compress/imports.js index c9b59e93d94..72cbbf6910c 100644 --- a/test/compress/imports.js +++ b/test/compress/imports.js @@ -193,6 +193,22 @@ forbid_merge: { } } +merge_tail: { + options = { + conditionals: true, + } + input: { + if (console) + import "foo"; + else + import "foo"; + } + expect: { + console; + import "foo"; + } +} + issue_4708_1: { options = { imports: true,