-
-
Notifications
You must be signed in to change notification settings - Fork 208
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
"use client" not appearing in the ESM entry #182
"use client" not appearing in the ESM entry #182
Comments
PR welcome! |
I'm guessing the solution will be in the build tool: https://github.com/preconstruct/preconstruct |
I didn't see any issues referencing that in the preconstruct repo. I see a few mentions of |
I opened a PR that might fix this here. It doesn't solve all the potential setups. I think that likely having the whole module marked with the
Is this true? I'm not an expert on the subject but the code in this particular node loader indicates that it's just its decision to ignore everything that is not a module. So it doesn't look like an inherent limitation. I recognize the issue here but to quote their README 😅 :
In a way, the issue seems to be not in a way how this package is structured but in their decision to ignore CJS files. I don't recall any mentions of |
Thanks a ton for taking a look, @Andarist. I’m also not sure of the right thing to do here, really. So much about server components feels half baked right now. |
react-error-boundary
version: 4.0.13 (latest)node
version: v20npm
version: v10Relevant code or config
What you did:
Using the node loader from react-server-dom-esm (https://github.com/facebook/react/blob/e373190faf3b994707f09488c1a7832f4a91e15a/packages/react-server-dom-esm/src/ReactFlightESMNodeLoader.js#L471-L481)
What happened:
react-error-boundary
is not treated as a client component because the "use client" pragma doesn't appear in the ESM module (only the CJS module).Problem description:
The problem is that node loaders can only transform native ESM modules. So the "use client" pragma needs to appear in the ESM module. Something in the build process doesn't make that work though.
Suggested solution:
My workaround is to create a separate module in my own codebase that adds the "use client" pragma and import that instead. I would love to not have to do that.
The text was updated successfully, but these errors were encountered: