Skip to content

Commit

Permalink
refactor(minifier): Math.pow(a,b) -> a ** (+b) instead of `(+a) *…
Browse files Browse the repository at this point in the history
…* (+b)` (oxc-project#9154)

It's currently minifying twice through:

`Math.pow(a, b)` -> `(+a) ** (+b)` -> `a ** (+b)`
---------

Co-authored-by: 翠 / green <[email protected]>
  • Loading branch information
Boshen and sapphi-red authored Feb 16, 2025
1 parent 9e3571f commit 814eab6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/oxc_minifier/src/peephole/replace_known_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ impl<'a> PeepholeOptimizations {

Some(ctx.ast.expression_binary(
span,
wrap_with_unary_plus_if_needed(first_arg),
// see [`PeepholeOptimizations::is_binary_operator_that_does_number_conversion`] why it does not require `wrap_with_unary_plus_if_needed` here
ctx.ast.move_expression(first_arg),
BinaryOperator::Exponential,
wrap_with_unary_plus_if_needed(second_arg),
))
Expand Down

0 comments on commit 814eab6

Please sign in to comment.