-
-
Notifications
You must be signed in to change notification settings - Fork 638
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(build): set some files to the client only for React Server Components use case #2245
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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. Latest deployment of this branch, based on commit fe7c7f8:
|
I think there is another approach that could make You can see https://github.com/vercel/swr/blob/41b061306e2ce8b64e2923b1594e8db525c9368a/package.json#L36 for example |
Please add the directive only in I don't think |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the directive only in jotai/react and jotai/react/utils.
Sorry for the late response. I will update the PR today |
btw, yarn now has 4.x version. Have any plans to migrate to the latest or use pnpm? I think yarn 1 is too old. |
I would personally like to move to pnpm for all zustand/jotai/valtio. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The diff looks good. I'll test it locally later.
diff -r dist.orig/esm/react/utils.mjs dist/esm/react/utils.mjs
0a1
> 'use client';
diff -r dist.orig/esm/react.mjs dist/esm/react.mjs
0a1
> 'use client';
diff -r dist.orig/package.json dist/package.json
88c88
< "react": {
---
> "@types/react": {
91c91
< "@types/react": {
---
> "react": {
94c94,95
< }
---
> },
> "packageManager": "[email protected]"
diff -r dist.orig/react/utils.js dist/react/utils.js
0a1
> 'use client';
diff -r dist.orig/react.js dist/react.js
0a1
> 'use client';
diff -r dist.orig/system/react/utils.development.js dist/system/react/utils.development.js
0a1
> 'use client';
diff -r dist.orig/system/react/utils.production.js dist/system/react/utils.production.js
0a1
> 'use client';
diff -r dist.orig/system/react.development.js dist/system/react.development.js
0a1
> 'use client';
diff -r dist.orig/system/react.production.js dist/system/react.production.js
0a1
> 'use client';
diff -r dist.orig/umd/react/utils.development.js dist/umd/react/utils.development.js
0a1
> 'use client';
diff -r dist.orig/umd/react.development.js dist/umd/react.development.js
0a1
> 'use client'; I'm not sure if we need to modify UMD/SystemJS, but it may not hurt. |
I just want to understand the reason for adding 'use client' to all files associated with React. From my understanding, it actually only needs to be added to files containing a |
Yes, usage-wise I think so too.
And, that's why. I'm not sure if there's any drawback, like error message. |
Related Issues or Discussions
Discussion: #2241 (comment)
Summary
Are not allowed in the server component since it import
useEffect
anduseState.
directly or indirectlyYou can import
jotai/vanilla
Check List
yarn run prettier
for formatting code and docs