Unverified Commit d8a60e34 authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

chore: turbopack metadata routes normalizing (#67159)

parent f03fed04
......@@ -131,7 +131,6 @@ export function isStaticMetadataRouteFile(appDirRelativePath: string) {
return isMetadataRouteFile(appDirRelativePath, [], true)
}
// @deprecated
export function isStaticMetadataRoute(page: string) {
return (
page === '/robots' ||
......
......@@ -63,7 +63,7 @@ import {
type TopLevelIssuesMap,
isWellKnownError,
printNonFatalIssue,
normalizeAppMetadataRoutePage,
normalizedPageToTurbopackStructureRoute,
} from './turbopack-utils'
import {
propagateServerField,
......@@ -808,7 +808,7 @@ export async function createHotReloaderTurbopack(
await currentEntriesHandling
const isInsideAppDir = routeDef.bundlePath.startsWith('app/')
const normalizedAppPage = normalizeAppMetadataRoutePage(
const normalizedAppPage = normalizedPageToTurbopackStructureRoute(
page,
extname(routeDef.filename)
)
......
......@@ -520,9 +520,7 @@ export async function handleRouteType({
const type = writtenEndpoint?.type
await manifestLoader.loadAppPathsManifest(
normalizeAppMetadataRoutePage(page, false)
)
await manifestLoader.loadAppPathsManifest(page)
if (type === 'edge') {
await manifestLoader.loadMiddlewareManifest(page, 'app')
......@@ -1000,7 +998,11 @@ export async function handlePagesErrorRoute({
})
}
export function normalizeAppMetadataRoutePage(
// Since turbopack will create app pages/route entries based on the structure,
// which means the entry keys are based on file names.
// But for special metadata conventions we'll change the page/pathname to a different path.
// So we need this helper to map the new path back to original turbopack entry key.
export function normalizedPageToTurbopackStructureRoute(
route: string,
ext: string | false
): string {
......
......@@ -415,17 +415,6 @@ async function startWatcher(opts: SetupOpts) {
pageName,
!!(staticInfo.generateSitemaps || staticInfo.generateImageMetadata)
)
// pageName = pageName.slice(0, -'/route'.length)
// if (pageName.endsWith('/sitemap')) {
// if (staticInfo.generateSitemaps) {
// pageName = `${pageName}/[__metadata_id__]`
// } else {
// pageName = `${pageName}.xml`
// }
// }
// pageName = `${pageName}/route`
}
if (
......
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