Skip to content
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

Watching of rust files not working in Vite #41

Open
darichey opened this issue Jul 5, 2023 · 2 comments
Open

Watching of rust files not working in Vite #41

darichey opened this issue Jul 5, 2023 · 2 comments

Comments

@darichey
Copy link

darichey commented Jul 5, 2023

When using this plugin in Vite, modifying rust files does not trigger a reload. Here is a minimal repro: https://github.com/darichey/rollup-plugin-rust-watch-issue-demo

Using vite --debug, I can see this in the logs when modifying lib.rs:

vite:hmr [file change] src/lib.rs +5s
vite:hmr [no modules matched] src/lib.rs +0ms

It's possible that this is a Vite issue. It seems related to vitejs/vite#7024.

@meesvermeulen
Copy link

I ran into the same issue.
As a workaround I added a handleHotUpdate hook to reload:

let rustPluginInstance = rust();
rustPluginInstance["handleHotUpdate"] = (ctx) => {
  if (ctx.file.endsWith(".rs")) {
    console.log("Rust code changed");
    ctx.server.restart();
  }
};

@Pauan
Copy link
Collaborator

Pauan commented Jul 27, 2023

This is definitely a Vite bug. They claim that they fixed it, but it seems that it's not fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants