Skip to content

HMR should handle cyclic dependencies #10208

@zen0wu

Description

@zen0wu

Description

Previously in #2314, we've decided that HMR will not handle cyclic dependencies and instead reload the entire app, and we think that's the only way that it's correct.

However, I think we should reconsider that decision. Webpack apparently supports reloading app with circular dependencies, I haven't dig into the code, but webpack HMR works with our app with many many circular imports in it. so it's theoretically possible.

Suggested solution

Let's say I have 3 modules, A <-> B -> C,

  • If B is changed, we can clearly see that we only need to reload A + B, but leaving C
  • Theoretically, when a module is changed, it should only go up until all its transitive importers change, and whenever we hit a cycle, we should return instead of bail out the HMR.
  • This logic made me believe this is a simple change, but maybe I missed something obvious.

Alternative

No response

Additional context

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions