Repository navigation
fix(@vercel/next): merge next-minimal-server.js.nft.json into server trace for prebuilt deployments - #15677
fix(@vercel/next): merge next-minimal-server.js.nft.json into server trace for prebuilt deployments#15677sleitor wants to merge 3 commits into
Conversation
🦋 Changeset detectedLatest commit: 564f4c0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Warning High Risk — Removes env var check, enabling bundled server path for all deployments — could break builds if bundled server path has issues.
Assessed at 564f4c0. |
| // newer Next.js builds), merge its files into the trace so prebuilt | ||
| // deployments include all necessary vendored files. | ||
| if ( | ||
| !useBundledServer && |
There was a problem hiding this comment.
I actually think we can remove VERCEL_NEXT_BUNDLED_SERVER env check, this was a flag that we used to roll out the bundled server way back when it was new but has been fully rolled out for a long time now.
…trace for prebuilt deployments When using prebuilt deployments (vercel build + vercel deploy --prebuilt) with Turbopack and the Pages Router, vendored context files required by require-hook.js at runtime were missing from the serverless function bundle. The next-server.js.nft.json trace does not include vendored paths that require-hook.js rewrites at runtime. This fix reads next-minimal-server.js.nft.json (when it exists) and merges its files into the server trace, capturing all vendored context files (e.g. head-manager-context.js) that newer Next.js builds produce via Turbopack. The internal VERCEL_NEXT_BUNDLED_SERVER env var is no longer required for prebuilt deployments to get the correct file list. Fixes vercel#15654
|
Done! Removed the Force-pushed the updated commit. |
…ys false after env check removal
|
Good catch! Removed the dead code block — since |
#15688) closes: #15677 closes: #15654 --------- Co-authored-by: Dmitrii Troitskii <[email protected]>
What
When using prebuilt deployments (
vercel build+vercel deploy --prebuilt) with Turbopack and the Pages Router, vendored context files required byrequire-hook.jsat runtime were missing from the serverless function bundle. This causedMODULE_NOT_FOUNDerrors for files likehead-manager-context.json pages usingnext/headornext/error.Root cause
next-server.js.nft.json(the trace used in the non-bundled path) does not include vendored context files thatrequire-hook.jsrewrites at runtime.next-minimal-server.js.nft.json(produced by Turbopack builds) does include all 10 vendored context files, but it was only consumed when the internalVERCEL_NEXT_BUNDLED_SERVER=1env var was set — which is only true on Vercel infrastructure, not duringvercel build.Fix
After reading
next-server.js.nft.json, also attempt to readnext-minimal-server.js.nft.json. If it exists:next-server.js.nft.jsonexists, use it as a fallbackThis is a non-breaking additive change: it only activates when
!useBundledServerand the Next.js version supports bundled server (>= 13.5.4), and silently no-ops ifnext-minimal-server.js.nft.jsonis unavailable.Testing
The fix can be verified by:
vercel build --prod).vercel/output/functions/<func>.func/now includes all 10 vendored context filesVERCEL_NEXT_BUNDLED_SERVER=1 vercel build --prod— both should produce the same vendored file listFixes #15654