Optimisations no longer applied to `_buildManifest.js` when using SWC
See original GitHub issueWhat 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
innext.config.json
- Run
next build
- Observe size of
.next/static/<generatedHash>/_buildManifest.js
(large)
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Confirmed, LGTM on a new build with 12.0.5-canary.6 👍
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.