@next/swc is not a development dependency (blowing Heroku slug size)
See original GitHub issueWhat version of Next.js are you using?
12.0.7
What version of Node.js are you using?
14.15.4
What browser are you using?
Chrome
What operating system are you using?
Linux
How are you deploying your application?
Heroku
Describe the Bug
Heroku limits the compressed size of the app folder to 500 MB. Somehow, the total compressed size of the app went from 200 to 600, after upgrading from Next 11 to 12.
After investigating the problem, the issue is that somehow, all the binaries for SWC are included in the build and not removed when running npm prune
.
$ du -ha --max-depth 3 /app | sort -hr | grep @next
481M /app/node_modules/@next
48M /app/node_modules/@next/swc-linux-x64-gnu
48M /app/node_modules/@next/swc-android-arm64
47M /app/node_modules/@next/swc-linux-x64-musl
47M /app/node_modules/@next/swc-linux-arm64-musl
47M /app/node_modules/@next/swc-linux-arm64-gnu
47M /app/node_modules/@next/swc-linux-arm-gnueabihf
44M /app/node_modules/@next/swc-win32-x64-msvc
40M /app/node_modules/@next/swc-win32-arm64-msvc
40M /app/node_modules/@next/swc-darwin-x64
38M /app/node_modules/@next/swc-win32-ia32-msvc
38M /app/node_modules/@next/swc-darwin-arm64
1.8M /app/node_modules/@next/react-dev-overlay
68K /app/node_modules/@next/react-refresh-utils
32K /app/node_modules/@next/env
28K /app/node_modules/@next/polyfill-module
....
The actual problem is that because those are binaries, they barely compress, so they really break the slug size limit of heroku.
Expected Behavior
Given that the build was already completed, I imagine it is unnecessary to have this packages in production. We should allow these packages to be removed by npm prune
.
To Reproduce
Deploy any Next 12 app to Heroku.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Reduce heroku slug size while whitelisting 'serve' and its ...
How to reduce heroku slug size while whitelisting 'serve' and its dependencies ? For now, I'm excluding some big independent packages (e.g. @mui ......
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
For Heroku and NextJS 12.0.7, I had to add the following custom Heroku build steps to
package.json
:Disable SWC compiler because of #31855
Remove SWC and .next/cache to reduce the slug size:
Hope this workaround helps someone.
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.