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) { ...@@ -131,7 +131,6 @@ export function isStaticMetadataRouteFile(appDirRelativePath: string) {
return isMetadataRouteFile(appDirRelativePath, [], true) return isMetadataRouteFile(appDirRelativePath, [], true)
} }
// @deprecated
export function isStaticMetadataRoute(page: string) { export function isStaticMetadataRoute(page: string) {
return ( return (
page === '/robots' || page === '/robots' ||
......
...@@ -63,7 +63,7 @@ import { ...@@ -63,7 +63,7 @@ import {
type TopLevelIssuesMap, type TopLevelIssuesMap,
isWellKnownError, isWellKnownError,
printNonFatalIssue, printNonFatalIssue,
normalizeAppMetadataRoutePage, normalizedPageToTurbopackStructureRoute,
} from './turbopack-utils' } from './turbopack-utils'
import { import {
propagateServerField, propagateServerField,
...@@ -808,7 +808,7 @@ export async function createHotReloaderTurbopack( ...@@ -808,7 +808,7 @@ export async function createHotReloaderTurbopack(
await currentEntriesHandling await currentEntriesHandling
const isInsideAppDir = routeDef.bundlePath.startsWith('app/') const isInsideAppDir = routeDef.bundlePath.startsWith('app/')
const normalizedAppPage = normalizeAppMetadataRoutePage( const normalizedAppPage = normalizedPageToTurbopackStructureRoute(
page, page,
extname(routeDef.filename) extname(routeDef.filename)
) )
......
...@@ -520,9 +520,7 @@ export async function handleRouteType({ ...@@ -520,9 +520,7 @@ export async function handleRouteType({
const type = writtenEndpoint?.type const type = writtenEndpoint?.type
await manifestLoader.loadAppPathsManifest( await manifestLoader.loadAppPathsManifest(page)
normalizeAppMetadataRoutePage(page, false)
)
if (type === 'edge') { if (type === 'edge') {
await manifestLoader.loadMiddlewareManifest(page, 'app') await manifestLoader.loadMiddlewareManifest(page, 'app')
...@@ -1000,7 +998,11 @@ export async function handlePagesErrorRoute({ ...@@ -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, route: string,
ext: string | false ext: string | false
): string { ): string {
......
...@@ -415,17 +415,6 @@ async function startWatcher(opts: SetupOpts) { ...@@ -415,17 +415,6 @@ async function startWatcher(opts: SetupOpts) {
pageName, pageName,
!!(staticInfo.generateSitemaps || staticInfo.generateImageMetadata) !!(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 ( 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