Unverified Commit 860c0281 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Add exportPathMap config type/schema field (#39171)

parent b1a5821e
...@@ -30,7 +30,7 @@ import { ...@@ -30,7 +30,7 @@ import {
} from '../shared/lib/constants' } from '../shared/lib/constants'
import loadConfig from '../server/config' import loadConfig from '../server/config'
import { isTargetLikeServerless } from '../server/utils' import { isTargetLikeServerless } from '../server/utils'
import { NextConfigComplete } from '../server/config-shared' import { ExportPathMap, NextConfigComplete } from '../server/config-shared'
import { eventCliSession } from '../telemetry/events' import { eventCliSession } from '../telemetry/events'
import { hasNextSupport } from '../telemetry/ci-info' import { hasNextSupport } from '../telemetry/ci-info'
import { Telemetry } from '../telemetry/storage' import { Telemetry } from '../telemetry/storage'
...@@ -124,10 +124,6 @@ const createProgress = (total: number, label: string) => { ...@@ -124,10 +124,6 @@ const createProgress = (total: number, label: string) => {
} }
} }
type ExportPathMap = {
[page: string]: { page: string; query?: { [key: string]: string } }
}
interface ExportOptions { interface ExportOptions {
outdir: string outdir: string
silent?: boolean silent?: boolean
...@@ -318,7 +314,7 @@ export default async function exportApp( ...@@ -318,7 +314,7 @@ export default async function exportApp(
`No "exportPathMap" found in "${nextConfig.configFile}". Generating map from "./pages"` `No "exportPathMap" found in "${nextConfig.configFile}". Generating map from "./pages"`
) )
} }
nextConfig.exportPathMap = async (defaultMap: ExportPathMap) => { nextConfig.exportPathMap = async (defaultMap) => {
return defaultMap return defaultMap
} }
} }
......
...@@ -391,6 +391,9 @@ const configSchema = { ...@@ -391,6 +391,9 @@ const configSchema = {
}, },
type: 'object', type: 'object',
}, },
exportPathMap: {
isFunction: true,
} as any,
future: { future: {
additionalProperties: false, additionalProperties: false,
properties: {}, properties: {},
......
...@@ -148,11 +148,26 @@ export interface ExperimentalConfig { ...@@ -148,11 +148,26 @@ export interface ExperimentalConfig {
largePageDataBytes?: number largePageDataBytes?: number
} }
export type ExportPathMap = {
[path: string]: { page: string; query?: Record<string, string | string[]> }
}
/** /**
* Next configuration object * Next configuration object
* @see [configuration documentation](https://nextjs.org/docs/api-reference/next.config.js/introduction) * @see [configuration documentation](https://nextjs.org/docs/api-reference/next.config.js/introduction)
*/ */
export interface NextConfig extends Record<string, any> { 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 * Internationalization configuration
* *
......
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