question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Optimisations no longer applied to `_buildManifest.js` when using SWC

See original GitHub issue

What version of Next.js are you using?

12.0.4-canary.4

What version of Node.js are you using?

16.13.0

What browser are you using?

Chrome

What operating system are you using?

macOS

How are you deploying your application?

Vercel

Describe the Bug

After enabling SWC I noticed that buildManfest.json’s output grew significantly (20kb⇢80kb) because it is no longer using optimisations for chunk names, e.g: self.__BUILD_MANIFEST=function(e,s,a,t,c,o,n,i,r,g,l,b,d,u,p,f,h,m,k)

// With SWC off:
ls -lh .next/static/JdI1kHMMIQ4b_kwr2NZiG/_buildManifest.js

-rw-r--r--  1 benschwarz  staff    26K 11 Nov 18:58 .next/static/JdI1kHMMIQ4b_kwr2NZiG/_buildManifest.js


// With SWC on: 
ls -lh .next/static/dtDJS-Od0qktpqIrQBB_S/_buildManifest.js

-rw-r--r--  1 benschwarz  staff    80K 11 Nov 18:51 .next/static/dtDJS-Od0qktpqIrQBB_S/_buildManifest.js

Over the wire (with Gzip compression) the file size difference isn’t anywhere near as dramatic (Repeated strings are of course optimised by Gzip, so they both end up around 6kb), but there may be an impact to JS parse & compile times, which could compromise main thread performance for sites with many pages.

Expected Behavior

Optimisations should be applied to _buildManifest.js to avoid a potential perf regression.

To Reproduce

  • Run rm -rf .next
  • Run next build
  • Observe size of .next/static/<generatedHash>/_buildManifest.js (small)
  • Run rm -rf .next
  • Turn on SWC using swcMinify: true in next.config.json
  • Run next build
  • Observe size of .next/static/<generatedHash>/_buildManifest.js (large)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
benschwarzcommented, Nov 20, 2021

Confirmed, LGTM on a new build with 12.0.5-canary.6 👍

1reaction
kdy1commented, Nov 12, 2021

Okay, I found the cause. The inliner inlines strings because those are literal, which is ‘simple enough’. I allowed it because the description of the google closure compiler said (in time of porting passes from it) they inline all strings because they focus on the gzipped size, but I can’t find it currently.

I’ll see if google closure compiler still inlines all string.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Next failed to load SWC binary - Stack Overflow
I've tried uninstalling node and reinstalling it again with version 16.13 but without success, on the vercel page, but unsuccessful so far. Any ......
Read more >
Advanced Features: Next.js Compiler
SWC can be used for compilation, minification, bundling, and more – and is designed to be extended. It's something you can call to...
Read more >
Build Options - Vite
If the build is configured to use a non-HTML custom entry via build. ... 'js' is allowed, in which case new URL(dep, import.meta.url)...
Read more >
Measuring Bundle Sizes with Next.js and GitHub Actions
Measuring your Javascript bundle size is an important way to keep client load times low. These days, load times matter for more than...
Read more >
Next.js 12 - Hacker News
We added support for `<style jsx>`, with more React optimizations and ... Next.js bundles with webpack, so it uses SWC in lieu of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found