Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove default fallback behavior when route group is missing a default #62370

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 5 additions & 16 deletions packages/next/src/build/webpack/loaders/next-app-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {
PAGE_SEGMENT_KEY,
} from '../../../shared/lib/segment'
import { getFilesInDir } from '../../../lib/get-files-in-dir'
import { normalizeAppPath } from '../../../shared/lib/router/utils/app-paths'
import type { PageExtensions } from '../../page-extensions-type'
import { PARALLEL_ROUTE_DEFAULT_PATH } from '../../../client/components/parallel-route-default'

Expand Down Expand Up @@ -450,22 +449,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