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: No styles in client components in PRD #658

Merged
merged 4 commits into from
Apr 13, 2024

Conversation

Aslemammad
Copy link
Contributor

Partially resolves #651

Copy link

vercel bot commented Apr 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
waku ✅ Ready (Inspect) Visit Preview Apr 13, 2024 0:19am

Copy link

codesandbox-ci bot commented Apr 10, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Copy link
Owner

@dai-shi dai-shi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than that it looks good.

const cssStr = cssAssets
.map((asset) => `<link rel="stylesheet" href="${asset}">`)
.join('\n');
// HACK is this too naive to inject style code?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I wish we could inject it in rscIndexPlugin for both server & client styles.
(hmm, we might consider about re-architecture at some point, for code-splitting styles, and (vite) plugins too.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, we haveto do code-splitting at some point! Shall I now work on it and get it working with rscIndexPlugin?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall I now work on it and get it working with rscIndexPlugin?

Is it possible for the current architecture?
It would be nice if there's a less-hacky way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure I'll try my best, I'll get back to you soon!
But if we want to do a release, I think let's merge it and tackle it later (maybe in the re-arch)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(re-arch won't be soon.)
Yeah, if there's a better way, we would like to have it now. I plan to merge it next week.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took a look, the emitted css files are emitted in the client bundle phase which is the last phase, while rscIndexPlugin happens at the same time or even before in the buildSsrBundle phase.

I don't know if it's possible to bring the client bundle before ssr! But it's not ideal anyway. Wdyt? maybe we should skip it.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it may require one more viteBuild step, which is not very good because it will make it slower.

I think the best is to send <link> tag in the RSC payload. But, it will require new technique (it's more work and different from re-arch I said above. It's more related with code-splitting.)

Thanks for your investigation. Let's merge this for now.

@dai-shi dai-shi mentioned this pull request Apr 13, 2024
2 tasks
@dai-shi dai-shi merged commit 59d4562 into dai-shi:main Apr 13, 2024
28 checks passed
@dai-shi dai-shi mentioned this pull request Apr 17, 2024
@Aslemammad Aslemammad deleted the fix/styles-client-comps-prd branch April 17, 2024 05:57
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.

Fix broken 04_cssmodules example
2 participants