Error: Failed to publish your Function. Got error: Your Functions script is over the 1 MiB size limi
Hey there! I'm looking at a couple of providers for hosting a somewhat large Nextjs 13 application. Vercel's pricing doesn't scale too well so was looking at using cloudflare workers (pages). I'm relatively new with cloudflare, so bare with me 😄
So I know that Vercel has edge functions and I believe that they piggyback off cloudflare. So my question is, how come I can host my application on vercel (free) but not on cloudflare (free). I also recognise that there is a 1Mb size limit for the worker (?) - where do I actually find out how big the file is (locally if possible)? I've got ~50 pages and the same number of api's (which I've converted to edge compatible functions). No single function is taking up more than 120kb in size. When I do - npx @cloudflare/next-on-pages --experimental-minify and check the .vercel/output/static/worker.js/ it's around 6mb - is this what I should be looking at or is it the index.js, which is 93kb (or something completely different)?
4 Replies
how come I can host my application on vercel (free) but not on cloudflare (free)Each platform monetizes in different ways. Vercel charges you for everything - bandwidth, web analytics, etc. Cloudflare gives you unlimited static asset requests, no bandwidth limit, web analytics for free, etc.
e .vercel/output/static/worker.js/ it's around 6mbThe _worker.js is the one you should be looking at, should be
.vercel/output/static/_worker.js
Workers Paid ($5/month min, includes 10 mil bundled requests) gets you up to 10 MB Workers (but any worker over a MB has a slower cold start, so if you can stay below that, you should).
If you need help trimming it down, I would ask in #next-on-pagesAwesome thanks @Chaika I’ll give it an ask. Tbh I wanted to test the performance without paying to see if it was worth switching from amplify, but I’ll give it a go when I get a chance 🙂
Sure, someone else asked that semi-recently in next-on-pages, answer might help you as well: https://discord.com/channels/595317990191398933/1135899572141568050/1162361308788817920
looks like in 13.4.4 or newer nextjs added a fix to better optimize the output
Oh fantastic! You legend. That’s exactly what I’ve got too cheers