Skip to content

Conversation

@sapphi-red
Copy link
Member

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

Compress Object(expr)(args) to (0, expr)(args).

This can be done because

  • the function call throws an error if the callee is not a function.
  • Object(expr) would output a function if and only if expr is a function.

References

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

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

@codspeed-hq
Copy link

codspeed-hq bot commented Aug 14, 2025

CodSpeed Instrumentation Performance Report

Merging #13092 will not alter performance

Comparing 08-15-feat_minifier_compress_object_expr_args_to_0_expr_args_ (dea41dc) with main (56ae824)1

Summary

✅ 34 untouched benchmarks

Footnotes

  1. No successful run was found on main (dea41dc) during the generation of this report, so 56ae824 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 ready for review August 14, 2025 16:04
Copilot AI review requested due to automatic review settings August 14, 2025 16:04
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 adds a JavaScript minification optimization that compresses Object(expr)(args) function calls to the more compact (0, expr)(args) form, reducing bundle size while maintaining equivalent runtime behavior.

Key changes:

  • Implemented try_rewrite_object_callee_indirect_call method to detect and transform Object(expr)(args) patterns
  • Added comprehensive test coverage for the optimization including edge cases
  • Achieved measurable size reductions in real-world bundles (victory.js: ~1.85kB, antd.js: ~20kB)

Reviewed Changes

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

File Description
crates/oxc_minifier/src/peephole/substitute_alternate_syntax.rs Implements the core optimization logic and test cases
tasks/minsize/minsize.snap Shows benchmark results demonstrating bundle size improvements

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

@magic-akari
Copy link
Contributor

I'm wondering where the Object(expr)(args) pattern originates from? Is it typically generated by compilers like Babel, or does it come from another source?

@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Aug 15, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented Aug 15, 2025

Merge activity

graphite-app bot pushed a commit that referenced this pull request Aug 15, 2025
…13092)

Compress `Object(expr)(args)` to `(0, expr)(args)`.

This can be done because
- the function call throws an error if the callee is not a function.
- `Object(expr)` would output a function if and only if `expr` is a function.

---

**References**

- [spec of `Object()`](https://tc39.es/ecma262/2025/multipage/fundamental-objects.html#sec-object-value)
@graphite-app graphite-app bot force-pushed the 08-15-feat_minifier_compress_object_expr_args_to_0_expr_args_ branch from 2b0ecd5 to 31cf14e Compare August 15, 2025 11:24
…13092)

Compress `Object(expr)(args)` to `(0, expr)(args)`.

This can be done because
- the function call throws an error if the callee is not a function.
- `Object(expr)` would output a function if and only if `expr` is a function.

---

**References**

- [spec of `Object()`](https://tc39.es/ecma262/2025/multipage/fundamental-objects.html#sec-object-value)
@graphite-app graphite-app bot force-pushed the 08-15-feat_minifier_compress_object_expr_args_to_0_expr_args_ branch from 31cf14e to dea41dc Compare August 15, 2025 11:26
@graphite-app graphite-app bot merged commit dea41dc into main Aug 15, 2025
25 checks passed
@graphite-app graphite-app bot deleted the 08-15-feat_minifier_compress_object_expr_args_to_0_expr_args_ branch August 15, 2025 11:31
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Aug 15, 2025
@sapphi-red
Copy link
Member Author

@magic-akari My guess is that it was generated by webpack.

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.

3 participants