Uh oh!
There was an error while loading. Please reload this page.
Fix: Add compatibility for server-external-packages.jsonc in Next.js 16.0 canary+ - #485
Fix: Add compatibility for server-external-packages.jsonc in Next.js 16.0 canary+#485emulienfou wants to merge 4 commits into
Conversation
Supports both .jsonc (16.0-canary+) and .json (older versions)
|
@emulienfou is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
Uh oh!
There was an error while loading. Please reload this page.
| return require( | ||
| require.resolve('next/dist/lib/server-external-packages.json') | ||
| ); | ||
| } |
There was a problem hiding this comment.
need a fallback maybe?
| } | |
| } | |
| return[]; |
There was a problem hiding this comment.
is the JSON.parse(content) necessary? can we simplify the catch block alot more here? #497 seemed to pass before for nextjs-webpack (which is not canary).
Uh oh!
There was an error while loading. Please reload this page.
…s fix issue for this next.js version and above
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
emulienfou
commented
Dec 3, 2025
Seems the fix was wrong, superseded by: #516 |
Fixing:#422
Summary
This PR introduces a compatibility layer to correctly load the
server-external-packageslist across various Next.js versions, specifically addressing the change introduced in Next.js 16.1.0-canary and above.Problem
Newer versions of Next.js (e.g.,
16.1.0-canary+) have switched the file extension for server-external packages from.jsonto.jsonc(as noted in vercel/next.js#86252). This change causes a runtime error when trying to resolve the file in environments using older Next.js versions or when the file resolution is hardcoded to only look for.json.Solution
A new utility function,
loadServerExternalPackages(), has been implemented. This function ensures backward and forward compatibility by:.jsoncextension (next/dist/lib/server-external-packages.jsonc)..jsoncfile is not found (indicating an older Next.js version), it falls back to loading the original.jsonextension (next/dist/lib/server-external-packages.json).This prevents breaks for users running both older and cutting-edge versions of Next.js.