Skip to content
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

4% increase in bundle size from next 11.1.2 to 12.0.7 #32417

Closed
LarsBuur opened this issue Dec 12, 2021 · 11 comments · Fixed by #32730
Closed

4% increase in bundle size from next 11.1.2 to 12.0.7 #32417

LarsBuur opened this issue Dec 12, 2021 · 11 comments · Fixed by #32730
Labels
bug Issue was opened via the bug report template.

Comments

@LarsBuur
Copy link

What version of Next.js are you using?

12.0.7

What version of Node.js are you using?

14.15.1

What browser are you using?

Chrome

What operating system are you using?

macOS

How are you deploying your application?

Vercel

Describe the Bug

We have been struggling with our bundle size and put a huge effort into making it as small as possible

Going from Next v. 11.1.2 to 12.0.7 means an increase in bundlesize from 127Kb to 132 kb.

This is before and after from next build:

Page                                                                               Size     First Load JS
├   /_app                                                                          0 B            75.8 kB
├ ● /[...slug] (ISR: 3600 Seconds) (122414 ms)                                     14.1 kB         127 kB

We tried enabling and disabling swcMinify in next.config.js without any noticeable difference

Page                                                                               Size     First Load JS
├   /_app                                                                          0 B            80.6 kB
├ ● /[...slug] (ISR: 3600 Seconds) (123146 ms)                                     14 kB           132 kB

Is this to be expected?

Expected Behavior

Same of less size. Not bigger.

To Reproduce

The difference in percentage would differ from project to project. To reproduce just monitoring bundle "First Load JS" from next build reveals the problem

@LarsBuur LarsBuur added the bug Issue was opened via the bug report template. label Dec 12, 2021
@kweiberth
Copy link

I also just tried to bump from v11.0.0 to v12.0.7 and experienced similar increase of about 4kb in first load JS.

@TheThirdRace
Copy link

Same here, from 11.1.2 to 12.0.7, I have an increase of 4KB for 12.0.7 with swcMinify: false.

If I enable swcMinify: true, I add another 4KB to the bundle for a total increase of 8KB in 12.0.7...

@kodiakhq kodiakhq bot closed this as completed in #32730 Dec 22, 2021
kodiakhq bot pushed a commit that referenced this issue Dec 22, 2021
We introduced the `StyleRegistry` on server side to make it concurrent safe for requests. For client we can have only 1 registry since there's only 1 instance per browser window. Keep consistence with previous usage

Closes #32417
Closes #30377

Revert change in #31357, it's not required anymore
@huozhi
Copy link
Member

huozhi commented Dec 22, 2021

Could you please try next@12.0.8-canary.13 to see if it resolves your issue? Thanks 🙏

@TheThirdRace
Copy link

@huozhi
Just tried with next@12.0.8-canary.13 and unfortunately there wasn't any significant difference.

Without swcMinify, the bundle was the same size as with 12.0.7

With swcMinify, the bundle only increased by 3 KB instead of 4 KB with 12.0.7

@huozhi
Copy link
Member

huozhi commented Dec 22, 2021

@TheThirdRace Do you have a minimal reproduction for it?

@LarsBuur does this version solve your problem?

@TheThirdRace
Copy link

@huozhi
What I tried is to change from 12.0.7 to 12.0.8-canary.13 and saw the bundle didn't reduce in size with yarn build.

Unfortunately, I don't have a version at 11.1.2 anymore that would allow you to simply compare directly.

I'll send you an invite to my private repo so you can check it out yourself.

I have a branch nextjs-11-1-2 and a branch nextjs-12-0-7 which were made to show the slower compile time of 12.0.7 compared to 11.1.2 for another thread. Unfortunately, there's more than 1 commit between the 2 branches, meaning it's not just the migration to 12.x.

If you want to validate build size from 11.1.2 to 12.0.7, you'll have to migrate the nextjs-11-1-2 branch to NextJs 12 manually.

@LarsBuur
Copy link
Author

@huozhi. Yes this solves my problem. I see the same bundle size moving from 11.1.2 to 12.0.8-canary.13.

Thank you for your effort.

@huozhi
Copy link
Member

huozhi commented Dec 23, 2021

@TheThirdRace It feels like sth else besides the styled-jsx since it's resolved for the original issue. Would you mind opening another issue with a minimal reproduction with more public visibility so that more people can help on it? 🙏

@kweiberth
Copy link

This didn't solve my bundle size increase. On 11.0.0 first load JS is 98.1kb, and on 12.0.8-canary.13 it is 102kb.

@TheThirdRace
Copy link

@huozhi
I could create a new ticket, but I won't be able to share a reproduction publicly as the repo is private.

And without the code itself, I doubt anyone can really help...

I sent your an invite already for the private repo in case you have time to take a look

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 27, 2022
natew pushed a commit to natew/next.js that referenced this issue Feb 16, 2022
We introduced the `StyleRegistry` on server side to make it concurrent safe for requests. For client we can have only 1 registry since there's only 1 instance per browser window. Keep consistence with previous usage

Closes vercel#32417
Closes vercel#30377

Revert change in vercel#31357, it's not required anymore
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants