Vite · VITE0013
Dispose HMR side effects
Checks that Vite hmr code includes the dispose for side effects needed for predictable behavior.
Run this rule
pnpm vite-doctor . --framework vite --rules vite/hmr/require-dispose-for-side-effects
Why it matters
Vite configuration runs in both dev and build pipelines. Narrow, explicit settings reduce surprises across SSR, workers, and local file access.
Recommended fix
Add dispose for side effects where Vite expects it, close to the code that depends on it.
Useful links
Example
Dispose HMR side effects
Before
const timer = setInterval(sync, 1000)
if (import.meta.hot) {
import.meta.hot.accept()
}
After
const timer = setInterval(sync, 1000)
if (import.meta.hot) {
import.meta.hot.dispose(() => clearInterval(timer))
}