You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I want to use rslib to create a component library which supports server components, how can I preserve the "use client" directive at the top of the file?
If "use client"; isn't the first line in the component definition, it's an invalid client component. If I manually move the directive to the top of the file before packing & installing in my consuming app, it works fine. Is there some config options or plugins that exist today to help solve this, or is this currently unsupported?
Currently, there's not a precise way to preserve the directive. Using `banner (https://lib.rsbuild.dev/config/lib/banner) may works but it's will add banner to all files.
This issue is similar to #166. InitFragment will force inserted the top of the chunk regardless the directive or shebang.
If I want to use rslib to create a component library which supports server components, how can I preserve the
"use client"
directive at the top of the file?I have a pretty basic config:
But my output for a simple client components winds up looking like this:
If
"use client";
isn't the first line in the component definition, it's an invalid client component. If I manually move the directive to the top of the file before packing & installing in my consuming app, it works fine. Is there some config options or plugins that exist today to help solve this, or is this currently unsupported?Originally posted by @rdenman in #379
The text was updated successfully, but these errors were encountered: