feat: support server-only and client-only modules (#2162)#2167
feat: support server-only and client-only modules (#2162)#2167YanAnghelp wants to merge 2 commits into
server-only and client-only modules (#2162)#2167Conversation
✅ Deploy Preview for solid-start-landing-page ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
🦋 Changeset detectedLatest commit: 54fc19b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
| { | ||
| name: "solid-start:boundary-modules", | ||
| enforce: "pre", | ||
| resolveId(id, importer, { ssr }) { |
There was a problem hiding this comment.
this is all that is needed?
There was a problem hiding this comment.
Yes, I have already tested it.
There was a problem hiding this comment.
There's a known limitation: when a client component imports a file that uses server-only, even if all functions in that file are marked with "use server", the build will incorrectly treat this as the client component directly calling server-only functions and throw an error. The only workaround is to apply "use server" at the file level.
However, "use server" already guarantees that the functions execute on the server — in that case, server-only is redundant. server-only is primarily meant to protect functions that must run on the server and cannot be called directly from outside (i.e., not exposed as RPC endpoints).
Closes #2162