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

Styles not reloading correctly in DEV mode of example app 37_css #1241

Closed
supersoniko opened this issue Feb 17, 2025 · 6 comments · Fixed by #1259
Closed

Styles not reloading correctly in DEV mode of example app 37_css #1241

supersoniko opened this issue Feb 17, 2025 · 6 comments · Fixed by #1259
Labels
bug Something isn't working

Comments

@supersoniko
Copy link

supersoniko commented Feb 17, 2025

Environment:

  • Waku 0.21.20
  • OS: Mac OS 15.3
  • Browser: Arc and Firefox Developer Edition
  • Node 20.17.0

Issue
When editing a style in the example application 37_css the new style is not automatically loaded and requires a manual refresh in the browser. HMR is triggered and the old style is not visible anymore, but to see the new style applied a manual refresh is required.

Reproducible steps

  1. Clone waku repository
  2. go to examples/37_css
  3. npm install
  4. npm run dev
  5. in app.module.css change the background-color to another color value

Extra Info
I notice this is not an issue in the example app 04_cssmodules. Might be related to the different routing? I also have this issue in my own application where I solely use css modules, but I do use the routing approach from example 37_css instead of the file system based routing.

@supersoniko supersoniko changed the title Styles not reloading correctly DEV mode of example 37 Styles not reloading correctly in DEV mode of example 37 Feb 17, 2025
@supersoniko supersoniko changed the title Styles not reloading correctly in DEV mode of example 37 Styles not reloading correctly in DEV mode of example app 37_css Feb 17, 2025
@dai-shi
Copy link
Member

dai-shi commented Feb 18, 2025

Confirmed the issue. For me, it reproduces with 04_cssmodules too.

Can you help investigating the issue? The first thing we would like to know is if this is a regression with some changes.

You can check out some previous commits and run:

git switch --detach ...
pnpm i
pnpm -F ./packages/waku compile
pnpm -F 37_css dev

instead of changing the directory.

@dai-shi dai-shi added the bug Something isn't working label Feb 18, 2025
@wesbos
Copy link
Contributor

wesbos commented Feb 19, 2025

Having this issue as well, Ill dig into the example, but from first glance:

  1. The issue only happens when the styles are in a RSC, not a client component
  2. When a CSS module is changed, the class hash is regenerated. For example the class _NavStyles_13kgl_8 is changed to _NavStyles_fzxdl_8. The corresponding <style> tag is also updated. In the case of a RSC, the <style> tag is updated, but the className on the RSC is not.

@wesbos
Copy link
Contributor

wesbos commented Feb 19, 2025

I traced it back 0.18.0 and had trouble getting anything earlier running. The issue seems to always be there. At 0.18.0 the issue changed a bit, but I'm assuming this is related to the full page reload VS the hot reload. Here is a video: https://share.cleanshot.com/PLM8Sffl

@wesbos
Copy link
Contributor

wesbos commented Feb 19, 2025

Interestingly, testing 37_css which also has Stylex in it, anytime any server component is updated, the Stylex client components are stripped of their styles.

Demo: https://share.cleanshot.com/JfQyGNMs

@dai-shi
Copy link
Member

dai-shi commented Feb 20, 2025

Wes, thanks so much for looking into it. It sounds like it's not a regression, and it has never worked before.

To be honest, our team lacks css specialists. Hope @Aslemammad has time to help. Otherwise, I should take a closer look later.

As for stylex, I'd say it's not working correctly in several aspects. We track the issue in #750.

@wesbos
Copy link
Contributor

wesbos commented Feb 21, 2025

Looks like next/webpack suffers the same issue, though I never had it with my next site vercel/next.js#57046

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

Successfully merging a pull request may close this issue.

3 participants