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

revert changes to process default routes at build #61241

Merged
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
12 changes: 2 additions & 10 deletions packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ import {
isReservedPage,
isAppBuiltinNotFoundPage,
serializePageInfos,
isReservedAppPage,
} from './utils'
import type { PageInfo, PageInfos, AppConfig } from './utils'
import { writeBuildId } from './write-build-id'
Expand Down Expand Up @@ -162,7 +161,6 @@ import type { NextEnabledDirectories } from '../server/base-server'
import { hasCustomExportOutput } from '../export/utils'
import { interopDefault } from '../lib/interop-default'
import { formatDynamicImportPath } from '../lib/format-dynamic-import-path'
import { isDefaultRoute } from '../lib/is-default-route'
import { isInterceptionRouteAppPath } from '../server/future/helpers/interception-routes'

interface ExperimentalBypassForInfo {
Expand Down Expand Up @@ -934,9 +932,7 @@ export default async function build(
validFileMatcher.isAppRouterPage(absolutePath) ||
// For now we only collect the root /not-found page in the app
// directory as the 404 fallback
validFileMatcher.isRootNotFound(absolutePath) ||
// Default slots are also valid pages, and need to be considered during path normalization
validFileMatcher.isDefaultSlot(absolutePath),
validFileMatcher.isRootNotFound(absolutePath),
ignorePartFilter: (part) => part.startsWith('_'),
})
)
Expand Down Expand Up @@ -1795,10 +1791,7 @@ export default async function build(
pageType === 'app' &&
staticInfo?.rsc !== RSC_MODULE_TYPES.client

if (
(pageType === 'app' && !isReservedAppPage(page)) ||
(pageType === 'pages' && !isReservedPage(page))
) {
if (pageType === 'app' || !isReservedPage(page)) {
try {
let edgeInfo: any

Expand Down Expand Up @@ -2499,7 +2492,6 @@ export default async function build(
routes.forEach((route) => {
if (isDynamicRoute(page) && route === page) return
if (route === '/_not-found') return
if (isDefaultRoute(page)) return

const {
revalidate = appConfig.revalidate ?? false,
Expand Down
2 changes: 0 additions & 2 deletions packages/next/src/build/normalize-catchall-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ export function normalizeCatchAllRoutes(
!appPaths[appPath].some((path) =>
hasMatchedSlots(path, catchAllRoute)
) &&
// check if the catch-all is not already matched by a default route or page route
!appPaths[`${appPath}/default`] &&
// check if appPath is a catch-all OR is not more specific than the catch-all
(isCatchAllRoute(appPath) || !isMoreSpecific(appPath, catchAllRoute))
) {
Expand Down
5 changes: 0 additions & 5 deletions packages/next/src/build/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ import { interopDefault } from '../lib/interop-default'
import type { PageExtensions } from './page-extensions-type'
import { formatDynamicImportPath } from '../lib/format-dynamic-import-path'
import { isInterceptionRouteAppPath } from '../server/future/helpers/interception-routes'
import { isDefaultRoute } from '../lib/is-default-route'

export type ROUTER_TYPE = 'pages' | 'app'

Expand Down Expand Up @@ -2124,10 +2123,6 @@ export function isReservedPage(page: string) {
return RESERVED_PAGE.test(page)
}

export function isReservedAppPage(page: string) {
return isDefaultRoute(page)
}

export function isAppBuiltinNotFoundPage(page: string) {
return /next[\\/]dist[\\/]client[\\/]components[\\/]not-found-error/.test(
page
Expand Down
10 changes: 3 additions & 7 deletions packages/next/src/export/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ import isError from '../lib/is-error'
import { needsExperimentalReact } from '../lib/needs-experimental-react'
import { formatManifest } from '../build/manifests/formatter/format-manifest'
import { validateRevalidate } from '../server/lib/patch-fetch'
import { isDefaultRoute } from '../lib/is-default-route'

function divideSegments(number: number, segments: number): number[] {
const result = []
Expand Down Expand Up @@ -565,12 +564,9 @@ export async function exportAppImpl(

const filteredPaths = exportPaths.filter(
(route) =>
// Remove default routes -- they don't need to be exported
// and are only used for parallel route normalization
!isDefaultRoute(exportPathMap[route].page) &&
(exportPathMap[route]._isAppDir ||
// Remove API routes
!isAPIRoute(exportPathMap[route].page))
exportPathMap[route]._isAppDir ||
// Remove API routes
!isAPIRoute(exportPathMap[route].page)
)

if (filteredPaths.length !== exportPaths.length) {
Expand Down
3 changes: 0 additions & 3 deletions packages/next/src/lib/is-default-route.ts

This file was deleted.

5 changes: 0 additions & 5 deletions packages/next/src/server/lib/find-page-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,6 @@ export function createValidFileMatcher(
return validExtensionFileRegex.test(filePath) || isMetadataFile(filePath)
}

function isDefaultSlot(filePath: string) {
return filePath.endsWith(`default.${pageExtensions[0]}`)
}

function isRootNotFound(filePath: string) {
if (!appDirPath) {
return false
Expand All @@ -147,6 +143,5 @@ export function createValidFileMatcher(
isAppRouterPage,
isMetadataFile,
isRootNotFound,
isDefaultSlot,
}
}
Loading