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

fix: css module hmr update #276

Merged
merged 2 commits into from
Apr 10, 2024
Merged

fix: css module hmr update #276

merged 2 commits into from
Apr 10, 2024

Conversation

edivados
Copy link
Contributor

@edivados edivados commented Apr 9, 2024

There is an issue with hmr not working as expected for css modules.
solidjs/solid-start#1400

Problem

CSS Module

Edit the css module and the styling on the counter button will disappear.
Open in StackBlitz

This Vite plugin sends custom hmr events to update inlined css. When updating a css module the generated classes change and don't match anymore with already rendered components.

viteServer.ws.send({
type: "custom",
event: "css-update",
data: {
file,
contents: code,
},
});
return [];

Solution

Currently I see two ways to handle css modules.

  • [In PR] Don't do full custom event handling. Allowing vite to send update event for affected files.
    • Brief FOUC during update because class names don't match. No full page reload.
  • Send a full-reload event

Copy link

codesandbox bot commented Apr 9, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link

vercel bot commented Apr 9, 2024

Someone is attempting to deploy a commit to a Personal Account owned by @nksaraf on Vercel.

@nksaraf first needs to authorize it.

Copy link

changeset-bot bot commented Apr 9, 2024

🦋 Changeset detected

Latest commit: 3b0e0d5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 28 packages
Name Type
vinxi Patch
@vinxi/router Patch
example-react-server Patch
react-rsc-spa Patch
react-rsc-ssr Patch
example-react-spa-basic Patch
react-spa-mdx Patch
react-spa-tanstack-router-app Patch
example-react-spa-tanstack-router-app Patch
react-ssr-basic-cloudflare Patch
react-ssr-basic Patch
react-ssr-tanstack-router-app Patch
react-ssr-wouter Patch
solid-spa-basic Patch
solid-ssr-basic Patch
example-ssr-solid-router Patch
example-vanilla-empty Patch
example-vanilla-partyroom Patch
example-vanilla-server Patch
example-vanilla-spa Patch
example-vanilla-stack Patch
example-vanilla-trpc Patch
test-multi-spa Patch
test-react-rsc Patch
test-react-srv-fn Patch
react-ssr-test-fs Patch
test-react-to-web-request Patch
test-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@edivados edivados marked this pull request as draft April 9, 2024 21:13
@edivados edivados changed the title fix css hmr update fix: css module hmr update Apr 9, 2024
@edivados edivados marked this pull request as ready for review April 9, 2024 22:18
@nksaraf nksaraf merged commit 98bf522 into nksaraf:main Apr 10, 2024
5 of 6 checks passed
@edivados edivados deleted the css-hmr branch April 11, 2024 08:39
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

Successfully merging this pull request may close these issues.

2 participants