Unverified Commit 771e29cb authored by Zack Tanner's avatar Zack Tanner Committed by GitHub

revert changes to process default routes at build (#61241)

Reverts changes from #61173 & #60240 (while leaving the tests that were
added).

There are too many spots where considering `/default` routes as pages
needs to be carefully considered in different runtimes, and it turns out
that it's not actually needed to handle the case that it was originally
added for. I confirmed that the test that added the case it was intended
to fix (`parallel-routes-catchall-default`, along with the unit tests in
`normalize-catchall-routes`) are still passing as expected.
parent b81ce725
...@@ -115,7 +115,6 @@ import { ...@@ -115,7 +115,6 @@ import {
isReservedPage, isReservedPage,
isAppBuiltinNotFoundPage, isAppBuiltinNotFoundPage,
serializePageInfos, serializePageInfos,
isReservedAppPage,
} from './utils' } from './utils'
import type { PageInfo, PageInfos, AppConfig } from './utils' import type { PageInfo, PageInfos, AppConfig } from './utils'
import { writeBuildId } from './write-build-id' import { writeBuildId } from './write-build-id'
...@@ -162,7 +161,6 @@ import type { NextEnabledDirectories } from '../server/base-server' ...@@ -162,7 +161,6 @@ import type { NextEnabledDirectories } from '../server/base-server'
import { hasCustomExportOutput } from '../export/utils' import { hasCustomExportOutput } from '../export/utils'
import { interopDefault } from '../lib/interop-default' import { interopDefault } from '../lib/interop-default'
import { formatDynamicImportPath } from '../lib/format-dynamic-import-path' import { formatDynamicImportPath } from '../lib/format-dynamic-import-path'
import { isDefaultRoute } from '../lib/is-default-route'
import { isInterceptionRouteAppPath } from '../server/future/helpers/interception-routes' import { isInterceptionRouteAppPath } from '../server/future/helpers/interception-routes'
interface ExperimentalBypassForInfo { interface ExperimentalBypassForInfo {
...@@ -934,9 +932,7 @@ export default async function build( ...@@ -934,9 +932,7 @@ export default async function build(
validFileMatcher.isAppRouterPage(absolutePath) || validFileMatcher.isAppRouterPage(absolutePath) ||
// For now we only collect the root /not-found page in the app // For now we only collect the root /not-found page in the app
// directory as the 404 fallback // directory as the 404 fallback
validFileMatcher.isRootNotFound(absolutePath) || validFileMatcher.isRootNotFound(absolutePath),
// Default slots are also valid pages, and need to be considered during path normalization
validFileMatcher.isDefaultSlot(absolutePath),
ignorePartFilter: (part) => part.startsWith('_'), ignorePartFilter: (part) => part.startsWith('_'),
}) })
) )
...@@ -1795,10 +1791,7 @@ export default async function build( ...@@ -1795,10 +1791,7 @@ export default async function build(
pageType === 'app' && pageType === 'app' &&
staticInfo?.rsc !== RSC_MODULE_TYPES.client staticInfo?.rsc !== RSC_MODULE_TYPES.client
if ( if (pageType === 'app' || !isReservedPage(page)) {
(pageType === 'app' && !isReservedAppPage(page)) ||
(pageType === 'pages' && !isReservedPage(page))
) {
try { try {
let edgeInfo: any let edgeInfo: any
...@@ -2499,7 +2492,6 @@ export default async function build( ...@@ -2499,7 +2492,6 @@ export default async function build(
routes.forEach((route) => { routes.forEach((route) => {
if (isDynamicRoute(page) && route === page) return if (isDynamicRoute(page) && route === page) return
if (route === '/_not-found') return if (route === '/_not-found') return
if (isDefaultRoute(page)) return
const { const {
revalidate = appConfig.revalidate ?? false, revalidate = appConfig.revalidate ?? false,
......
...@@ -44,8 +44,6 @@ export function normalizeCatchAllRoutes( ...@@ -44,8 +44,6 @@ export function normalizeCatchAllRoutes(
!appPaths[appPath].some((path) => !appPaths[appPath].some((path) =>
hasMatchedSlots(path, catchAllRoute) 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 // check if appPath is a catch-all OR is not more specific than the catch-all
(isCatchAllRoute(appPath) || !isMoreSpecific(appPath, catchAllRoute)) (isCatchAllRoute(appPath) || !isMoreSpecific(appPath, catchAllRoute))
) { ) {
......
...@@ -84,7 +84,6 @@ import { interopDefault } from '../lib/interop-default' ...@@ -84,7 +84,6 @@ import { interopDefault } from '../lib/interop-default'
import type { PageExtensions } from './page-extensions-type' import type { PageExtensions } from './page-extensions-type'
import { formatDynamicImportPath } from '../lib/format-dynamic-import-path' import { formatDynamicImportPath } from '../lib/format-dynamic-import-path'
import { isInterceptionRouteAppPath } from '../server/future/helpers/interception-routes' import { isInterceptionRouteAppPath } from '../server/future/helpers/interception-routes'
import { isDefaultRoute } from '../lib/is-default-route'
export type ROUTER_TYPE = 'pages' | 'app' export type ROUTER_TYPE = 'pages' | 'app'
...@@ -2124,10 +2123,6 @@ export function isReservedPage(page: string) { ...@@ -2124,10 +2123,6 @@ export function isReservedPage(page: string) {
return RESERVED_PAGE.test(page) return RESERVED_PAGE.test(page)
} }
export function isReservedAppPage(page: string) {
return isDefaultRoute(page)
}
export function isAppBuiltinNotFoundPage(page: string) { export function isAppBuiltinNotFoundPage(page: string) {
return /next[\\/]dist[\\/]client[\\/]components[\\/]not-found-error/.test( return /next[\\/]dist[\\/]client[\\/]components[\\/]not-found-error/.test(
page page
......
...@@ -55,7 +55,6 @@ import isError from '../lib/is-error' ...@@ -55,7 +55,6 @@ import isError from '../lib/is-error'
import { needsExperimentalReact } from '../lib/needs-experimental-react' import { needsExperimentalReact } from '../lib/needs-experimental-react'
import { formatManifest } from '../build/manifests/formatter/format-manifest' import { formatManifest } from '../build/manifests/formatter/format-manifest'
import { validateRevalidate } from '../server/lib/patch-fetch' import { validateRevalidate } from '../server/lib/patch-fetch'
import { isDefaultRoute } from '../lib/is-default-route'
function divideSegments(number: number, segments: number): number[] { function divideSegments(number: number, segments: number): number[] {
const result = [] const result = []
...@@ -565,12 +564,9 @@ export async function exportAppImpl( ...@@ -565,12 +564,9 @@ export async function exportAppImpl(
const filteredPaths = exportPaths.filter( const filteredPaths = exportPaths.filter(
(route) => (route) =>
// Remove default routes -- they don't need to be exported exportPathMap[route]._isAppDir ||
// and are only used for parallel route normalization
!isDefaultRoute(exportPathMap[route].page) &&
(exportPathMap[route]._isAppDir ||
// Remove API routes // Remove API routes
!isAPIRoute(exportPathMap[route].page)) !isAPIRoute(exportPathMap[route].page)
) )
if (filteredPaths.length !== exportPaths.length) { if (filteredPaths.length !== exportPaths.length) {
......
export function isDefaultRoute(value?: string) {
return value?.endsWith('/default')
}
...@@ -127,10 +127,6 @@ export function createValidFileMatcher( ...@@ -127,10 +127,6 @@ export function createValidFileMatcher(
return validExtensionFileRegex.test(filePath) || isMetadataFile(filePath) return validExtensionFileRegex.test(filePath) || isMetadataFile(filePath)
} }
function isDefaultSlot(filePath: string) {
return filePath.endsWith(`default.${pageExtensions[0]}`)
}
function isRootNotFound(filePath: string) { function isRootNotFound(filePath: string) {
if (!appDirPath) { if (!appDirPath) {
return false return false
...@@ -147,6 +143,5 @@ export function createValidFileMatcher( ...@@ -147,6 +143,5 @@ export function createValidFileMatcher(
isAppRouterPage, isAppRouterPage,
isMetadataFile, isMetadataFile,
isRootNotFound, isRootNotFound,
isDefaultSlot,
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment