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

feat: styled-jsx as client-only for rsc #816

Merged
merged 3 commits into from
Oct 17, 2022
Merged

feat: styled-jsx as client-only for rsc #816

merged 3 commits into from
Oct 17, 2022

Conversation

huozhi
Copy link
Member

@huozhi huozhi commented Oct 9, 2022

Use import "client-only" to mark styled-jsx as client only packages for server components, so that when users try to import it on server layer it will error in next.js

Expected error if you use styled-jsx in server components rather than client components

error - ../../../node_modules/.pnpm/client-only@0.0.1/node_modules/client-only/error.js (1:6) @ eval
error - Error: This module cannot be imported from a Server Component module. It should only be used from a Client Component.
at eval (webpack-internal:///(sc_server)/../../../../node_modules/.pnpm/client-only@0.0.1/node_modules/client-only/error.js:1:7)

x-ref: vercel/next.js#41414

@huozhi huozhi changed the title Mark styled-jsx as client-only for rsc feat: styled-jsx as client-only for rsc Oct 9, 2022
@huozhi huozhi marked this pull request as ready for review October 14, 2022 10:17
@huozhi huozhi requested a review from ijjk as a code owner October 14, 2022 10:17
@huozhi huozhi requested a review from shuding October 14, 2022 10:17
package.json Show resolved Hide resolved
@huozhi huozhi merged commit ea0432b into main Oct 17, 2022
@huozhi huozhi deleted the client-only branch October 17, 2022 22:40
@github-actions
Copy link

🎉 This PR is included in version 5.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@vpontis
Copy link

vpontis commented Oct 18, 2022

Ooo exciting! Congrats on 5.1.0 👍👍

kodiakhq bot pushed a commit to vercel/next.js that referenced this pull request Oct 19, 2022
For css-in-js libs like styled-jsx we don't recommend to use on server side since it will blow up the rsc payload during navigation. This upgration of styled-jsx includes `client-only` as dependency so that it will throw when it's been used on serevr layer

x-ref: vercel/styled-jsx#816
Kikobeats pushed a commit to Kikobeats/next.js that referenced this pull request Oct 24, 2022
For css-in-js libs like styled-jsx we don't recommend to use on server side since it will blow up the rsc payload during navigation. This upgration of styled-jsx includes `client-only` as dependency so that it will throw when it's been used on serevr layer

x-ref: vercel/styled-jsx#816
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants