How to fix workers.api.error.script_too_large when deploying Sveltekit to Cloudflare pages

366 Views Asked by At

I've been working on a sveltekit blog using mdsvex. The .md files have svelte components. I now have more than 200 posts with multiple components each.

Everything was working well, but recently started getting the following error when deploying to Cloudflare pages:

*Your Functions script is over the 1 MiB size limit (workers.api.error.script_too_large) *

I suspect the problem is that the _worker.js inside the cloudflare folder contains all the blog posts info, and it is getting large (although don't know exactly what it does).

I'm using prerender = true, but also tried different options like prerender = false, csr = false, and still getting the same error.

Does anyone know how to solve this?

Should I use something different than mdsvex?

I also tried using the following configs for the adapter

adapter({routes: {
include: ['/*'],
exclude: ['/january/*', '/february/*', '/countdowns/*', '/days/*', '/_worker.js' ]
}
})
0

There are 0 best solutions below