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

Add exportPathMap config type/schema field #39171

Merged
merged 1 commit into from Jul 29, 2022
Merged
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
8 changes: 2 additions & 6 deletions packages/next/export/index.ts
Expand Up @@ -30,7 +30,7 @@ import {
} from '../shared/lib/constants'
import loadConfig from '../server/config'
import { isTargetLikeServerless } from '../server/utils'
import { NextConfigComplete } from '../server/config-shared'
import { ExportPathMap, NextConfigComplete } from '../server/config-shared'
import { eventCliSession } from '../telemetry/events'
import { hasNextSupport } from '../telemetry/ci-info'
import { Telemetry } from '../telemetry/storage'
Expand Down Expand Up @@ -124,10 +124,6 @@ const createProgress = (total: number, label: string) => {
}
}

type ExportPathMap = {
[page: string]: { page: string; query?: { [key: string]: string } }
}

interface ExportOptions {
outdir: string
silent?: boolean
Expand Down Expand Up @@ -318,7 +314,7 @@ export default async function exportApp(
`No "exportPathMap" found in "${nextConfig.configFile}". Generating map from "./pages"`
)
}
nextConfig.exportPathMap = async (defaultMap: ExportPathMap) => {
nextConfig.exportPathMap = async (defaultMap) => {
return defaultMap
}
}
Expand Down
3 changes: 3 additions & 0 deletions packages/next/server/config-schema.ts
Expand Up @@ -391,6 +391,9 @@ const configSchema = {
},
type: 'object',
},
exportPathMap: {
isFunction: true,
} as any,
future: {
additionalProperties: false,
properties: {},
Expand Down
15 changes: 15 additions & 0 deletions packages/next/server/config-shared.ts
Expand Up @@ -148,11 +148,26 @@ export interface ExperimentalConfig {
largePageDataBytes?: number
}

export type ExportPathMap = {
[path: string]: { page: string; query?: Record<string, string | string[]> }
}

/**
* Next configuration object
* @see [configuration documentation](https://nextjs.org/docs/api-reference/next.config.js/introduction)
*/
export interface NextConfig extends Record<string, any> {
exportPathMap?: (
defaultMap: ExportPathMap,
ctx: {
dev: boolean
dir: string
outDir: string | null
distDir: string
buildId: string
}
) => Promise<ExportPathMap> | ExportPathMap

/**
* Internationalization configuration
*
Expand Down