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

[Bug?]: CSS module styles injected after hydration; in dev? #1175

Closed
2 tasks done
LexSwed opened this issue Dec 23, 2023 · 5 comments
Closed
2 tasks done

[Bug?]: CSS module styles injected after hydration; in dev? #1175

LexSwed opened this issue Dec 23, 2023 · 5 comments
Labels
bug Something isn't working vinxi related to vinxi

Comments

@LexSwed
Copy link

LexSwed commented Dec 23, 2023

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

When using CSS modules, so

// text-field.tsx
import styles from './style.module.css';
const TextField = (props) => <div class={styles.textField}><label class={styles.label} /><input class={styles.input} /></div>

const SomeRoute = () => {
  return (
  <section class="container flex flex-col gap-4">
    <TextField label="Field label" placeholder="Enter something" />
  </section>)
}

The TextField styles chunk is not included in the initial HTML, it's loaded lazily after the component is rendered.

See isolated example with text field:
image

image

I also see the warning form Seroval(?) when using CSS modules:

image

Expected behavior 🤔

CSS used for the elements on first render pass is included on the page (as inline styles or separate CSS file in prod env).

Steps to reproduce 🕹

Steps:

  1. Create a component that uses CSS modules.
  2. Use it in a route (maybe createAsync usage is required to reproduce).
  3. See that while component is indeed rendered in the initial HTML on the server, its styles are not included.
  4. This leads to flash of unstyled content.

Context 🔦

No response

Your environment 🌎

Node 20
Vite 5.0.10
vite-plugin-solid 2.8.0
vinxi 0.0.54
solid-start 0.4.2
solid-js latest
@LexSwed LexSwed added the bug Something isn't working label Dec 23, 2023
@srikrsna
Copy link

I see this too. Just to add to the repro steps, in the basic template changing the Counter.css to a css module Counter.module.css will trigger the warning

@nksaraf
Copy link
Member

nksaraf commented Dec 27, 2023

Yeah seems like our Module CSS handling is insufficient. Filing this issue in vinxi where it will need to be fixed.

@nksaraf nksaraf added the vinxi related to vinxi label Dec 27, 2023
@nksaraf
Copy link
Member

nksaraf commented Dec 27, 2023

Should be fixed in vinxi@0.0.55. please try that and reopen this issue if it still doesn't work.

@nksaraf nksaraf closed this as completed Dec 27, 2023
@albertoforni
Copy link
Contributor

I tested it and it works. Thanks

@arackaf
Copy link

arackaf commented Apr 7, 2024

I'm seeing this behavior now, on a new "bare" project scaffolded. Vinxi I have is 0.3.10

Looking at the SSR page source, it looks like the tags with the styles are not being send down from the server (and presumably injected after hydration, as with the original issue above).

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

No branches or pull requests

5 participants