Skip to content

Conversation

@daviddaytw
Copy link

@daviddaytw daviddaytw commented Oct 21, 2025

Problem

When using vercel-php in modern monorepo setups (Turbo, Next.js, Nuxt, SvelteKit, etc.), deployments fail with:

Error: A Serverless Function has exceeded the unzipped maximum size of 250 MB

Root Cause

The PHP runtime bundles all files from workPath into each serverless function, excluding only:

  • node_modules/**
  • Vercel config files

Modern frameworks generate large build artifacts (.next/, .turbo/, etc.) that weren't common when this runtime was created. These directories get included in every PHP function, causing massive bundle sizes.

Real-World Example

In a Turbo monorepo with Next.js:

  • .next/ folder: 662 MB (mostly webpack cache)
  • Result: Each PHP function tries to bundle this → deployment fails
  • After fix: PHP functions are ~38 MB → deployment succeeds ✅

Solution

Update the default excludeFiles list to exclude common modern build directories:

  • .next/** - Next.js build output
  • .turbo/** - Turbo cache
  • dist/** - Common build output
  • .cache/** - General build caches
  • .nuxt/** - Nuxt.js build
  • .svelte-kit/** - SvelteKit build
  • .output/** - Nitro/Nuxt output

Additional Context

This issue became prominent with the rise of:

  • Monorepo tooling (Turbo, Nx, Rush)
  • Aggressive build caching strategies

// Build outputs and caches
'.next/**',
'.turbo/**',
'dist/**',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with all of them, but dist can be useful. If you need some resources for PHP, for example geoip.json, I think you can place it to data or dist or something like that. Ignoring dist folder can be hidden problem. WDYT?

If someone want to ignore it, you can use excludeFiles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants