Skip to content

warn if HMR failed due a circular dependency issue #7893

@yeion7

Description

@yeion7

Clear and concise description of the problem

Vite's HMR fails if in some point of the dependency tree find a circular dependency issue, and then as a fallback triggers a ful l page reload, but the user doesn't get some info to be able to fix the issue

Suggested solution

If the HMR fails due a circular dependency, display a message for users about it

updateModules uses a utils propagateUpdate to traverse the files dependency tree and if find a circular dependency, returns true to triggers a full page reload,

My proposal is, instead of return a boolean, updateModules could return ModuleNode | undefined, if returns a ModuleNode, triggers a page reload, and send a message with the module and the importers

Alternative

No response

Additional context

I have been migrating from create-react-app@5 to vite@2.9.5 and this was annoying, I could't realized why HMR works with some files but not with others, I had to use ndb, and put a debugger here, then edit a file and debug the issue, I realized that I have a lot of circular dependency issues in my project 🙈

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