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
next/dynamic with ssr: false | changed behaviour / breaking builds in Next 13 #43895
Comments
Can you provide a minimal reproduction to show how you use |
@huozhi Apologies, I've now updated the issue with an example repo and instructions. |
Seems like a module resolving issue instead of a |
@huozhi yeah sorry, logically at the bug is probably somewhere in swc, rather than dynamic. |
Interestingly the bug is not present in 13.0.2-canary.2, but is there in 13.0.2-canary.3. |
So looking at it I think the error comes from this commit, 21b6654 @huozhi . Is this intentional? I'm not 100% up to speed on server components so I may just be missing the logic here. |
Thanks for the investigation! I got what you mean why it appears in the trace and can't resolve with browser field. Filed #43974 to fix it |
Thanks so much. Apologies again for the rather opaque description of the bug, it all made sense in my head. 🙂 |
Fixes #43895 There's a `is_server_components` condition introduced in #42426 but it's always truthy so the `ssr:false` is not erased properly. Then in #42589 the flag is removed but also the optimization is removed as well. This PR reverts the unexpected change removed in #42589 to keep the removal for client dynamic imports on server side. Add tests to keep there's no trace ## Bug - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
Fixes #43895 There's a `is_server_components` condition introduced in #42426 but it's always truthy so the `ssr:false` is not erased properly. Then in #42589 the flag is removed but also the optimization is removed as well. This PR reverts the unexpected change removed in #42589 to keep the removal for client dynamic imports on server side. Add tests to keep there's no trace ## Bug - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
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
Operating System:
Platform: darwin
Arch: x64
Version: Darwin Kernel Version 22.1.0: Sun Oct 9 20:14:54 PDT 2022; root:xnu-8792.41.9~2/RELEASE_X86_64
Binaries:
Node: 16.18.1
npm: 7.20.2
Yarn: 1.22.19
pnpm: N/A
Relevant packages:
next: 13.0.7-canary.4
eslint-config-next: 12.1.0
react: 18.2.0
react-dom: 18.2.0
Which area(s) of Next.js are affected? (leave empty if unsure)
Dynamic imports (next/dynamic)
Link to the code that reproduces this issue
https://github.com/maxcbc/nextjs-13-dynamic-bug
To Reproduce
Investigation Points
./components/dynamic-thing/some-client-side-only-component.tsx
toimport foo from 'fake-dependency-1/browser'
Adding
main
property"main": "browser.js",
to each of the fake dependency package.json filesDescribe the Bug
Broken somewhere between 12.3.4 and 13.0.6.
Module not found errors in build when running the above.
Can be fixed by adding a
main
property in thepackage.json
of the 'missing' modules.Expected Behavior
In the example above
./some-client-side-only-component.tsx
should never be required when compiling serverside code.There should be no trace of them in
.next/server
after a build.Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
The text was updated successfully, but these errors were encountered: