vercel / next.js

The React Framework
https://nextjs.org
MIT License
124.72k stars 26.62k forks source link

Next 14 build First Load JS size increased compared to Next 13.5.6 #58047

Open AnasArafeh opened 10 months ago

AnasArafeh commented 10 months ago

Link to the code that reproduces this issue

https://github.com/AnasArafeh/Next14-build-issue-reproduction

To Reproduce

  1. npm install Next 13.5.6
  2. npm run build
  3. view first load js sizes
  4. npm install Next 14.0.1
  5. npm run build
  6. view first load js sizes

Current vs. Expected behavior

Following the previous steps:

The result for npm run build in Next 13.5.6 : 13 5 6

And the result for npm run build in Next 14.0.1 : 14 0 1

the only package changes were these using git : git-changes

The result for Next 14.0.2-canary.12 : 14 0 2-canary 12


Screenshots from reproduction template

Next 13.5.6

reproduction-13 5 6

Next 14.0.2-canary.12

reproduction-canary 12

Verify canary release

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Enterprise
Binaries:
  Node: 18.18.0
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.0.2-canary.12
  eslint-config-next: 14.0.1
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.2.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Package manager (npm, pnpm, Yarn), Script optimization (next/script)

Additional context

The issue was introduced in Next 14, I have also tested it on the latest canary release and the issue remains the same. I have even noticed 1 KB increase in canary release compared to Next 14.0.1.

NEXT-1762

jantimon commented 10 months ago

maybe duplicate of #57886

abenhamdine commented 10 months ago

probably fixed by https://github.com/vercel/next.js/pull/57904

AnasArafeh commented 10 months ago

@jantimon @abenhamdine I have tried the latest canary release Next 14.0.2-canary.21 that I believe includes the fix mentioned.

There was a small decrease few kb as shown in screenshot

Next 14.0.2-canary.12 image

Next 14.0.2-canary.21 image

However, if you compare it to Next 13.5.6 ( screenshot available in the issue above ) you can see that the actual First Load JS size is doubled for some files, so these few KB changes does not resolve the issue.

balazsorban44 commented 9 months ago

Thanks for reporting! After having a closer look, this seems to be related to a regression via https://github.com/vercel/next.js/pull/57474/files#diff-e249217c618857db05acc1cba9dbaad4e488dbb256aa0b33ea471e9ff1629c33

we will have a look!

jantimon commented 9 months ago

Here are some stats from a real world project:

shot-NqbOuCgn shot-goufu93X

The overall bundle size is increasing by about 13kb (before gzip) but that's only a fraction of the overall project size