Skip to content

Comments

feat(minifier): merge assignments in sequence exprs to variable declaration#13270

Merged
graphite-app[bot] merged 1 commit intomainfrom
08-23-feat_minifier_merge_assignments_in_sequence_exprs_to_variable_declaration
Aug 24, 2025
Merged

feat(minifier): merge assignments in sequence exprs to variable declaration#13270
graphite-app[bot] merged 1 commit intomainfrom
08-23-feat_minifier_merge_assignments_in_sequence_exprs_to_variable_declaration

Conversation

@sapphi-red
Copy link
Member

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

Compress var a, b; a = 0, b = 1 into var a = 0, b = 1.

Copy link
Member Author

sapphi-red commented Aug 23, 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.

@github-actions github-actions bot added A-minifier Area - Minifier C-enhancement Category - New feature or request labels Aug 23, 2025
@sapphi-red sapphi-red marked this pull request as ready for review August 23, 2025 09:40
@codspeed-hq
Copy link

codspeed-hq bot commented Aug 23, 2025

CodSpeed Instrumentation Performance Report

Merging #13270 will not alter performance

Comparing 08-23-feat_minifier_merge_assignments_in_sequence_exprs_to_variable_declaration (a08dd5a) with main (07afa70)1

Summary

✅ 34 untouched benchmarks

Footnotes

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

@sapphi-red sapphi-red force-pushed the 08-23-feat_minifier_merge_assignments_in_sequence_exprs_to_variable_declaration branch from 2ada070 to d75eb97 Compare August 24, 2025 05:40
@sapphi-red sapphi-red force-pushed the 08-23-feat_minifier_merge_assignment_to_variable_declaration branch 2 times, most recently from 92300a2 to f288210 Compare August 24, 2025 10:01
@sapphi-red sapphi-red force-pushed the 08-23-feat_minifier_merge_assignments_in_sequence_exprs_to_variable_declaration branch from d75eb97 to 992af91 Compare August 24, 2025 10:01
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Aug 24, 2025
Copy link
Member

Boshen commented Aug 24, 2025

Merge activity

…ration (#13270)

Compress `var a, b; a = 0, b = 1` into `var a = 0, b  = 1`.
@graphite-app graphite-app bot force-pushed the 08-23-feat_minifier_merge_assignment_to_variable_declaration branch from f288210 to a19e84f Compare August 24, 2025 10:48
@graphite-app graphite-app bot force-pushed the 08-23-feat_minifier_merge_assignments_in_sequence_exprs_to_variable_declaration branch from 992af91 to a08dd5a Compare August 24, 2025 10:49
Base automatically changed from 08-23-feat_minifier_merge_assignment_to_variable_declaration to main August 24, 2025 10:54
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Aug 24, 2025
@graphite-app graphite-app bot merged commit a08dd5a into main Aug 24, 2025
25 checks passed
@graphite-app graphite-app bot deleted the 08-23-feat_minifier_merge_assignments_in_sequence_exprs_to_variable_declaration branch August 24, 2025 10:55
graphite-app bot pushed a commit that referenced this pull request Sep 10, 2025
…TDZ error would be introduced (#13635)

```js
let x;
x = (() => x?.a)();
```
should not be transformed to
```js
let x = (() => x?.a)();
```
, as it would introduce a TDZ error.

To fix that, I limited the right hand side of the assignment to be a literal value for let declarations.

The precise check would be to check whether the right hand side includes a reference to the variable declared on the left hand side, but I didn't do that for now as it is complicated. If we implement that, we can improve this condition too.
https://github.com/oxc-project/oxc/blob/5d597f71c06a9c56fe404a712c05b61e2da3697a/crates/oxc_minifier/src/peephole/minimize_statements.rs#L544-L548

fixes #13615
refs #13270
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