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
Emit "use client" directive for RSC builds #3115
Comments
Unknown directives are currently stripped by the minifier. I can change esbuild to preserve them instead. In the meantime, you can use the banner feature to do this. |
Sorry to jump in here after all this time but I'll need this soon and just adding a banner to the entire bundle seems a bit excessive. It's been a while since I've used esbuild so I might have forgotten a few things that can circumvent this issue. Let me know if the situation has changed or not and if there's some magic trickery I can use to keep the directive only for the components that actually need it. |
Esbuild does it's job at the referenced commit, but my experience says that the whole toolchain is usually more than esbuild. You may need to code split via something like |
Did this get released? I've noticed it only keeps the directive in index.ts files and not the chunks and component files. So any nestting of rsc+rcc never will work. |
React Server Components require client-only components to be served with a module-level directive
"use client"
, hook authors are now required to add them to stay forward compatible.Is there a way to tell esbuild to keep them in the final ESM bundle?
The text was updated successfully, but these errors were encountered: