Skip to content
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

unexpected full reloads for modules that are not referenced #17806

Open
7 tasks done
mmmmmmmgo opened this issue Aug 1, 2024 · 4 comments
Open
7 tasks done

unexpected full reloads for modules that are not referenced #17806

mmmmmmmgo opened this issue Aug 1, 2024 · 4 comments

Comments

@mmmmmmmgo
Copy link

Describe the bug

  1. First, App.tsx import the Foo method of a.ts
  2. Then I removed the Foo method, and now a.ts is not imported by any file
  3. Modify the a.ts file at this time. After saving, vite reload the entire page, HMR does not work.
Area.mp4

Reproduction

https://stackblitz.com/edit/vitejs-vite-d4lgyd?file=src%2Fa.ts,src%2FApp.tsx&terminal=dev

Steps to reproduce

No response

System Info

...

Used Package Manager

pnpm

Logs

No response

Validations

Copy link

stackblitz bot commented Aug 1, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@mmmmmmmgo
Copy link
Author

This may be the key code

if (!node.importers.size) {
return true
}

@hi-ogawa
Copy link
Collaborator

hi-ogawa commented Aug 2, 2024

The behavior might not be entirely ideal, but it doesn't look so bothering either. Can you maybe explain if you have any concrete use cases where this scenario shouldn't full reload?

@bluwy
Copy link
Member

bluwy commented Aug 5, 2024

Yeah this may be hard to fix because the no-importers check is used to assume a module is a root, e.g. if you ssrLoadModule a .js file, that file would be the root so it assumes a full reload.

If we want to fix this, we need an alternate way to track the root, which is similar to #16664 that is the inverse of the problem, where a circular dep causes the root to not be detected and miss a reload.

@bluwy bluwy added the feat: hmr label Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants