Skip to content

Commit

Permalink
fix(minifier): keep template literals with expressions (#6849)
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Oct 24, 2024
1 parent 076f5c3 commit c658d93
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@ impl<'a, 'b> PeepholeRemoveDeadCode {
Self::try_fold_object_expression(object_expr, ctx)
}
Expression::TemplateLiteral(template_lit) => {
template_lit.expressions.retain(
oxc_ecmascript::side_effects::MayHaveSideEffects::may_have_side_effects,
);
if !template_lit.expressions.is_empty() {
return None;
}

let mut expressions = ctx.ast.move_vec(&mut template_lit.expressions);

Expand Down Expand Up @@ -453,7 +453,7 @@ mod test {

fold("{'hi'}", "");
fold("{x==3}", "x == 3");
fold("{`hello ${foo}`}", "");
fold("{`hello ${foo}`}", "`hello ${foo}`");
fold("{ (function(){x++}) }", "");
fold_same("function f(){return;}");
fold("function f(){return 3;}", "function f(){return 3}");
Expand Down

0 comments on commit c658d93

Please sign in to comment.