Skip to content

Commit b940218

Browse files
committed
minify: move unused expr simplification later
1 parent c46d498 commit b940218

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

internal/js_parser/js_parser.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9206,6 +9206,12 @@ func (p *parser) mangleStmts(stmts []js_ast.Stmt, kind stmtsKind) []js_ast.Stmt
92069206
}
92079207

92089208
case *js_ast.SExpr:
9209+
// Trim expressions without side effects
9210+
s.Value = p.astHelpers.SimplifyUnusedExpr(s.Value, p.options.unsupportedJSFeatures)
9211+
if s.Value.Data == nil {
9212+
continue
9213+
}
9214+
92099215
// Merge adjacent expression statements
92109216
if len(result) > 0 {
92119217
prevStmt := result[len(result)-1]
@@ -10769,14 +10775,6 @@ func (p *parser) visitAndAppendStmt(stmts []js_ast.Stmt, stmt js_ast.Stmt) []js_
1076910775
return stmts
1077010776
}
1077110777

10772-
// Trim expressions without side effects
10773-
if p.options.minifySyntax {
10774-
s.Value = p.astHelpers.SimplifyUnusedExpr(s.Value, p.options.unsupportedJSFeatures)
10775-
if s.Value.Data == nil {
10776-
return stmts
10777-
}
10778-
}
10779-
1078010778
case *js_ast.SThrow:
1078110779
s.Value = p.visitExpr(s.Value)
1078210780

0 commit comments

Comments
 (0)