1+ import type { PageRuntime , NextConfigComplete } from '../server/config-shared'
2+ import type { webpack5 } from 'next/dist/compiled/webpack/webpack'
13import fs from 'fs'
24import chalk from 'next/dist/compiled/chalk'
35import { posix , join } from 'path'
@@ -12,11 +14,9 @@ import { MiddlewareLoaderOptions } from './webpack/loaders/next-middleware-loade
1214import { ClientPagesLoaderOptions } from './webpack/loaders/next-client-pages-loader'
1315import { ServerlessLoaderQuery } from './webpack/loaders/next-serverless-loader'
1416import { LoadedEnvFiles } from '@next/env'
15- import { NextConfigComplete } from '../server/config-shared'
1617import { parse } from '../build/swc'
1718import { isCustomErrorPage , isFlightPage , isReservedPage } from './utils'
1819import { ssrEntries } from './webpack/plugins/middleware-plugin'
19- import type { webpack5 } from 'next/dist/compiled/webpack/webpack'
2020import {
2121 MIDDLEWARE_RUNTIME_WEBPACK ,
2222 MIDDLEWARE_SSR_RUNTIME_WEBPACK ,
@@ -99,17 +99,14 @@ type Entrypoints = {
9999 edgeServer : webpack5 . EntryObject
100100}
101101
102- const cachedPageRuntimeConfig = new Map <
103- string ,
104- [ number , 'nodejs' | 'edge' | undefined ]
105- > ( )
102+ const cachedPageRuntimeConfig = new Map < string , [ number , PageRuntime ] > ( )
106103
107104// @TODO : We should limit the maximum concurrency of this function as there
108105// could be thousands of pages existing.
109106export async function getPageRuntime (
110107 pageFilePath : string ,
111108 globalRuntimeFallback ?: 'nodejs' | 'edge'
112- ) : Promise < 'nodejs' | 'edge' | undefined > {
109+ ) : Promise < PageRuntime > {
113110 const cached = cachedPageRuntimeConfig . get ( pageFilePath )
114111 if ( cached ) {
115112 return cached [ 1 ]
@@ -129,7 +126,7 @@ export async function getPageRuntime(
129126 // discussion:
130127 // https://github.com/vercel/next.js/discussions/34179
131128 let isRuntimeRequired : boolean = false
132- let pageRuntime : 'nodejs' | 'edge' | undefined = undefined
129+ let pageRuntime : PageRuntime = undefined
133130
134131 // Since these configurations should always be static analyzable, we can
135132 // skip these cases that "runtime" and "gSP", "gSSP" are not included in the
0 commit comments