Closed igordanchenko closed 1 year ago
Can confirm a similar issue running internal libs being compiled by transpilePackages
. This only happens with --turbo enabled for me.
I have a monorepo with the ui
package needing this in order for "use client";
directive to be recognised.
export * from "./components/Separator"; // Doesn't need "use client"
export {
Popover,
PopoverContent,
PopoverPortal,
PopoverTrigger,
} from "./components/Popover"; // has "use client" directive
Hi there,
I can confirm as well, same issue on my side (same scenario, a UI package). However I'm not using --turbo
yet I have the issue.
This is happening for me in a plain nexJS app.
"dependencies": {
"@types/node": "20.1.1",
"@types/react": "18.2.6",
"@types/react-dom": "18.2.4",
"encoding": "^0.1.13",
"eslint": "8.40.0",
"eslint-config-next": "13.4.1",
"firebase": "^9.21.0",
"jotai": "^2.1.0",
"next": "13.4.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"typescript": "5.0.4"
}
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
No response
Link to the code that reproduces this issue
https://codesandbox.io/p/sandbox/tender-visvesvaraya-rhm6q7?file=%2Fapp%2Fpage.tsx
To Reproduce
Describe the Bug
The
"use client"
directive doesn't appear to be working as intended in 3rd-party libraries usingexport * from
syntax.Next.js produces the following error when I'm trying to use such 3rd-party library in a server component:
I'm using the following sample library to demonstrate this issue.
index.js:
Foo.js:
Bar.js:
You can find the complete library code under the following gist - https://gist.github.com/igordanchenko/e64c9280113e768e8df6673cee7a6035
The
"use client"
directive doesn't appear to be working in the library entry point either. If I remove the"use client"
fromFoo.js
andBar.js
, and add it to theindex.js
instead, Next.js errors out with the following error:Expected Behavior
It should be really straight-forward task for library authors to add the
"use client"
directive to their libraries, andexport * from
syntax should be supported.Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
NEXT-1112