apps/docs/content/troubleshooting/edge-function-bundle-size-issues.mdx
The maximum size of a deployed Edge Function depends on how it's bundled:
If your function exceeds the applicable limit, deployment fails with an error such as Function source code exceeds the maximum deployment size.
Use the deno info command to analyze your function's dependencies and total size:
deno info /path/to/function/index.ts
Look for the "size" field in the output to see the total bundle size.
If your bundle is too large, try these strategies:
Review your imports and remove any packages you're not actively using.
Instead of importing entire packages, import only the specific modules you need:
// Good: Import specific submodules
import { specific } from 'npm:package/specific'
// Avoid: Import entire package
import * as everything from 'npm:package'
Consider breaking large functions into smaller, more focused functions. Each function can handle a specific task, reducing the code needed in any single deployment.
Research smaller packages that provide the same functionality. Many NPM packages designed for Node.js include unnecessary polyfills that increase bundle size.
If your function is under 20 MB but exceeds the 5 MB server-side limit, bundle it locally with the Supabase CLI to get the higher limit. Run supabase functions deploy with the --use-docker flag to force local bundling.