A Serverless Function has exceeded the unzipped max size

I am including some large packages in my build, namely rehype-starry-night and @wooorm/starty-night, and it seems to be inflating my build massively.

I can see in the build logs that there is a huge webpack cache being copied in, is there some way to ignore or exclude that? I’m confused about how to reduce this size.

Also, I’m confused why .git would be in there at all.

Hey @adamyonk! I shared some related info in another thread.

Please give those tips a try and let me know how it goes :pray:

1 Like

I think that just removing the .git directory would get these functions under the limit - are there any hooks I can tap into to remove that once the repo is cloned, before that gets unzipped into the different serverless functions?

Using bundle analyzer, here is the client bundle size:
image
And nodejs bundle size:
image

I just don’t understand how this could possibly be breaking a 250MB barrier!

Some more data:

Vercel CLI 39.3.0
WARNING: You should not upload the `.next` directory.
Installing dependencies...

up to date in 425ms

197 packages are looking for funding
  run `npm fund` for details
Detected Next.js version: 15.1.4
Running "npm run build"

> build
> next build

   β–² Next.js 15.1.4
   - Experiments (use with caution):
     Β· turbo

   Creating an optimized production build ...
 βœ“ Compiled successfully
 βœ“ Linting and checking validity of types
 βœ“ Collecting page data
 βœ“ Generating static pages (42/42)
 βœ“ Collecting build traces
 βœ“ Finalizing page optimization

Route (app)                                            Size     First Load JS
β”Œ β—‹ /                                                  258 B           109 kB
β”œ β—‹ /_not-found                                        979 B           106 kB
β”œ ● /[slug]                                            141 B           105 kB
β”œ   β”œ /colophon
β”œ   β”œ /resume
β”œ   β”” /uses
β”œ β—‹ /feed.json                                         141 B           105 kB
β”œ β—‹ /feed.xml                                          141 B           105 kB
β”œ ● /posts/[slug]                                      231 B           109 kB
β”œ   β”œ /posts/2025-01-03-html-search-input
β”œ   β”œ /posts/2019-11-23-raspberry-pi-kiosk
β”œ   β”œ /posts/2018-12-29-screencasting-using-quicktime
β”œ   β”” [+13 more paths]
β”” ● /posts/tagged/[slug]                               258 B           109 kB
    β”œ /posts/tagged/javascript
    β”œ /posts/tagged/gatsby
    β”œ /posts/tagged/tools
    β”” [+13 more paths]
+ First Load JS shared by all                          105 kB
  β”œ chunks/4bd1b696-20882bf820444624.js                52.9 kB
  β”œ chunks/517-4122b31d994211b5.js                     50.5 kB
  β”” other shared chunks (total)                        1.89 kB


β—‹  (Static)  prerendered as static content
●  (SSG)     prerendered as static HTML (uses generateStaticParams)

Traced Next.js server files in: 115.386ms
Created all serverless functions in: 886.539ms
Collected static files (public/, static/, .next/static): 2.171ms
βœ…  Build Completed in .vercel/output [17s]

➜ du -sh .vercel/output
6.8M    .vercel/output