Recently our team have been having issues moving more pages from SSR to static generation with our Next.js setup.
We have 1256 static pages at the moment and 24 edge function routes.
The static routes are all output to .next/prerender-manifest.json (this is normal Next.js behaviour).
npx wrangler pages deploy copies the contents of the prerender-manifest.json file into each edge function js file as a __PRERENDER_MANIFEST variable. This duplication pushes us over the 25MiB limit for an individual file.
Our prerender-manifest.json comes in at 781KiB, so for me we've got it duplicated 24 times and in theory only need 1 copy of this in the final _worker.js that's generated when executing npx wrangler pages deploy.
Has anyone else come across this before?
Is this intended behaviour or can the duplication be reduced?
Should I raise this instead or as well on https://github.com/cloudflare/workers-sdk?
Expected behavior
A shared __PRERENDER_MANIFEST variable in the final _workers.js
next-on-pages environment related information
System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:30 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6030 CPU: (11) arm64 Apple M3 Pro Memory: 18 GB Shell: /bin/zsh Package Manager Used: npm (10.8.2)
Relevant Packages: @cloudflare/next-on-pages: 1.13.2 vercel: 37.1.0 next: 14.2.5
Description
Observed behavior
Recently our team have been having issues moving more pages from SSR to static generation with our Next.js setup. We have 1256 static pages at the moment and 24 edge function routes. The static routes are all output to
.next/prerender-manifest.json
(this is normal Next.js behaviour).npx wrangler pages deploy
copies the contents of the prerender-manifest.json file into each edge function js file as a__PRERENDER_MANIFEST
variable. This duplication pushes us over the 25MiB limit for an individual file. Our prerender-manifest.json comes in at 781KiB, so for me we've got it duplicated 24 times and in theory only need 1 copy of this in the final_worker.js
that's generated when executingnpx wrangler pages deploy
.Has anyone else come across this before? Is this intended behaviour or can the duplication be reduced? Should I raise this instead or as well on https://github.com/cloudflare/workers-sdk?
Expected behavior
A shared
__PRERENDER_MANIFEST
variable in the final_workers.js
Reproduction
src/app/api/hello/route.ts
tosrc/app/api/hi/route.ts
npm run pages:build
g.__PRERENDER_MANIFEST
.vercel/output/static/_worker.js/__next-on-pages-dist__/functions/api/hello.func.js
.vercel/output/static/_worker.js/__next-on-pages-dist__/functions/api/hi.func.js
Pages Deployment Method
Direct Upload (
wrangler pages publish
or the @cloudflare/pages-action GitHub Action)Pages Deployment ID
No response
Additional Information
No response
Would you like to help?