-
-
Notifications
You must be signed in to change notification settings - Fork 179
Description
Related plugins
Describe the bug
If a plugin watches an imported Vue file for changes via addWatchFile()
HMR may not trigger template updates for that file depending on the file structure and where things are.
A setup like this could happen for a monorepo structure similar to this:
Shared UI library:
packages/ui/src/index.js
packages/ui/src/example.vue
Vite Project:
apps/web/vite.config.js
apps/web/src/app.vue
apps/web/src/style.css
Interestingly HMR for the <style>
blocks does function even when template updates do not.
I'm not sure if this is a bug with this plugin or with Vite. Because of some of the setup required I was thinking Vite but because <style>
blocks do work I figured I'd open it here.
I'll note that, as far as I can tell, this bug only affects Windows. I know that macOS is unaffected. I haven't tested on Linux though but I assume it's probably fine there as well.
Reproduction
https://github.com/thecrypticace/vite-windows-hmr-bug
Steps to reproduce
- Be on Windows
- Setup a project where a Vite project is in a subdir
- Add vue files to a directory outside of that subdir
- Create a file that re-exports those Vue files' default export (barrel file basically)
- Add a plugin that calls addWatchFile on those Vue file paths for some other file
- Use those components in an app.vue or something simiar
- Try updating them, you'll see HMR does not trigger
System Info
System:
OS: Windows 11 10.0.22631
CPU: (4) arm64 Apple Silicon
Memory: 1.79 GB / 7.99 GB
Binaries:
Node: 24.7.0 - C:\Program Files\nodejs\node.EXE
npm: 11.5.1 - C:\Program Files\nodejs\npm.CMD
pnpm: 10.15.1 - ~\AppData\Local\pnpm\pnpm.EXE
Browsers:
Edge: Chromium (139.0.3405.125)
Internet Explorer: 11.0.22621.3527
(I reproduced this in a VM but not just VMs are affected)
Used Package Manager
npm
Logs
I ran into this when triaging a bug for @tailwindcss/vite
with a project that uses a monorepo.
If you want to see that reproduction (though it's much larger than the minimal one I've given) you can see the issue here: tailwindlabs/tailwindcss#18852
If there's further any questions or whatever feel free to ping me and I'll try to clear things up.
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.