Skip to content

Comments

feat(minifier): compress return void foo() => foo(); return#13271

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

feat(minifier): compress return void foo() => foo(); return#13271
graphite-app[bot] merged 1 commit intomainfrom
08-23-feat_minifier_compress_return_void_foo_foo_return_

Conversation

@sapphi-red
Copy link
Member

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

Compress return void foo() => foo(); return.
return void 0 and return undefined was handled but this wasn't.

@github-actions github-actions bot added A-minifier Area - Minifier C-enhancement Category - New feature or request labels Aug 23, 2025
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.

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

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 a minification optimization that transforms return void foo() to foo(); return when the expression evaluates to undefined. This builds on existing optimizations for return void 0 and return undefined patterns.

  • Adds logic to detect return statements with arguments that evaluate to undefined and have side effects
  • Transforms these statements by extracting the side-effect expression and creating a bare return
  • Updates test expectations to reflect the new optimization behavior

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
crates/oxc_minifier/src/peephole/minimize_statements.rs Implements the core optimization logic for return void foo() transformation
crates/oxc_minifier/src/peephole/substitute_alternate_syntax.rs Updates test case to expect the new optimized output
tasks/minsize/minsize.snap Minor improvement in gzip size measurement for typescript.js

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codspeed-hq
Copy link

codspeed-hq bot commented Aug 23, 2025

CodSpeed Instrumentation Performance Report

Merging #13271 will not alter performance

Comparing 08-23-feat_minifier_compress_return_void_foo_foo_return_ (cae222c) with main (a1b6ad4)1

Summary

✅ 34 untouched benchmarks

Footnotes

  1. No successful run was found on main (cae222c) during the generation of this report, so a1b6ad4 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 15:20
@sapphi-red sapphi-red force-pushed the 08-23-feat_minifier_compress_return_void_foo_foo_return_ branch from a2c517f to d047315 Compare August 23, 2025 15:37
@sapphi-red sapphi-red marked this pull request as ready for review August 23, 2025 15:46
@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

  • Aug 24, 1:09 AM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Aug 24, 1:09 AM UTC: Boshen added this pull request to the Graphite merge queue.
  • Aug 24, 1:17 AM UTC: The Graphite merge queue couldn't merge this PR because it was not satisfying all requirements (Failed CI: 'Test NAPI', 'Conformance').
  • Aug 24, 4:37 AM UTC: Merged by the Graphite merge queue.

graphite-app bot pushed a commit that referenced this pull request Aug 24, 2025
Compress `return void foo()` => `foo(); return`.
`return void 0` and `return undefined` was handled but this wasn't.
@graphite-app graphite-app bot force-pushed the 08-23-feat_minifier_compress_return_void_foo_foo_return_ branch from d047315 to c84d763 Compare August 24, 2025 01:14
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Aug 24, 2025
graphite-app bot pushed a commit that referenced this pull request Aug 24, 2025
Compress `return void foo()` => `foo(); return`.
`return void 0` and `return undefined` was handled but this wasn't.
@graphite-app graphite-app bot force-pushed the 08-23-feat_minifier_compress_return_void_foo_foo_return_ branch from c84d763 to 533a74a Compare August 24, 2025 04:28
Compress `return void foo()` => `foo(); return`.
`return void 0` and `return undefined` was handled but this wasn't.
@graphite-app graphite-app bot force-pushed the 08-23-feat_minifier_compress_return_void_foo_foo_return_ branch from 533a74a to cae222c Compare August 24, 2025 04:31
@graphite-app graphite-app bot merged commit cae222c into main Aug 24, 2025
24 checks passed
@graphite-app graphite-app bot deleted the 08-23-feat_minifier_compress_return_void_foo_foo_return_ branch August 24, 2025 04:37
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