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

Hot module replacement #3

Closed
2 tasks
axelboc opened this issue Feb 29, 2024 · 6 comments
Closed
2 tasks

Hot module replacement #3

axelboc opened this issue Feb 29, 2024 · 6 comments
Labels
bug Something isn't working released

Comments

@axelboc
Copy link

axelboc commented Feb 29, 2024

Problem

You're probably aware of it already, but CSS modules are no longer reloaded automatically on change with this plugin. Even refreshing the page doesn't seem to work; I have to restart the server to see changes.

Expected behavior

Any changes to CSS modules should appear right away in the browser in development, without restarting/reloading.

Minimal reproduction URL

NA

Version

5.1.0

Node.js version

20

Package manager

pnpm

Operating system

Windows

Contributions

  • I plan to open a pull request for this issue
  • I plan to make a financial contribution to this project
@axelboc axelboc added the bug Something isn't working label Feb 29, 2024
@privatenumber
Copy link
Owner

Thanks for the issues!

Can you provide a minimal reproduction for this? It works fine for me.

@axelboc
Copy link
Author

axelboc commented Feb 29, 2024

Hmm maybe it's related to my TS monorepo set-up. I have an app project that depends on a lib project. The app imports the lib's source files directly; there's no build step.

  • When I save a CSS module located inside app, I do see an "hmr update" log in the terminal, but nothing changes in the browser.
  • When I save a CSS module located inside lib, nothing happens at all; I have to restart the server.

I'll try to make a repro.

@privatenumber
Copy link
Owner

I was able to reproduce the bug:
https://stackblitz.com/edit/vitejs-vite-zc8bbp?file=src%2Fstyle.module.css

I had fixed it in vitejs/vite#16018, but forgot to port the fix back to this plugin. Thanks for catching! Will be fixed shortly.

I also found that HMR doesn't currently work in CSS Module dependencies in Vite: vitejs/vite#16074

@privatenumber
Copy link
Owner

🎉 This issue has been resolved in version 1.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@privatenumber
Copy link
Owner

privatenumber commented Mar 2, 2024

I added this demo to the README to confirm HMR is working now in v1.3.0:
https://stackblitz.com/edit/vitejs-vite-v9jcwo?file=src%2Fstyle.module.css

@axelboc
Copy link
Author

axelboc commented Mar 4, 2024

Awesome, glad you were able to reproduce!

I forked your repro because I'm still having issues when coupled with the @vitejs/plugin-react plugins. I get page reloads instead of hot replacements: https://stackblitz.com/edit/vitejs-vite-15bgs7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released
Projects
None yet
Development

No branches or pull requests

2 participants