mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 20:32:10 +00:00
feat(minifier): handle more expressions for side effects (#2062)
Eventually these should return effects rather than a bool since some can be moved around and ignored. For now, keep it similar to previous code.
This commit is contained in:
parent
3faa2aa2a8
commit
18a58d472b
1 changed files with 14 additions and 0 deletions
|
|
@ -113,6 +113,9 @@ impl<'a, 'b> CheckForStateChange<'a, 'b> for Expression<'a> {
|
||||||
| Self::BigintLiteral(_)
|
| Self::BigintLiteral(_)
|
||||||
| Self::NullLiteral(_)
|
| Self::NullLiteral(_)
|
||||||
| Self::RegExpLiteral(_)
|
| Self::RegExpLiteral(_)
|
||||||
|
| Self::MetaProperty(_)
|
||||||
|
| Self::ThisExpression(_)
|
||||||
|
| Self::ClassExpression(_)
|
||||||
| Self::FunctionExpression(_) => false,
|
| Self::FunctionExpression(_) => false,
|
||||||
Self::TemplateLiteral(template) => template
|
Self::TemplateLiteral(template) => template
|
||||||
.expressions
|
.expressions
|
||||||
|
|
@ -122,6 +125,17 @@ impl<'a, 'b> CheckForStateChange<'a, 'b> for Expression<'a> {
|
||||||
Self::UnaryExpression(unary_expr) => {
|
Self::UnaryExpression(unary_expr) => {
|
||||||
unary_expr.check_for_state_change(check_for_new_objects)
|
unary_expr.check_for_state_change(check_for_new_objects)
|
||||||
}
|
}
|
||||||
|
Self::ParenthesizedExpression(p) => {
|
||||||
|
p.expression.check_for_state_change(check_for_new_objects)
|
||||||
|
}
|
||||||
|
Self::ConditionalExpression(p) => {
|
||||||
|
p.test.check_for_state_change(check_for_new_objects)
|
||||||
|
|| p.consequent.check_for_state_change(check_for_new_objects)
|
||||||
|
|| p.alternate.check_for_state_change(check_for_new_objects)
|
||||||
|
}
|
||||||
|
Self::SequenceExpression(s) => {
|
||||||
|
s.expressions.iter().any(|expr| expr.check_for_state_change(check_for_new_objects))
|
||||||
|
}
|
||||||
Self::BinaryExpression(binary_expr) => {
|
Self::BinaryExpression(binary_expr) => {
|
||||||
binary_expr.check_for_state_change(check_for_new_objects)
|
binary_expr.check_for_state_change(check_for_new_objects)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue