Closed bjfresh closed 10 months ago
@bjfresh thanks for mentioning!
I believe it might not be the worst idea to revert https://github.com/vercel/next.js/pull/59254 since there is no ETA for a fix.
At least it will unblock a huge number of people from updating to the latest version
This should be fixed with the latest canary as of yesterday, can you try again?
@ForsakenHarmony seems to work with the latest canary release, yes, in both my minimal repo and the production site. Excellent!
Ex-Berliner here, too.
@ForsakenHarmony this is not is fixed definitely https://github.com/vercel/next.js/issues/59804
@OlegLustenko that sounds like a different issue then (I think this one is primarily about turbopack), could you open an issue with a reproduction?
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/bjfresh/next14-turbo-lazy-error
To Reproduce
If
'use client'
is commented out in either Test1.tsx or TBAccount.tsx, the page will then render fine.Current vs. Expected behavior
Current behaviour:
I have a large repo that works well in both Next 13 and Next 14 with the default dev configuration. This repo is derived from a fairly minimal Web3 starter that I've assembled. I'm hoping to start working with Turbopack.
When run using
pnpm dev --turbo
, I consistently get the following error that prevents render:I've tracked this back to a quirk in how Turbopack seems to handle imports from barrel files. It seems as though Turbopack cannot handle multiple components with
'use client'
being exported from the same file. Generally I export components from a barrel like so:and import as such:
The two files I'm exporting (just minimal example components) look like this:
Test1.tsx
TBAccount.tsx
If both components specify 'use client', the "Lazy element type must resolve to a class or function" error is thrown, even if I'm only importing Test1 in page.tsx. If I comment out 'use client' in either file, the page will render as expected.
page.tsx
Expected behaviour: components exported from barrel file can be imported and function correctly. This works in Next 13 and Next 14 with the default configuration but not with the
--turbo
flag enabled.Verify canary release
Provide environment information
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
There are a few issues reporting similar problems with less specificity:
https://github.com/vercel/next.js/issues/59804
@OlegLustenko pointed out this started occurring with
14.0.4-canary.41
+ possibly the associated PR https://github.com/vercel/next.js/pull/59254 (cc: @shuding)Also: https://github.com/vercel/next.js/issues/59535 https://github.com/vercel/next.js/discussions/59534 https://github.com/vercel/next.js/issues/59386
PACK-2223