Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(flight-manifest-plugin): passthrough intercepting routes in manifest #52958

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -17,6 +17,7 @@ import { getProxiedPluginState } from '../../build-context'
import { nonNullable } from '../../../lib/non-nullable'
import { WEBPACK_LAYERS } from '../../../lib/constants'
import { normalizePagePath } from '../../../shared/lib/page-path/normalize-page-path'
import { normalizeAppPath } from '../../../shared/lib/router/utils/app-paths'

interface Options {
dev: boolean
Expand Down Expand Up @@ -349,10 +350,11 @@ export class ClientReferenceManifestPlugin {
// - app/foo/loading -> app/foo
// - app/foo/page -> app/foo
// - app/(group)/@named/foo/page -> app/foo
const groupName = entryName
.slice(0, entryName.lastIndexOf('/'))
.replace(/\/@[^/]+/g, '')
.replace(/\/\([^/]+\)/g, '')
// - app/(group)/@named/(.)foo/page -> app/(.)foo
const groupName = normalizeAppPath(entryName, [
'loading',
'layout',
]).slice(1)

if (!manifestsPerGroup.has(groupName)) {
manifestsPerGroup.set(groupName, [])
Expand Down
10 changes: 5 additions & 5 deletions packages/next/src/shared/lib/router/utils/app-paths.ts
Expand Up @@ -19,7 +19,10 @@ import { ensureLeadingSlash } from '../../page-path/ensure-leading-slash'
* @param route the app route to normalize
* @returns the normalized pathname
*/
export function normalizeAppPath(route: string) {
export function normalizeAppPath(route: string, extraLeafs?: string[]) {
const DEFAULT_LEAFS = ['page', 'route']
const mergedLeafs = [...(extraLeafs ?? []), ...DEFAULT_LEAFS]

return ensureLeadingSlash(
route.split('/').reduce((pathname, segment, index, segments) => {
// Empty segments are ignored.
Expand All @@ -38,10 +41,7 @@ export function normalizeAppPath(route: string) {
}

// The last segment (if it's a leaf) should be ignored.
if (
(segment === 'page' || segment === 'route') &&
index === segments.length - 1
) {
if (mergedLeafs.includes(segment) && index === segments.length - 1) {
return pathname
}

Expand Down