next.js icon indicating copy to clipboard operation
next.js copied to clipboard

Next 13 (and canary) Bundles react and react-dom twice in production build

Open Fredkiss3 opened this issue 2 years ago • 3 comments

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 : Capture d’écran 2022-10-25 à 23 42 51

Screenshot for next 13 :

Capture d’écran 2022-10-25 à 23 42 30

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 : Capture d’écran 2022-10-25 à 23 43 21

Screenshot for next 13 : Capture d’écran 2022-10-25 à 23 43 11

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.

Fredkiss3 avatar Oct 25 '22 22:10 Fredkiss3

I'm having the same problem.

image

image

Chastrlove avatar Oct 26 '22 02:10 Chastrlove

same here 🤫

michael-land avatar Oct 26 '22 16:10 michael-land

Same here, looks like it happened on RSC/ new "app" folder routing..

antonybudianto avatar Oct 27 '22 08:10 antonybudianto

Duplicate of #41870. A fix has been merged and will be available soon in the next canary release.

balazsorban44 avatar Oct 28 '22 17:10 balazsorban44

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.

github-actions[bot] avatar Nov 28 '22 00:11 github-actions[bot]