Skip to content

Class names hydration mismatches when using SSR and SCSS styles with module #477

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

Closed
7 tasks done
Gwynerva opened this issue Nov 20, 2024 · 2 comments · Fixed by vuejs/core#12450
Closed
7 tasks done

Comments

@Gwynerva
Copy link

Gwynerva commented Nov 20, 2024

Describe the bug

Without module attribute on <style> Vue SSR correctly handles updates to .scss files that are imported via @use ... at-rule.
However, with module attribte it fails to watch changes to style files or something else breaks with hydration mismatches related to hashed class names so only making manual changes to .vue file will re-sync the updates.

It is also not related to flexible path options when using @use. The bug occurs no matter how you use style files: with .scss extension and without it, omitting _ at the beginning or not.

Reproduction

https://stackblitz.com/edit/github-bea9um

Steps to reproduce

Just create an external .scss file, define any mixin and then @include that mixin in any .vue file <style lang="scss" module> tag.
Changing the .scss fill will break all files that @use this style file.

System Info

Everywhere

Used Package Manager

npm

Logs

No response

Validations

@Gwynerva Gwynerva changed the title Class names hydration mismatches when using SSR ans SCSS styles with module Class names hydration mismatches when using SSR and SCSS styles with module Nov 20, 2024
@hi-ogawa
Copy link

hi-ogawa commented Nov 20, 2024

I couldn't grasp you description in details, but can you confirm the same issue happens for simple css too? without @use and such?

<style lang="css" module>
.header {
  /* hydration error after changing this to `color: green` */
  color: red
}
</style>

What's happening looks normal in terms of Vite's behavior, so you might need to check with renderer side. Probably asking on https://github.com/vitejs/vite-plugin-vue/ is better.


Also can you check this #146? It looks like there's a known issue with css module hmr.

@sapphi-red sapphi-red transferred this issue from vitejs/vite Nov 21, 2024
@edison1105
Copy link
Member

duplicate of #146
The root cause is that the HMR reload triggers hydration.
This is a bug in vuejs/core, I will create a PR to fix this.

@edison1105 edison1105 closed this as not planned Won't fix, can't repro, duplicate, stale Nov 21, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Dec 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants