Unverified Commit b1cbb4c4 authored by Steven's avatar Steven Committed by GitHub

fix: improve type of `ExportPathMap` (#47676)

This is a new PR with only the typescript changes from previous closed
PR #47628
parent 0a94e222
import type { RemotePattern } from '../shared/lib/image-config'
import type { AppBuildManifest } from './webpack/plugins/app-build-manifest-plugin'
import type { PagesManifest } from './webpack/plugins/pages-manifest-plugin'
import type { NextConfigComplete } from '../server/config-shared'
import type { ExportPathMap, NextConfigComplete } from '../server/config-shared'
import type { MiddlewareManifest } from './webpack/plugins/middleware-plugin'
import type { ActionManifest } from './webpack/plugins/flight-client-entry-plugin'
......@@ -2341,7 +2341,7 @@ export default async function build(
// pages and incremental pages.
// n.b. we cannot handle this above in combinedPages because the dynamic
// page must be in the `pages` array, but not in the mapping.
exportPathMap: (defaultMap: any) => {
exportPathMap: (defaultMap: ExportPathMap) => {
// Dynamically routed pages should be prerendered to be used as
// a client-side skeleton (fallback) while data is being fetched.
// This ensures the end-user never sees a 500 or slow response from the
......@@ -2358,12 +2358,12 @@ export default async function build(
if (i18n) {
defaultMap[`/${i18n.defaultLocale}${page}`] = {
page,
query: { __nextFallback: true },
query: { __nextFallback: 'true' },
}
} else {
defaultMap[page] = {
page,
query: { __nextFallback: true },
query: { __nextFallback: 'true' },
}
}
} else {
......@@ -2432,11 +2432,10 @@ export default async function build(
defaultMap[outputPath] = {
page: defaultMap[page]?.page || page,
query: { __nextLocale: locale },
}
if (isFallback) {
defaultMap[outputPath].query.__nextFallback = true
query: {
__nextLocale: locale,
__nextFallback: isFallback ? 'true' : undefined,
},
}
}
......
......@@ -3,9 +3,11 @@ import type {
AppRouteRouteHandlerContext,
} from '../server/future/route-handlers/app-route-route-handler'
import type { FontManifest, FontConfig } from '../server/font-utils'
import type { DomainLocale, NextConfigComplete } from '../server/config-shared'
import { NextParsedUrlQuery } from '../server/request-meta'
import type {
DomainLocale,
ExportPathMap,
NextConfigComplete,
} from '../server/config-shared'
// `NEXT_PREBUNDLED_REACT` env var is inherited from parent process,
// then override react packages here for export worker.
......@@ -64,10 +66,7 @@ interface AmpValidation {
}
}
interface PathMap {
page: string
query?: NextParsedUrlQuery
}
type PathMap = ExportPathMap[keyof ExportPathMap]
interface ExportPageInput {
path: string
......
......@@ -9,6 +9,7 @@ import {
import { ServerRuntime } from 'next/types'
import { SubresourceIntegrityAlgorithm } from '../build/webpack/plugins/subresource-integrity-plugin'
import { WEB_VITALS } from '../shared/lib/utils'
import type { NextParsedUrlQuery } from './request-meta'
export type NextConfigComplete = Required<NextConfig> & {
images: Required<ImageConfigComplete>
......@@ -241,8 +242,9 @@ export interface ExperimentalConfig {
export type ExportPathMap = {
[path: string]: {
page: string
query?: Record<string, string | string[]>
query?: NextParsedUrlQuery
_isAppDir?: boolean
_isDynamicError?: boolean
}
}
......
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