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: Svelte CSS won't work on build if inside a component with client:only directive #2966

Closed
1 task
outerlook opened this issue Apr 2, 2022 · 5 comments Β· Fixed by #3113
Closed
1 task
Assignees

Comments

@outerlook
Copy link

What version of astro are you using?

0.25.4

What package manager are you using?

npm, (but local pnpm)

What operating system are you using?

Stackblitz, but local linux

Describe the Bug

Expected

1 - npm run dev βœ…
2 - Observe components are blue and red βœ…
3 - npm run build && npm run preview βœ…
4 - Observe components continue to be blue and red βœ…

Reproduced

1 - npm run dev βœ…
2 - Observe components are blue and red βœ…
3 - npm run build && npm run preview βœ…
4 - Observe red is red, but blue isn't blue ❌

The difference in components is the client:XXX directive

I tried to understand better astro codes to understand this, but I failed to understand vite-plugins particpation, etc... if someone points the right direction I would try to submit a PR

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-cdtzxj?file=src/pages/index.astro

Participation

  • I am willing to submit a pull request for this issue.
@songololo
Copy link

Same for me with vue components with client:only directive.

@outerlook
Copy link
Author

Persists on 0.26.0
https://stackblitz.com/edit/github-cdtzxj-wai3qu?file=src%2Fpages%2Findex.astro

@LorenzoLeonardini
Copy link

The last version this worked properly was 0.25.2, something broke in the 0.25.3 release

@songololo
Copy link

Still happening on v1.0.0-beta.4

For me it only happens with client:only i.e. no issues if using the client:load directive where suitable.

@bholmesdev
Copy link
Contributor

bholmesdev commented Apr 7, 2022

Initial findings: this is caused by our recent PR to prevent styles leaking to unrelated pages #2918

Dev-y notes mostly for myself: When building the page, client:only components are stripped from the top-level imports by esbuild since they aren't used for SSR. This function call is the culprit. Since we walk through all components imported by the page via ESM, we accidentally miss these client:only components.

☝️ Working on a fix to address the above! Hoping we don't need too many changes

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 a pull request may close this issue.

4 participants