-
-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Description
Describe the bug
When spinning up the Vite dev server with code that contains an invalid import, an error is shown as expected. However, fixing the code does not cause the page to reload as it should. It needs to be reloaded manually.
This only seems to occur when the invalid import was present when the Vite dev server was first spun up. I suspect that's because Vite 3 doesn't set up the module graph in the same way as Vite 2 did, i.e. a file that contains a bad import isn't added to the module graph, so when that file is updated, Vite 3's dev server doesn't know about it and therefore no reload occurs.
I found out about it when upgrading Preview.js to Vite 3, as I have tests for that specific case. Yes, I'm considering adding it to the ecosystem test suite, but it's too flaky at the moment :)
Reproduction
https://github.com/fwouts/vite-not-refreshing (reproduction steps in README)
System Info
System:
OS: macOS 12.5
CPU: (8) arm64 Apple M1
Memory: 119.88 MB / 8.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.15.0 - ~/.nvm/versions/node/v16.15.0/bin/node
Yarn: 1.22.19 - ~/.yarn/bin/yarn
npm: 8.9.0 - ~/.config/yarn/global/node_modules/.bin/npm
Browsers:
Chrome: 103.0.5060.134
Firefox: 103.0
Safari: 15.6
npmPackages:
vite: ^3.0.0 => 3.0.4
Used Package Manager
pnpm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- 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 vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.