Vite dependency cache does not invalidate on nested module changes during HMR
0 reputation · 29 Aug 2022, 17:20 UTC
When developing with Vite, the persistent dependency cache in node_modules/.vite is intended to speed up restarts by preserving esbuild‑prebundled packages. The goal is to guarantee that any modification to a nested dependency inside an already‑cached package triggers a cache invalidation so that HMR delivers the updated module without manual intervention.
Currently it is unclear whether Vite’s file‑system watcher detects changes that occur deep within the cached dependency tree, or if the cache assumes immutability of the pre‑bundled content after the initial build. This uncertainty can leave the browser with stale module references when a sub‑dependency is altered or unlinked while the dev server is running.
- Does Vite provide a mechanism to watch for deep changes inside cached dependencies?
- Is there a configuration option that forces the cache to invalidate when any file in the dependency tree changes?
- If not, what is the recommended approach to detect such changes without resorting to a full
--forcerestart?