Skip to content

Commit 54d1203

Browse files
authored
Fix route.replace crash with --debug-build-paths (vercel#90312)
## Summary - Fixes `route.replace is not a function` error when running `next build --debug-build-paths` on projects with parallel routes **Root cause:** Turbopack filters routes at the route level (e.g., `/parallel-test` includes all page entries), while JS route discovery filters at the file path level (e.g., only `app/parallel-test/page.tsx`). This causes the `appPathsManifest` to contain entries (like `/@sidebar/page`) that `mappedAppPages` doesn't have. The unguarded lookup at `mappedAppPages[originalPath].replace(...)` crashes on `undefined`. **Fix:** Added a guard to skip manifest entries that don't exist in `mappedAppPages`. ## Test plan - [x] Verified `next build --debug-build-paths 'app/parallel-test/**/page.tsx'` succeeds on test fixture - [x] Verified other `--debug-build-paths` patterns still work (multi-page, pages-only, etc.)
1 parent 1fedf5b commit 54d1203

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

packages/next/src/build/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2185,7 +2185,10 @@ export default async function build(
21852185
for (const [originalPath, normalizedPath] of Object.entries(
21862186
appPathRoutes
21872187
)) {
2188-
if (normalizedPath === page) {
2188+
if (
2189+
normalizedPath === page &&
2190+
mappedAppPages[originalPath]
2191+
) {
21892192
pagePath = mappedAppPages[originalPath].replace(
21902193
/^private-next-app-dir/,
21912194
''

0 commit comments

Comments
 (0)