-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Description
- Read the docs.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
Describe the bug
In Vite 1, when a module is updated only that module is re-evaluated in the browser.
In Vite 2, when a module is updated all modules that depend on the updated module are invalidated and have their import path updated, causing the browser to re-evaluate the modules if they're in the dependency tree of the updated module (due to circular dependencies). Marking modules with import.meta.hot.decline() doesn't appear to make any difference.
Specifically the issue is at
vite/packages/vite/src/node/server/hmr.ts
Line 237 in 4396057
| mod.importers.forEach((importer) => invalidate(importer, timestamp, seen)) |
It would be nice if this behaviour was configurable.
Reproduction
https://github.com/nowylie/vite-2-repro
npm ci
npm run vite
- Open the repro page in the browser
- Open the JS console in the dev tools
- Save
src/dep.jsto trigger a HMR update - Note that
main.jsis re-evaluated
System Info
viteversion:2.0.4- Operating System:
macOS 11.2 - Node version:
14.16.0 - Package manager (npm/yarn/pnpm) and version:
npm 6.14.11