Skip to content

fix: Deoptimize the proxied object if its property is reassigned in the handler functions#5713

Merged
lukastaegert merged 4 commits intomasterfrom
fix-5709
Nov 4, 2024
Merged

fix: Deoptimize the proxied object if its property is reassigned in the handler functions#5713
lukastaegert merged 4 commits intomasterfrom
fix-5709

Conversation

@TrickyPi
Copy link
Member

@TrickyPi TrickyPi commented Nov 2, 2024

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:
resolved #5709

Description

For fixing the circular dependency issues, I added src/ast/utils/identifyNode.ts file. I think we need to sort out the dependencies of some of the current ast files later, especially where instanceof is called.

@vercel
Copy link

vercel bot commented Nov 2, 2024

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 Nov 3, 2024 0:28am

@github-actions
Copy link

github-actions bot commented Nov 2, 2024

Thank you for your contribution! ❤️

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

npm install rollup/rollup#fix-5709

Notice: Ensure you have installed the latest stable 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-pjemtcc4n-rollup-js.vercel.app/repl/?pr=5713

@github-actions
Copy link

github-actions bot commented Nov 2, 2024

Performance report

  • BUILD: 8948ms, 729 MB
    • initialize: 0ms, 26.4 MB
    • generate module graph: 3419ms, 554 MB
      • generate ast: 1573ms, 547 MB
    • sort and bind modules: 489ms, 595 MB
    • mark included statements: 5043ms, 729 MB
      • treeshaking pass 1: 1679ms, 695 MB
      • treeshaking pass 2: 807ms, 724 MB
      • treeshaking pass 3: 328ms, 726 MB
      • treeshaking pass 4: 306ms, 722 MB
      • treeshaking pass 5: 353ms, 728 MB
      • treeshaking pass 6: 288ms, 735 MB
      • treeshaking pass 7: 277ms, 728 MB
      • treeshaking pass 8: 267ms, 729 MB
      • treeshaking pass 9: 242ms, 735 MB
      • treeshaking pass 10: 242ms, 734 MB
      • treeshaking pass 11: 241ms, 729 MB
  • GENERATE: 971ms (-49ms, -4.8%), 981 MB
    • initialize render: 0ms, 871 MB
    • generate chunks: 98ms (-47ms, -32.4%), 878 MB
      • optimize chunks: 0ms, 873 MB
    • render chunks: 849ms, 957 MB
    • transform chunks: 19ms, 981 MB
    • generate bundle: 0ms, 981 MB

@codecov
Copy link

codecov bot commented Nov 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.02%. Comparing base (69353a8) to head (cf930ea).
Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5713   +/-   ##
=======================================
  Coverage   99.01%   99.02%           
=======================================
  Files         257      258    +1     
  Lines        8055     8062    +7     
  Branches     1358     1359    +1     
=======================================
+ Hits         7976     7983    +7     
  Misses         52       52           
  Partials       27       27           

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

@TrickyPi TrickyPi changed the title fix: Deoptimize the proxied object if its property is reassigned in the set function fix: Deoptimize the proxied object if its property is reassigned in the handler functions Nov 3, 2024
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.

Nice, and thank you for looking into this so quickly. The solution looks good to me!

For fixing the circular dependency issues, I added src/ast/utils/identifyNode.ts file. I think we need to sort out the dependencies of some of the current ast files later, especially where instanceof is called.

I actually have a permanent fix for this mostly prepared for Rollup 5 on a branch. Basically what I want to do is auto-generated the AST types from the same files that we use to generate the AST converters so that they are perfectly in sync. This will also include the internally used types in the AST classes. This will be based on union types so that then, doing a string comparison for Node.type would actually narrow the TypeScript type. Thus, we can replace all instanceof checks with .type comparisons without the need to define manual type guards any more.

@lukastaegert lukastaegert added this pull request to the merge queue Nov 4, 2024
Merged via the queue into master with commit 0776b4e Nov 4, 2024
@lukastaegert lukastaegert deleted the fix-5709 branch November 4, 2024 06:21
@github-actions
Copy link

github-actions bot commented Nov 4, 2024

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

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.

Rollup treeshakes incorrectly when proxy is used

2 participants