Hey! Trying to understand how Edge Functions bundling/deploy works — has anyone hit similar issues?
Context: we have one shared TS module (~4 MB, mostly static data like word lists, asset catalogs) used across multiple Edge Functions. Once we crossed a size threshold, deploys started failing with a vague HTTP 500 (“Function deploy failed due to an internal error”). No parse errors or “too large” message — just a 500 after upload. Smaller functions still deploy fine.
Empirical findings: – Below ~3.85 MB bundle → deploy works – Above ~4 MB → consistent 500 – Removing comments (~450 KB) → deploy works again – Splitting into multiple files (same total size) → no help (limit seems total, not per file) – Minimal entry importing the big module → works; larger entries with same import → fail – Same project, CLI, infra — broke exactly at threshold
Questions:
Is there a real bundle size limit? Docs say 20 MB but we hit issues much earlier.
Has anyone seen similar opaque 500s? Any way to surface the real error?
How do you handle large shared code/data across functions?
– Move static data to Storage/Postgres and fetch at runtime?
– Use dynamic import() to avoid bundling everything?
– Split into smaller functions and route between them?
– Other patterns?
Does Supabase’s Deno bundler tree-shake effectively? We use a global registry referencing everything, so nothing gets removed. Any better patterns?
Are dynamic imports with computed paths (e.g. await import(./mods/${name}.ts)) bundled statically or actually lazy-loaded?
Any insights appreciated 🙏
The user is experiencing deployment failures with Edge Functions when a shared TypeScript module exceeds approximately 4 MB, despite documentation stating a 20 MB limit. They receive an HTTP 500 error without detailed messages. The user seeks clarity on actual bundle size limits, error transparency, and best practices for handling large shared code or data across functions.