feat(minifier): remove unused assignments for vars#13231
Merged
graphite-app[bot] merged 1 commit intomainfrom Aug 24, 2025
Merged
feat(minifier): remove unused assignments for vars#13231graphite-app[bot] merged 1 commit intomainfrom
graphite-app[bot] merged 1 commit intomainfrom
Conversation
Member
Author
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements support for removing unused assignments for var declarations in the minifier. Previously, variables declared with var did not have SymbolValue populated, causing them to bail out during unused assignment removal optimization.
- Modified the inline module to populate
SymbolValueforvardeclarations while avoiding constant value inlining - Updated test cases to verify that unused
varassignments are now properly removed - Achieved improved minification results across multiple test files
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| crates/oxc_minifier/src/peephole/inline.rs | Modified init_symbol_value to populate symbol values for var declarations while skipping constant value inlining |
| crates/oxc_minifier/src/peephole/remove_unused_expression.rs | Updated test cases to verify unused var assignment removal works correctly |
| tasks/minsize/minsize.snap | Updated snapshot showing improved minification sizes across test files |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
CodSpeed Instrumentation Performance ReportMerging #13231 will degrade performances by 5.55%Comparing Summary
Benchmarks breakdown
Footnotes |
2141c18 to
dadfdc6
Compare
dadfdc6 to
93236d4
Compare
758139a to
277b91e
Compare
277b91e to
fc93c07
Compare
93236d4 to
19ab2c0
Compare
19ab2c0 to
b9a5d6e
Compare
fc93c07 to
da76589
Compare
This was referenced Aug 24, 2025
Contributor
Merge activity
|
I found that the temporary variable are kept. This change would remove them. Variables that were declared with `var` did not have `SymbolValue` populated and that caused those variables to bail out at this line. https://github.com/oxc-project/oxc/blob/2141c18540803218889aa3c3f1bca5f51cdb5daa/crates/oxc_minifier/src/peephole/remove_unused_expression.rs#L624-L626 I think TDZ needs to be considered when inlining the values, but does not affect removing the unused assignments.
da76589 to
0e804aa
Compare
b9a5d6e to
8ca9909
Compare
Base automatically changed from
08-23-fix_minifier_keep_variables_that_are_modified_by_combined_assignments_made_by_minification
to
main
August 24, 2025 08:49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

I found that the temporary variable are kept. This change would remove them.
Variables that were declared with
vardid not haveSymbolValuepopulated and that caused those variables to bail out at this line.oxc/crates/oxc_minifier/src/peephole/remove_unused_expression.rs
Lines 624 to 626 in 2141c18
I think TDZ needs to be considered when inlining the values, but does not affect removing the unused assignments.