-
Notifications
You must be signed in to change notification settings - Fork 27.6k
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
14.2.0 throws errors with Turbopack when importing client components in route handlers that use context #64412
Comments
I've run into a similar error but with a slightly different repro scenario. in my case, I have a server component like this:
Even though I am using version 2.8.2 of |
Resolves #64412 This adds a client transition to the app route `ModuleAssetContext` and the corresponding transforms so that client components can be safely imported and referenced (as their proxies) in app routes. Test Plan: Added an integration test
Hey @wbinnssmith I just did some testing with this on Might be worth noting that we have components within I have updated the reproduction in this initial post to demonstrate that local client files with Take a look at this file for a working route: And this one for a broken route: Any ideas? |
Amazing - thank you! |
Epic - thanks everyone. Confirmed everything works in Payload again. 👍 |
Thanks for checking James! |
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Link to the code that reproduces this issue
https://github.com/jmikrut/next-turbo-client-components
To Reproduce
npm run dev
- note that it worksnpm run dev:turbo
- note that it breaksCurrent vs. Expected behavior
Turbopack throws the following error:
But, the component that uses
createContext
indeed has the'use client'
directive at the top of the file, so this error should not be thrown.Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 21.6.0: Mon Aug 22 20:19:52 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T6000 Available memory (MB): 32768 Available CPU cores: 10 Binaries: Node: 20.11.1 npm: 10.2.4 Yarn: 1.16.0 pnpm: 8.15.1 Relevant Packages: next: 14.2.0 // Latest available version is detected (14.2.0). eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0 typescript: 5.1.3 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Turbopack (--turbo)
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
Up until
14.2.0-canary.34
, Turbopack was working properly for us at Payload. After that, Turbopack now throws an error.Release that breaks it:
https://github.com/vercel/next.js/releases/tag/v14.2.0-canary.34
It might seem strange that we are importing client components in a request handler, BUT, the Payload config contains both server-side and client-side code, including custom React components. We need the Payload config within API routes in order to function, so, safely being able to disregard client components within route handlers is paramount to us.
Also of note,
useState
works fine in theClientComponent
included in this repro. It's justcreateContext
that breaks Turbopack.PACK-3014
The text was updated successfully, but these errors were encountered: