-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Description
Describe the bug
When I am writing a plugin and using "addWatchFile" inside the plugin to watch files which are not imported in some JS file, then Vite is tracking that the file has changed, but doesn't reload because of the message "no modules matched"
For example I added some-other-file.yaml with "addWatchFile" and then Vite in debug mode logs this on changes:
vite:hmr [file change] some-other-file.yaml +42m
vite:hmr [no modules matched] some-other-file.yaml +1ms
In the reproduction you have to do npm run dev and then change the file some-other-file.yaml to see this output.
If I do this in rollup, it is doing the reload on file changes. But Vite is somewhere loosing the info of the file path inside the module graph.
This was noticed when developing the rollup-plugin-openapi
Reproduction
https://stackblitz.com/edit/vitejs-vite-wuaaxt?file=vite.config.js
System Info
System:
OS: macOS 12.2.1
CPU: (10) arm64 Apple M1 Pro
Memory: 68.09 MB / 32.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 16.14.0 - ~/Library/Caches/fnm_multishells/14259_1645436772510/bin/node
npm: 8.3.1 - ~/Library/Caches/fnm_multishells/14259_1645436772510/bin/npm
Browsers:
Chrome: 98.0.4758.102
Firefox: 97.0
Firefox Developer Edition: 98.0
Safari: 15.3
npmPackages:
vite: ^2.7.2 => 2.8.4 Used Package Manager
npm
Logs
vite:hmr [file change] some-other-file.yaml +42m
vite:hmr [no modules matched] some-other-file.yaml +1msValidations
- 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 https://github.com/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.