-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fails to hmr accept virtual modules #12912
Comments
Re-opening as fix is reverted in #13734 |
I think this should still be open? @bluwy ? |
I believe I've run into a similar issue, a virtual module has broken my build #16142 |
Please ignore everything I wrote below I turns out that in my Vite config I got confused between invalidating the server module, which leads to the transitive reloading that I observed below, and actively pushing an HMR update with If I push an HMR everything works as expected.
|
I have some hard time to debug a failed HMR issue. In my exact case, I use unplugin-icons to create a custom icon package to install to my project via npm install @org/ui-icons. If I use the unplugin-icons vite plugin directly in my vite.config.js, the icon rendered, HMR works. It turns out very costly that it is caused by my ui-icons package was bundling @vue/shared, core, reactivity internally via unplug-icons' virtual module.. This breaks how vite HMR works internally(I don't have further time to go deeper to figure out why, maybe some future time). After I use vite plugin to externalize deps, All the frustration gone instantly. import { defineConfig } from "vite"
import Icons from "unplugin-icons/vite"
import dts from "vite-plugin-dts"
import { externalizeDeps } from "vite-plugin-externalize-deps"
export default defineConfig({
//Omited
plugins: [Icons(), dts(), externalizeDeps()]
}) Lesson learned is HMR can be failed in project by npm package as it may break how HMR works internally. especially with virtual modules |
Describe the bug
I'm trying to hot reload a virtual module, but it doesn't seem to be able to accept it:
Reproduction
https://github.com/Janpot/vitejs-virtual-hmr
Steps to reproduce
yarn && yarn dev
http://localhost:3000
const mod = devServer.moduleGraph.getModuleById(path.resolve("./src/bar.js"));
I tried using
/@id/__x00__virtual:my-plugin:foo
, but that doesn't work neitherSystem Info
Used Package Manager
yarn
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: