Open inuwan opened 4 months ago
hi @inuwan
thanks for reporting the issue
could you please set up a minimal reproduction example?
it looks like there is a bug in next.js and or css-loader but I am still investigating it
the error NextRscErrClientMetadataExport
is thrown by some rust code which shouldn't mess with the css at all 🤷♂️
error definition:
Created a reproduction example here:
https://github.com/jantimon/reproduction-next-server-component-css-error
Reported at next.js: https://github.com/vercel/next.js/issues/67591
As a intermediate solution you could split the code - everything works as long as metadata
and yak styled components are not used within the same file
I think we should create another example with this case in our repo. What do you think @jantimon ?
@Mad-Kat - yes we should definitely improve our examples (a more realistic one and a very basic one) 👍
Btw I found the reason for this bug.
During processing Next.js identifies import __styleYak from "./page.yak.module.css!=!./page?./page.yak.module.css
as a page and therefore creates an entry out of it:
https://github.com/vercel/next.js/issues/67591#issuecomment-2236111457
As a intermediate solution you could split the code - everything works as long as metadata and yak styled components are not used within the same file
I tried this, it worked at first. But the navigating on the page triggered the error again...
There is an open bug in next.js but I believe nobody is working on it
https://github.com/vercel/next.js/issues/67591
can you please show us how you are splitting it? maybe we can help you to fix it
Using a next-yak styled component with a server component (page.tsx) that defines the Next.js special function generateMetadata. I get the following error:
You are attempting to export "generateMetadata" from a component marked with "use client", which is disallowed. Either remove the export, or the "use client" directive. Read more: https:// │ nextjs.org/docs/getting-started/react-essentials#the-use-client-directive
If I remove the next-yak styled component, the error is eliminated.