Skip to content

Commit

Permalink
fix corner case in conditionals (#5548)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlamsl committed Jul 7, 2022
1 parent 902292f commit b92a89f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 16 additions & 0 deletions test/compress/imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b92a89f

Please sign in to comment.