Skip to content

Conversation

sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Aug 20, 2025

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.

let Some(symbol_value) = ctx.state.symbol_values.get_symbol_value(symbol_id) else {
return false;
};

I think TDZ needs to be considered when inlining the values, but does not affect removing the unused assignments.

@github-actions github-actions bot added A-minifier Area - Minifier C-enhancement Category - New feature or request labels Aug 20, 2025
Copy link
Member Author

sapphi-red commented Aug 20, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@sapphi-red sapphi-red marked this pull request as ready for review August 20, 2025 12:46
@Copilot Copilot AI review requested due to automatic review settings August 20, 2025 12:46
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 SymbolValue for var declarations while avoiding constant value inlining
  • Updated test cases to verify that unused var assignments 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.

Copy link

codspeed-hq bot commented Aug 20, 2025

CodSpeed Instrumentation Performance Report

Merging #13231 will degrade performances by 5.55%

Comparing 08-20-feat_minifier_collect_symbol_information_for_vars (8ca9909) with main (e7a49ed)1

Summary

❌ 1 regressions
✅ 33 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
minifier[react.development.js] 2.1 ms 2.3 ms -5.55%

Footnotes

  1. No successful run was found on main (0e804aa) during the generation of this report, so e7a49ed was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@sapphi-red sapphi-red marked this pull request as draft August 23, 2025 05:17
@sapphi-red sapphi-red changed the base branch from main to graphite-base/13231 August 23, 2025 08:09
@sapphi-red sapphi-red force-pushed the 08-20-feat_minifier_collect_symbol_information_for_vars branch from 2141c18 to dadfdc6 Compare August 23, 2025 08:09
@sapphi-red sapphi-red changed the base branch from graphite-base/13231 to 08-23-fix_minifier_keep_variables_that_are_modified_by_combined_assignments_made_by_minification August 23, 2025 08:09
@sapphi-red sapphi-red marked this pull request as ready for review August 23, 2025 08:59
@Boshen Boshen self-assigned this Aug 23, 2025
@sapphi-red sapphi-red force-pushed the 08-20-feat_minifier_collect_symbol_information_for_vars branch from dadfdc6 to 93236d4 Compare August 24, 2025 05:37
@sapphi-red sapphi-red force-pushed the 08-23-fix_minifier_keep_variables_that_are_modified_by_combined_assignments_made_by_minification branch from 758139a to 277b91e Compare August 24, 2025 05:37
@sapphi-red sapphi-red force-pushed the 08-23-fix_minifier_keep_variables_that_are_modified_by_combined_assignments_made_by_minification branch from 277b91e to fc93c07 Compare August 24, 2025 06:38
@sapphi-red sapphi-red force-pushed the 08-20-feat_minifier_collect_symbol_information_for_vars branch from 93236d4 to 19ab2c0 Compare August 24, 2025 06:38
@sapphi-red sapphi-red force-pushed the 08-20-feat_minifier_collect_symbol_information_for_vars branch from 19ab2c0 to b9a5d6e Compare August 24, 2025 06:42
@sapphi-red sapphi-red force-pushed the 08-23-fix_minifier_keep_variables_that_are_modified_by_combined_assignments_made_by_minification branch from fc93c07 to da76589 Compare August 24, 2025 06:42
@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Aug 24, 2025
Copy link
Contributor

graphite-app bot commented Aug 24, 2025

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.
@graphite-app graphite-app bot force-pushed the 08-23-fix_minifier_keep_variables_that_are_modified_by_combined_assignments_made_by_minification branch from da76589 to 0e804aa Compare August 24, 2025 08:43
@graphite-app graphite-app bot force-pushed the 08-20-feat_minifier_collect_symbol_information_for_vars branch from b9a5d6e to 8ca9909 Compare August 24, 2025 08:44
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Aug 24, 2025
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
@graphite-app graphite-app bot merged commit 8ca9909 into main Aug 24, 2025
26 checks passed
@graphite-app graphite-app bot deleted the 08-20-feat_minifier_collect_symbol_information_for_vars branch August 24, 2025 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-minifier Area - Minifier C-enhancement Category - New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants