vercel / next.js

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

Bundle size increased by ~5% after 13.4.19 #57108

Open LoiLock opened 1 year ago

LoiLock commented 1 year ago

Link to the code that reproduces this issue

https://github.com/LoiLock/nextjs-bundle-size

To Reproduce

Recently I found that after only updating nextjs, the bundle size has increased quite a bit for what is only a minor version bump.

The following screenshots were after a fresh install

Not sure where to go from here, would like to find out what causes the increase in size.

Current vs. Expected behavior

13.4.19:

Screenshot 2023-10-20 at 10 03 18

13.5.7-canary.11:

Screenshot 2023-10-20 at 10 03 49

Verify canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.0.0: Thu Aug 17 21:23:05 PDT 2023; root:xnu-10002.1.11~3/RELEASE_ARM64_T6000
Binaries:
  Node: 20.1.0
  npm: 9.6.4
  Yarn: 1.22.19
  pnpm: N/A
Relevant Packages:
  next: 13.5.7-canary.11
  eslint-config-next: N/A
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.1.3
Next.js Config:
  output: N/A

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

Not sure

Additional context

No response

DustinBrett commented 1 year ago

I'd noticed the same issue and have been waiting/hoping it would be fixed. It added nearly 9 kB's in my case. 272 kB after upgrade, 263 kB before. I'm not expecting every upgrade to be the same size or smaller, but 9 kB seemed like a good sized jump.

balazsorban44 commented 1 year ago

Hi @DustinBrett. adding a reproduction in this case would be beneficial, as this can happen for many reasons, and it's not possible to tell without some actual code to look at.

@LoiLock are you able to pin down a specific version this increase was introduced in? This could help investigate if this was a regression in our minifier, a dependency/vendored package change, or something else.

You can use @next/bundle-analyzer to analyze bundle sizes across Next.js versions.

LoiLock commented 1 year ago

@balazsorban44 Well, any version right after 13.4.19 adds extra. A few kb per minor version bump. The following screenshots are from a full project, the only thing that was changed was the next version, with the .next and node_modules cleared before every build, just to be sure.

13.4.19: image 13.5.2: image 13.5.6: image 13.5.7-canary.11: image

LoiLock commented 1 year ago

Keep in mind though, with the example that I provided, I used yarn create next-app --example reproduction-template-pages so the increase happens regardless of whether other packages are installed.

DustinBrett commented 1 year ago

Hi @DustinBrett. adding a reproduction in this case would be beneficial, as this can happen for many reasons, and it's not possible to tell without some actual code to look at.

I was just agreeing with OP and not making my own bug report and going through making a reproduction. I've decided to stay at 13.5.3 and see how things improve with reports like this one.

balazsorban44 commented 1 year ago

@DustinBrett I appreciate it, but in this case, the "same issue" comment was not really helpful/actionable, and simply :+1:-ing the original post is enough in this case, to keep the conversation relevant/helping the investigation.

So far, the changes seem to be growing slowly over versions, which might just be the added code to the codebase, and not a verifiable as a regression.

chrisrudge2002 commented 1 year ago

In case it helps... I am seeing the same issue (5% increase in bundle size) but only starting with version 13.5.4.

bobaaaaa commented 1 year ago

I compared some files locally in our codebase. It seems that the minifyer has changed a lot. See https://github.com/vercel/next.js/pull/56281 for example

sabrinaluohk01 commented 1 year ago

Hi, the bundle size increased 20% + for our case, checked with webpack-bundle-analyzer, it's mainly caused by browserify related code image 13.5.6 vs 13.5.2

LoiLock commented 1 year ago

Any updates/comments?

LoiLock commented 4 months ago

Issue keeps increasing quite drastically, just upgrading to the latest next@15.0.0-canary.91 added about 10-15kb to my bundle

lovrozagar-recommend commented 1 day ago

Same here, Nextjs 15.0.3 Hello world after build is now shipping 100kb to the client (first load js)