Skip to content

Commit

Permalink
Remove default fallback behavior when route group is missing a default
Browse files Browse the repository at this point in the history
  • Loading branch information
ztanner committed Feb 22, 2024
1 parent aafb329 commit 6b478d4
Show file tree
Hide file tree
Showing 15 changed files with 5 additions and 256 deletions.
20 changes: 5 additions & 15 deletions packages/next/src/build/webpack/loaders/next-app-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,22 +450,12 @@ async function createTreeCodeFromPath(
adjacentParallelSegment === 'children'
? ''
: `/${adjacentParallelSegment}`
let defaultPath = await resolver(
`${appDirPrefix}${segmentPath}${actualSegment}/default`
)

if (!defaultPath) {
// no default was found at this segment. Check if the normalized segment resolves a default
// for example: /(level1)/(level2)/default doesn't exist, but /default does
const normalizedDefault = await resolver(
`${appDirPrefix}${normalizeAppPath(
segmentPath
)}/${actualSegment}/default`
)

// if a default is found, use that. Otherwise use the fallback, which will trigger a `notFound()`
defaultPath = normalizedDefault ?? PARALLEL_ROUTE_DEFAULT_PATH
}
// if a default is found, use that. Otherwise use the fallback, which will trigger a `notFound()`
const defaultPath =
(await resolver(
`${appDirPrefix}${segmentPath}${actualSegment}/default`
)) ?? PARALLEL_ROUTE_DEFAULT_PATH

nestedCollectedAsyncImports.push(defaultPath)
props[normalizeParallelKey(adjacentParallelSegment)] = `[
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

9 changes: 0 additions & 9 deletions test/e2e/app-dir/interception-route-groups/app/layout.tsx

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions test/e2e/app-dir/interception-route-groups/app/nested/page.tsx

This file was deleted.

12 changes: 0 additions & 12 deletions test/e2e/app-dir/interception-route-groups/app/page.tsx

This file was deleted.

This file was deleted.

12 changes: 0 additions & 12 deletions test/turbopack-tests-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3563,18 +3563,6 @@
"flakey": [],
"runtimeError": false
},
"test/e2e/app-dir/interception-route-groups/interception-route-groups.test.ts": {
"passed": [
"interception route groups (no default) should use the default fallback (a 404) if there is no custom default page"
],
"failed": [
"interception route groups (with default) should render the root default when a route group doesn't have a default",
"interception route groups (with default) should work when nested a level deeper"
],
"pending": [],
"flakey": [],
"runtimeError": false
},
"test/e2e/app-dir/interception-route-prefetch-cache/interception-route-prefetch-cache.test.ts": {
"passed": [
"interception-route-prefetch-cache runtime = edge should render the correct interception when two distinct layouts share the same path structure",
Expand Down

0 comments on commit 6b478d4

Please sign in to comment.