| | import type { NextConfigComplete } from '../config-shared' |
| | import type { |
| | AppPageModule, |
| | AppPageRouteModule, |
| | } from '../route-modules/app-page/module' |
| | import type { |
| | AppRouteModule, |
| | AppRouteRouteModule, |
| | } from '../route-modules/app-route/module.compiled' |
| |
|
| | import '../require-hook' |
| | import '../node-environment' |
| |
|
| | import { collectSegments } from '../../build/segment-config/app/app-segments' |
| | import type { StaticPathsResult } from '../../build/static-paths/types' |
| | import { loadComponents } from '../load-components' |
| | import { setHttpClientAndAgentOptions } from '../setup-http-agent-env' |
| | import type { IncrementalCache } from '../lib/incremental-cache' |
| | import { isAppPageRouteModule } from '../route-modules/checks' |
| | import { |
| | checkIsRoutePPREnabled, |
| | type ExperimentalPPRConfig, |
| | } from '../lib/experimental/ppr' |
| | import { InvariantError } from '../../shared/lib/invariant-error' |
| | import { collectRootParamKeys } from '../../build/segment-config/app/collect-root-param-keys' |
| | import { buildAppStaticPaths } from '../../build/static-paths/app' |
| | import { buildPagesStaticPaths } from '../../build/static-paths/pages' |
| | import { createIncrementalCache } from '../../export/helpers/create-incremental-cache' |
| | import { parseAppRoute } from '../../shared/lib/router/routes/app' |
| |
|
| | type RuntimeConfig = { |
| | pprConfig: ExperimentalPPRConfig | undefined |
| | configFileName: string |
| | cacheComponents: boolean |
| | } |
| |
|
| | |
| | |
| | |
| | export async function loadStaticPaths({ |
| | dir, |
| | distDir, |
| | pathname, |
| | config, |
| | httpAgentOptions, |
| | locales, |
| | defaultLocale, |
| | isAppPath, |
| | page, |
| | isrFlushToDisk, |
| | fetchCacheKeyPrefix, |
| | cacheMaxMemorySize, |
| | requestHeaders, |
| | cacheHandler, |
| | cacheHandlers, |
| | cacheLifeProfiles, |
| | nextConfigOutput, |
| | buildId, |
| | authInterrupts, |
| | sriEnabled, |
| | }: { |
| | dir: string |
| | distDir: string |
| | pathname: string |
| | config: RuntimeConfig |
| | httpAgentOptions: NextConfigComplete['httpAgentOptions'] |
| | locales?: readonly string[] |
| | defaultLocale?: string |
| | isAppPath: boolean |
| | page: string |
| | isrFlushToDisk?: boolean |
| | fetchCacheKeyPrefix?: string |
| | cacheMaxMemorySize: number |
| | requestHeaders: IncrementalCache['requestHeaders'] |
| | cacheHandler?: string |
| | cacheHandlers?: NextConfigComplete['cacheHandlers'] |
| | cacheLifeProfiles?: { |
| | [profile: string]: import('../../server/use-cache/cache-life').CacheLife |
| | } |
| | nextConfigOutput: 'standalone' | 'export' | undefined |
| | buildId: string |
| | authInterrupts: boolean |
| | sriEnabled: boolean |
| | }): Promise<StaticPathsResult> { |
| | |
| | |
| | await createIncrementalCache({ |
| | dir, |
| | distDir, |
| | cacheHandler, |
| | cacheHandlers, |
| | requestHeaders, |
| | fetchCacheKeyPrefix, |
| | flushToDisk: isrFlushToDisk, |
| | cacheMaxMemorySize, |
| | }) |
| |
|
| | |
| | setHttpClientAndAgentOptions({ |
| | httpAgentOptions, |
| | }) |
| |
|
| | const components = await loadComponents<AppPageModule | AppRouteModule>({ |
| | distDir, |
| | |
| | page: page || pathname, |
| | isAppPath, |
| | isDev: true, |
| | sriEnabled, |
| | needsManifestsForLegacyReasons: true, |
| | }) |
| |
|
| | if (isAppPath) { |
| | const routeModule = components.routeModule |
| | const segments = await collectSegments( |
| | |
| | |
| | routeModule as AppPageRouteModule | AppRouteRouteModule |
| | ) |
| |
|
| | const route = parseAppRoute(pathname, true) |
| | if (route.dynamicSegments.length === 0) { |
| | throw new InvariantError( |
| | `Expected a dynamic route, but got a static route: ${pathname}` |
| | ) |
| | } |
| |
|
| | const isRoutePPREnabled = |
| | isAppPageRouteModule(routeModule) && |
| | checkIsRoutePPREnabled(config.pprConfig) |
| |
|
| | const rootParamKeys = collectRootParamKeys(routeModule) |
| |
|
| | return buildAppStaticPaths({ |
| | dir, |
| | page: pathname, |
| | route, |
| | cacheComponents: config.cacheComponents, |
| | segments, |
| | distDir, |
| | requestHeaders, |
| | cacheHandler, |
| | cacheLifeProfiles, |
| | isrFlushToDisk, |
| | fetchCacheKeyPrefix, |
| | cacheMaxMemorySize, |
| | ComponentMod: components.ComponentMod, |
| | nextConfigOutput, |
| | isRoutePPREnabled, |
| | buildId, |
| | authInterrupts, |
| | rootParamKeys, |
| | }) |
| | } else if (!components.getStaticPaths) { |
| | |
| | |
| | throw new InvariantError( |
| | `Failed to load page with getStaticPaths for ${pathname}` |
| | ) |
| | } |
| |
|
| | return buildPagesStaticPaths({ |
| | page: pathname, |
| | getStaticPaths: components.getStaticPaths, |
| | configFileName: config.configFileName, |
| | locales, |
| | defaultLocale, |
| | }) |
| | } |
| |
|