Unverified Commit 334f3356 authored by Wyatt Johnson's avatar Wyatt Johnson Committed by GitHub

refactor: remove ability to call getStaticPaths from app directory pages (#70477)

We previously supported a legacy mode of exporting a `getStaticPaths`
from app directory pages. This removes that option in favour of
`generateStaticParams`.
parent 80974dfa
...@@ -1227,7 +1227,6 @@ type GenerateParamsResult = { ...@@ -1227,7 +1227,6 @@ type GenerateParamsResult = {
config?: AppConfig config?: AppConfig
isDynamicSegment?: boolean isDynamicSegment?: boolean
segmentPath: string segmentPath: string
getStaticPaths?: GetStaticPaths
generateStaticParams?: GenerateStaticParams generateStaticParams?: GenerateStaticParams
isLayout?: boolean isLayout?: boolean
} }
...@@ -1306,7 +1305,7 @@ export async function collectGenerateParams(tree: LoaderTree) { ...@@ -1306,7 +1305,7 @@ export async function collectGenerateParams(tree: LoaderTree) {
const isDynamicSegment = /^\[.+\]$/.test(page) const isDynamicSegment = /^\[.+\]$/.test(page)
const { generateStaticParams, getStaticPaths } = mod || {} const { generateStaticParams } = mod || {}
if (isDynamicSegment && isClientComponent && generateStaticParams) { if (isDynamicSegment && isClientComponent && generateStaticParams) {
throw new Error( throw new Error(
...@@ -1323,7 +1322,6 @@ export async function collectGenerateParams(tree: LoaderTree) { ...@@ -1323,7 +1322,6 @@ export async function collectGenerateParams(tree: LoaderTree) {
isDynamicSegment, isDynamicSegment,
segmentPath, segmentPath,
config, config,
getStaticPaths: !isClientComponent ? getStaticPaths : undefined,
generateStaticParams: !isClientComponent generateStaticParams: !isClientComponent
? generateStaticParams ? generateStaticParams
: undefined, : undefined,
...@@ -1331,12 +1329,7 @@ export async function collectGenerateParams(tree: LoaderTree) { ...@@ -1331,12 +1329,7 @@ export async function collectGenerateParams(tree: LoaderTree) {
// If the configuration contributes to the static generation, then add it // If the configuration contributes to the static generation, then add it
// to the list. // to the list.
if ( if (result.config || result.generateStaticParams || isDynamicSegment) {
result.config ||
result.generateStaticParams ||
result.getStaticPaths ||
isDynamicSegment
) {
generateParams.push(result) generateParams.push(result)
} }
...@@ -1431,18 +1424,6 @@ export async function buildAppStaticPaths({ ...@@ -1431,18 +1424,6 @@ export async function buildAppStaticPaths({
}, },
}, },
async (): Promise<PartialStaticPathsResult> => { async (): Promise<PartialStaticPathsResult> => {
const pageEntry = generateParams[generateParams.length - 1]
// if the page has legacy getStaticPaths we call it like normal
if (typeof pageEntry?.getStaticPaths === 'function') {
return buildStaticPaths({
page,
configFileName,
getStaticPaths: pageEntry.getStaticPaths,
})
} else {
// if generateStaticParams is being used we iterate over them
// collecting them from each level
let hadAllParamsGenerated = false let hadAllParamsGenerated = false
const buildParams = async ( const buildParams = async (
...@@ -1529,8 +1510,7 @@ export async function buildAppStaticPaths({ ...@@ -1529,8 +1510,7 @@ export async function buildAppStaticPaths({
const supportsStaticGeneration = hadAllParamsGenerated || isProduction const supportsStaticGeneration = hadAllParamsGenerated || isProduction
const supportsPPRFallbacks = const supportsPPRFallbacks = isRoutePPREnabled && isAppPPRFallbacksEnabled
isRoutePPREnabled && isAppPPRFallbacksEnabled
const fallbackMode = dynamicParams const fallbackMode = dynamicParams
? supportsStaticGeneration ? supportsStaticGeneration
...@@ -1570,7 +1550,6 @@ export async function buildAppStaticPaths({ ...@@ -1570,7 +1550,6 @@ export async function buildAppStaticPaths({
return result return result
} }
}
) )
} }
......
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