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

swcMinify adds considerably to the bundle size in version 13.0.3 #42847

Closed
1 task done
TheThirdRace opened this issue Nov 13, 2022 · 4 comments
Closed
1 task done

swcMinify adds considerably to the bundle size in version 13.0.3 #42847

TheThirdRace opened this issue Nov 13, 2022 · 4 comments
Labels
bug Issue was opened via the bug report template.

Comments

@TheThirdRace
Copy link

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
Platform: win32
Arch: x64
Version: Windows 10 Pro
Binaries:
Node: 16.15.1
npm: N/A
Yarn: N/A
pnpm: N/A
Relevant packages:
next: 13.0.3
eslint-config-next: 13.0.3
react: 18.2.0
react-dom: 18.2.0

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

Short Story

When migrating from version 13.0.2 to 13.0.3, my bundle size jumped from 217 KB to 253 KB.

This is a 36 KB increase, there's clearly a problem...

Long Story

I just migrated my website from 12.3.3 to 13.0.3.

In 12.3.3, I never activated swcMinify because it always added 2 to 4 KB to my bundle size. Sure, it was faster to build by a whole 2 seconds, but I'd take that 4 KB before the build speed.

Now that 13.x has been released, swcMinify is the default and I activated it to see if I could finally get the same bundle size with faster builds.

To my surprise, my bundle size jumped 36 KB!!! I was already on the fence for 4 KB, 36 is simply unacceptable.

I did some testing:

Version swcMinify = false swcMinify = true
12.3.3 215 KB 217 KB
13.0.0 216 KB 217 KB
13.0.1 216 KB 217 KB
13.0.2 217 KB 218 KB
13.0.3 217 KB 253 KB

As you can see, somehow activating swcMinify always produced higher bundle size. But version 13.0.3 is simply abnormal.

I ran next-bundle-analyzer and I saw a weird difference with version 13.0.3.

While the Stat size values are pretty much the same across the board between 13.0.2 and 13.0.3, the Parsed size and Gzipped size have huge differences.

Parsed size (KB):

Package 13.0.2 13.0.3
@chakra-ui 134.33 188.25
framer-motion 94.96 156.44
@emotion 14.87 26.56

Gzipped size (KB):

Package 13.0.2 13.0.3
@chakra-ui 41.91 48.41
framer-motion 32.44 41.51
@emotion 5.98 7.63

This pattern repeats for all packages. This is where all those extra 36 KB are coming from.

I don't know what exactly changed in swc to have such an impact, but it seems it's not parsing the sources the same way anymore and it's producing way larger files in 13.0.3 as the result.

Going through the PRs for 13.0.3, maybe one of these is the culprit:

Expected Behavior

Hopefully, swcMinify would minify as well as babel did.

But I'd settle with as well as it did in 13.0.2

Link to reproduction - Issues with a link to complete (but minimal) reproduction code will be addressed faster

https://github.com/TheThirdRace/thethirdrace.com.git

To Reproduce

I have a private repo I could give access to a contributor.

Just gives me a heads up in this ticket and I should give access within 12 hours.

The steps to reproduce are simple:

  1. Clone the repo
  2. Checkout branch develop
  3. Run yarn to install dependencies
  4. Run yarn build
  5. You'll see 217 KB because swcMinify is set to false in next.config.js
  6. Modify next.config.js to put swcMinify in comment (default value is true)
  7. Run yarn build
  8. You'll see 253 KB
@TheThirdRace TheThirdRace added the bug Issue was opened via the bug report template. label Nov 13, 2022
@jakejarvis
Copy link
Contributor

Looks like this was fixed in #42790 a couple days ago, hopefully there will be a patch release soon...

@kdy1
Copy link
Member

kdy1 commented Nov 14, 2022

Yes, it's fixed.
Closing as fixed

@kdy1 kdy1 closed this as completed Nov 14, 2022
@TheThirdRace
Copy link
Author

Ah, I see...

I filed the bug after it was fixed so I didn't see an open issue for it, but before any canary build was created so I didn't have the fix...

Talk about good timing 😅

@github-actions
Copy link
Contributor

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 github-actions bot locked as resolved and limited conversation to collaborators Dec 14, 2022
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

No branches or pull requests

3 participants