Skip to content

Commit

Permalink
Treat DebuggerStmt as EmptyStmt, fixes #370
Browse files Browse the repository at this point in the history
  • Loading branch information
tdewolff committed Jan 29, 2021
1 parent 0df2feb commit dd03d38
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions js/js_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ func TestJS(t *testing.T) {
{`for(var a;;)a();var b=5`, `for(var a,b;;)a();b=5`}, // #346
{`if(e?0:n=1,o=2){o.a}`, `(e?0:n=1,o=2)&&o.a`}, // #347
{`const a=(a,b)=>({...a,b})`, `const a=(a,b)=>({...a,b})`}, // #369
{`if(!a)debugger;`, `!a`}, // #370
}

m := minify.New()
Expand Down
2 changes: 2 additions & 0 deletions js/stmtlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ func (m *jsMinifier) optimizeStmt(i js.IStmt) js.IStmt {
return &js.EmptyStmt{}
}
return blockStmt
} else if _, ok := i.(*js.DebuggerStmt); ok {
return &js.EmptyStmt{}
}
return i
}
Expand Down
2 changes: 2 additions & 0 deletions js/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ func (m *jsMinifier) isEmptyStmt(stmt js.IStmt) bool {
return true
} else if _, ok := stmt.(*js.EmptyStmt); ok {
return true
} else if _, ok := stmt.(*js.DebuggerStmt); ok {
return true
} else if decl, ok := stmt.(*js.VarDecl); ok && m.varsHoisted != nil && decl != m.varsHoisted {
for _, item := range decl.List {
if item.Default != nil {
Expand Down

0 comments on commit dd03d38

Please sign in to comment.