Skip to content

Commit

Permalink
Add exportPathMap config type/schema field
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Jul 29, 2022
1 parent b1a5821 commit 50c5b7e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
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

0 comments on commit 50c5b7e

Please sign in to comment.