feat(minifier): mark more known global methods as side-effect free#13086
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. |
There was a problem hiding this comment.
Pull Request Overview
This PR extends the minifier's capability to mark more known global methods as side-effect free, allowing for better optimization. The changes update the side-effect analysis to recognize more pure global functions and static methods as safe to remove when their results are unused.
Key changes:
- Added comprehensive lists of pure global functions and static methods
- Updated test cases to reflect the new optimization behavior
- Refined the side-effect detection logic for call and new expressions
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tasks/minsize/minsize.snap | Updated benchmark results showing improved minification |
| crates/oxc_minifier/tests/peephole/obscure_edge_cases.rs | Modified tests to expect optimization of Math.random(), Date.now(), and Object(null) |
| crates/oxc_minifier/tests/ecmascript/may_have_side_effects.rs | Added comprehensive test coverage for pure global functions and methods |
| crates/oxc_minifier/src/peephole/substitute_alternate_syntax.rs | Updated test to include assignment for RegExp optimization |
| crates/oxc_minifier/src/peephole/replace_known_methods.rs | Updated tests to include assignments for proper test validation |
| crates/oxc_minifier/src/peephole/remove_unused_expression.rs | Updated logic to use side-effect analysis for call expressions |
| crates/oxc_ecmascript/src/side_effects/may_have_side_effects.rs | Core implementation adding pure function detection and extensive method coverage |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
CodSpeed Instrumentation Performance ReportMerging #13086 will degrade performances by 3.36%Comparing Summary
Benchmarks breakdown
|
7841316 to
a1fa518
Compare
|
This doesn't quite close #13067 yet; for example, while this optimizes |
Merge activity
|
e4215cc to
fbe6663
Compare
closes #13067