Unverified Commit 9d1e94d5 authored by Wyatt Johnson's avatar Wyatt Johnson Committed by GitHub

fix: revert client segment route changes for sub shell generation (#81731)

Reverts changes to the `routes-manifest.json` from #81321. Incorrect
route sorting was causing some routing errors.
parent 382b79bc
...@@ -3103,44 +3103,18 @@ export default async function build( ...@@ -3103,44 +3103,18 @@ export default async function build(
} }
let prefetchDataRoute: string | undefined let prefetchDataRoute: string | undefined
let dynamicRoute = routesManifest.dynamicRoutes.find(
(r) => r.page === route.pathname
)
if (!isAppRouteHandler && isAppPPREnabled) { if (!isAppRouteHandler && isAppPPREnabled) {
prefetchDataRoute = path.posix.join( prefetchDataRoute = path.posix.join(
`${normalizedRoute}${RSC_PREFETCH_SUFFIX}` `${normalizedRoute}${RSC_PREFETCH_SUFFIX}`
) )
// If the dynamic route wasn't found, then we need to create
// it. This ensures that for each fallback shell there's an
// entry in the app routes manifest which enables routing for
// this fallback shell.
if (!dynamicRoute) {
dynamicRoute = pageToRoute(route.pathname)
// This route is not for the internal router, but instead
// for external routers.
dynamicRoute.skipInternalRouting = true
// Push this to the end of the array. The dynamic routes are
// sorted by page later.
routesManifest.dynamicRoutes.push(dynamicRoute)
}
} }
if (!isAppRouteHandler && metadata?.segmentPaths) { if (!isAppRouteHandler && metadata?.segmentPaths) {
// If PPR isn't enabled, then we might not find the dynamic const dynamicRoute = routesManifest.dynamicRoutes.find(
// route by pathname. If that's the case, we need to find the (r) => r.page === page
// route by page. )
if (!dynamicRoute) { if (!dynamicRoute) {
dynamicRoute = routesManifest.dynamicRoutes.find( throw new InvariantError('Dynamic route not found')
(r) => r.page === page
)
// If it can't be found by page, we must throw an error.
if (!dynamicRoute) {
throw new InvariantError('Dynamic route not found')
}
} }
dynamicRoute.prefetchSegmentDataRoutes ??= [] dynamicRoute.prefetchSegmentDataRoutes ??= []
......
...@@ -4,6 +4,8 @@ import * as cheerio from 'cheerio' ...@@ -4,6 +4,8 @@ import * as cheerio from 'cheerio'
describe('sub-shell-generation', () => { describe('sub-shell-generation', () => {
const { next, isNextDev, isNextDeploy } = nextTestSetup({ const { next, isNextDev, isNextDeploy } = nextTestSetup({
files: __dirname, files: __dirname,
// FIXME: re-enable once we've re-enabled the sub-shell generation in Vercel
skipDeployment: true,
}) })
if (isNextDev) { if (isNextDev) {
......
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