next.js
next.js copied to clipboard
Next 13 (and canary) Bundles react and react-dom twice in production build
Verify canary release
- [X] I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 22.1.0: Sun Oct 9 20:14:30 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T8103 Binaries: Node: 16.17.1 npm: 8.15.0 Yarn: 1.22.18 pnpm: 7.1.0 Relevant packages: next: 12.3.2-canary.43 eslint-config-next: 13.0.0 react: 18.2.0 react-dom: 18.2.0
What browser are you using? (if relevant)
Chrome 106.0.5249.119 (arm64)
How are you deploying your application? (if relevant)
No response
Describe the Bug
starting with two simple nextjs project (the getting started template page), one with NextjS 12 and the other with NextjS 13. When I launch a production build, i see that there is almost no difference in the bundle size, even worse i see that with next 12 the bundle is lighter.
Screenshot for next 12 :
Screenshot for next 13 :
When I tried to see the content of the bundle with @next/bundle-analyzer
, I noticed that nextjs 13 bundles react and react-dom twice while in nextjs 12 it bundles it only once.
Screenshot for next 12 :
Screenshot for next 13 :
Expected Behavior
I don't know if it's a bug or the expected behavior, but in my opinion it should not bundle react-dom twice since for an app this size react-dom is the biggest factor in size.
And if it the expected behavior, then i would like to know why it does that.
Link to reproduction
https://stackblitz.com/edit/vercel-next-js-1wu76s
To Reproduce
To reproduce, clone the template repo and run a production build with ANALYZE=true
env variable to see the content of the generated bundle.
I'm having the same problem.
same here 🤫
Same here, looks like it happened on RSC/ new "app" folder routing..
Duplicate of #41870. A fix has been merged and will be available soon in the next canary
release.
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.