deploying-payload-to-cloudflare
Installation
SKILL.md
Deploying Payload CMS to Cloudflare Workers
Overview
Deploying Payload CMS to Cloudflare Workers often hits the 3 MiB bundle size limit and encounters issues with native dependencies like sharp and @vercel/og. This skill provides a proven strategy to overcome these limitations by pruning unused files and patching imports.
When to Use
- Deploying Payload CMS to Cloudflare Workers.
- Encountering "Bundle size exceeds 3 MiB" errors.
- Encountering "Could not resolve" errors for
sharp,resvg.wasm, oryoga.wasm.
The Strategy
- Build: Use
@opennextjs/cloudflareto build the worker. - Prune: Remove the massive
node_modulesdirectory from the output. The worker bundle (handler.mjs) already contains the necessary code (mostly). - Patch: Replace absolute paths to missing native modules (which were in the pruned
node_modules) with an empty module stub.