Skip to content

Correct the logic of include in BinaryExpression and don't optimize external references away #6041

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 29, 2025

Conversation

TrickyPi
Copy link
Member

@TrickyPi TrickyPi commented Jul 29, 2025

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

List any relevant issue numbers:
resolves #6040

Description

There was an issue with the previous BinaryExpression include logic: if included was set to true before calling super.include(), the include() logic for left and right would not be executed.

Include changes from #6042.

Copy link

vercel bot commented Jul 29, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
rollup ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 29, 2025 7:08pm

Copy link

github-actions bot commented Jul 29, 2025

Thank you for your contribution! ❤️

You can try out this pull request locally by installing Rollup via

npm install rollup/rollup#fix/6040

Notice: Ensure you have installed the latest nightly Rust toolchain. If you haven't installed it yet, please see https://www.rust-lang.org/tools/install to learn how to download Rustup and install Rust.

or load it into the REPL:
https://rollup-akycuo890-rollup-js.vercel.app/repl/?pr=6041

Copy link

github-actions bot commented Jul 29, 2025

Performance report

  • BUILD: 6913ms, 831 MB
    • initialize: 0ms, 24.6 MB
    • generate module graph: 2577ms, 632 MB
      • generate ast: 1354ms, 622 MB
    • sort and bind modules: 398ms, 693 MB
    • mark included statements: 3936ms, 831 MB
      • treeshaking pass 1: 2321ms, 827 MB
      • treeshaking pass 2: 456ms, 837 MB (+5%)
      • treeshaking pass 3: 394ms, 833 MB
      • treeshaking pass 4: 381ms, 805 MB
      • treeshaking pass 5: 375ms, 831 MB
  • GENERATE: 806ms, 920 MB (-3%)
    • initialize render: 0ms, 876 MB (+3%)
    • generate chunks: 229ms (+179ms, +360.2%), 830 MB (-3%)
      • optimize chunks: 0ms, 859 MB
    • render chunks: 634ms, 903 MB
    • transform chunks: 20ms, 920 MB (-3%)
    • generate bundle: 0ms, 920 MB (-3%)

Copy link

codecov bot commented Jul 29, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.79%. Comparing base (244dc20) to head (3353959).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6041      +/-   ##
==========================================
+ Coverage   98.77%   98.79%   +0.01%     
==========================================
  Files         271      271              
  Lines       10597    10601       +4     
  Branches     2828     2830       +2     
==========================================
+ Hits        10467    10473       +6     
+ Misses         89       88       -1     
+ Partials       41       40       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@TrickyPi TrickyPi changed the title correct the logic of include in BinaryExpression Correct the logic of include in BinaryExpression and don't optimize external references away Jul 29, 2025
Copy link
Member

@lukastaegert lukastaegert left a comment

Choose a reason for hiding this comment

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

I think the problem was that the includeNode logic was no longer called if this.included was set to true first. I changed it so that it works like in other nodes—the first line is

if (!this.include) this.includeNode(context)

Then all test cases are green as they should be. In general, the purpose of an includeNode method is to deoptimize paths of its children once on the first include, which is what is happening here.

Thanks for your work and the quick fix again, I do not know what I would do without you at the moment ❤️

@lukastaegert lukastaegert enabled auto-merge July 29, 2025 19:12
@lukastaegert lukastaegert added this pull request to the merge queue Jul 29, 2025
Merged via the queue into master with commit 603e046 Jul 29, 2025
42 checks passed
@lukastaegert lukastaegert deleted the fix/6040 branch July 29, 2025 19:26
Copy link

This PR has been released as part of rollup@4.46.2. You can test it via npm install rollup.

@TrickyPi
Copy link
Member Author

I think the problem was that the includeNode logic was no longer called if this.included was set to true first. I changed it so that it works like in other nodes—the first line is

Ah, you're right!

Thanks for your work and the quick fix again, I do not know what I would do without you at the moment ❤️

Glad I could help — that’s what teammates are for! 🥳

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4.46 breaks styled-components with new in optimization
3 participants