-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
HMR failure, must restart Vite #1477
Comments
@yyx990803 This bug is incredibly impacting. I basically have to restart Vite at every edit I make. There's a minimal repro for you here: https://github.com/jods4/vite-1477 The bug happens when you have circular dependencies amongst your module (something that is fine in native ESM, under some initialization constraints). In the repo, So App.vue -> A -> B -> C -> A. As this is an empty app, you have to look carefully to observe the bug ;) Nothing unusual here: each file has been fetched from network and we can see each module initialized once in the console.
And that's broken. This is not how the app should work. |
BTW I can confirm this is still a problem in latest Vite, tested NOK in beta 31. |
I am opening this FYI. As I don't have the time to find out what is required for a proper repro, I'm going to close it immediately. @yyx990803 if you want to look at a private repository that reproduces this issue get in touch with me on discord (same handle).
Describe the bug
I start Vite on one of my projects.
Everything works fine.
Now touch any
.ts
file with an irrelevant edit. Let's saysequence.ts
.This appears on the terminal and looks quite suspicious given the simple edit:
Application doesn't work anymore, because of a JS bug.
Full app refresh with F5 doesn't work either!
Only solution seems to be a full restart of Vite: now app works again.
My Analysis
The JS failure in browser is related to a static global field exported by one TS module, that seems to be undefined after the edit, always.
Turns out the containing module is imported twice.
First with a timestamp:
state.ts?t=1610318299861
.But then a later file
action.ts
imports the same module as juststate.ts
, no timestamp in querystring.Needless to say for the browser that's 2 different modules, and they don't share variables which leads to all kind of bugs.
Why Vite references 2 different versions of the same file after HMR, I haven't found out.
System Info
vite
version: 2.0.0-beta.19The text was updated successfully, but these errors were encountered: