Skip to content

Commit a695016

Browse files
nathanschramclaude
andcommitted
fix: handle extensionless manifests and add prefetch-hints
- Fix prettier formatting in changeset - Strip .json extension before matching optional manifests since Next.js defines some constants without it (SUBRESOURCE_INTEGRITY_MANIFEST, DYNAMIC_CSS_MANIFEST, SERVER_REFERENCE_MANIFEST) - Add prefetch-hints to the optional manifest list (new in Next.js 16.2) - All 236 tests pass, tsc clean, prettier clean Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0f9006b commit a695016

2 files changed

Lines changed: 24 additions & 12 deletions

File tree

.changeset/fix-load-manifest-graceful-fallback.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@ generated, so the patched function threw at runtime, crashing dynamic routes wit
1010

1111
Instead of a blanket catch-all, handle only the specific optional manifests from Next.js
1212
`route-module.ts`:
13-
- `react-loadable-manifest.json` (Turbopack per-route, not all routes have dynamic imports)
14-
- `subresource-integrity-manifest.json` (only when `experimental.sri` configured)
15-
- `server-reference-manifest.json` (App Router only)
16-
- `dynamic-css-manifest.json` (Pages Router + Webpack only)
17-
- `fallback-build-manifest.json` (only for `/_error` page)
18-
- `_client-reference-manifest.js` (optional for static metadata routes)
13+
14+
- `react-loadable-manifest` (Turbopack per-route, not all routes have dynamic imports)
15+
- `subresource-integrity-manifest` (only when `experimental.sri` configured)
16+
- `server-reference-manifest` (App Router only)
17+
- `dynamic-css-manifest` (Pages Router + Webpack only)
18+
- `fallback-build-manifest` (only for `/_error` page)
19+
- `prefetch-hints` (new in Next.js 16.2)
20+
- `_client-reference-manifest.js` (optional for static metadata routes, evalManifest)
21+
22+
Manifest matching strips `.json` before comparison since some Next.js constants omit
23+
the extension (`SUBRESOURCE_INTEGRITY_MANIFEST`, `DYNAMIC_CSS_MANIFEST`, etc.).
1924

2025
Unknown manifests still throw to surface genuine errors.
2126

packages/cloudflare/src/cli/build/patches/plugins/load-manifest.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,19 @@ function loadManifest($PATH, $$$ARGS) {
6969
// Known optional manifests \u2014 Next.js loads these with handleMissing: true
7070
// (see vercel/next.js packages/next/src/server/route-modules/route-module.ts).
7171
// Return {} to match Next.js behaviour instead of crashing the worker.
72-
if ($PATH.endsWith("react-loadable-manifest.json") ||
73-
$PATH.endsWith("subresource-integrity-manifest.json") ||
74-
$PATH.endsWith("server-reference-manifest.json") ||
75-
$PATH.endsWith("dynamic-css-manifest.json") ||
76-
$PATH.endsWith("fallback-build-manifest.json")) {
77-
return {};
72+
// Note: Some manifest constants in Next.js omit the .json extension
73+
// (e.g. SUBRESOURCE_INTEGRITY_MANIFEST, DYNAMIC_CSS_MANIFEST), so we
74+
// strip .json before matching to handle both forms.
75+
{
76+
const p = $PATH.replace(/\\.json$/, "");
77+
if (p.endsWith("react-loadable-manifest") ||
78+
p.endsWith("subresource-integrity-manifest") ||
79+
p.endsWith("server-reference-manifest") ||
80+
p.endsWith("dynamic-css-manifest") ||
81+
p.endsWith("fallback-build-manifest") ||
82+
p.endsWith("prefetch-hints")) {
83+
return {};
84+
}
7885
}
7986
throw new Error(\`Unexpected loadManifest(\${$PATH}) call!\`);
8087
}`,

0 commit comments

Comments
 (0)