diff --git a/packages/next/build/analysis/get-page-static-info.ts b/packages/next/build/analysis/get-page-static-info.ts index 8d7353e74e4d..d27ef9057b1b 100644 --- a/packages/next/build/analysis/get-page-static-info.ts +++ b/packages/next/build/analysis/get-page-static-info.ts @@ -1,4 +1,4 @@ -import { isServerRuntime, ServerRuntime } from '../../server/config-shared' +import { isServerRuntime } from '../../server/config-shared' import type { NextConfig } from '../../server/config-shared' import { extractExportedConstValue, @@ -10,6 +10,7 @@ import { promises as fs } from 'fs' import { tryToParsePath } from '../../lib/try-to-parse-path' import * as Log from '../output/log' import { SERVER_RUNTIME } from '../../lib/constants' +import { ServerRuntime } from '../../types' interface MiddlewareConfig { pathMatcher: RegExp diff --git a/packages/next/build/entries.ts b/packages/next/build/entries.ts index 1e17ff961053..5d757be91e85 100644 --- a/packages/next/build/entries.ts +++ b/packages/next/build/entries.ts @@ -2,7 +2,6 @@ import type { ClientPagesLoaderOptions } from './webpack/loaders/next-client-pag import type { MiddlewareLoaderOptions } from './webpack/loaders/next-middleware-loader' import type { EdgeSSRLoaderQuery } from './webpack/loaders/next-edge-ssr-loader' import type { NextConfigComplete } from '../server/config-shared' -import type { ServerRuntime } from '../server/config-shared' import type { ServerlessLoaderQuery } from './webpack/loaders/next-serverless-loader' import type { webpack5 } from 'next/dist/compiled/webpack/webpack' import type { LoadedEnvFiles } from '@next/env' @@ -38,6 +37,7 @@ import { getPageStaticInfo } from './analysis/get-page-static-info' import { normalizePathSep } from '../shared/lib/page-path/normalize-path-sep' import { normalizePagePath } from '../shared/lib/page-path/normalize-page-path' import { serverComponentRegex } from './webpack/loaders/utils' +import { ServerRuntime } from '../types' type ObjectValue = T extends { [key: string]: infer V } ? V : never diff --git a/packages/next/build/utils.ts b/packages/next/build/utils.ts index 95f8d413a000..e1c1a85900a0 100644 --- a/packages/next/build/utils.ts +++ b/packages/next/build/utils.ts @@ -1,4 +1,4 @@ -import type { NextConfigComplete, ServerRuntime } from '../server/config-shared' +import type { NextConfigComplete } from '../server/config-shared' import '../server/node-polyfill-fetch' import chalk from 'next/dist/compiled/chalk' @@ -27,7 +27,7 @@ import { getRouteMatcher } from '../shared/lib/router/utils/route-matcher' import { isDynamicRoute } from '../shared/lib/router/utils/is-dynamic' import escapePathDelimiters from '../shared/lib/router/utils/escape-path-delimiters' import { findPageFile } from '../server/lib/find-page-file' -import { GetStaticPaths, PageConfig } from 'next/types' +import { GetStaticPaths, PageConfig, ServerRuntime } from 'next/types' import { BuildManifest } from '../server/get-page-files' import { removeTrailingSlash } from '../shared/lib/router/utils/remove-trailing-slash' import { UnwrapPromise } from '../lib/coalesced-function' diff --git a/packages/next/lib/constants.ts b/packages/next/lib/constants.ts index 6571d0fc6254..a7f0d8018b0c 100644 --- a/packages/next/lib/constants.ts +++ b/packages/next/lib/constants.ts @@ -1,4 +1,4 @@ -import type { ServerRuntime } from '../server/config-shared' +import type { ServerRuntime } from '../types' import { join } from '../shared/lib/isomorphic/path' export const NEXT_PROJECT_ROOT = join(__dirname, '..', '..') diff --git a/packages/next/server/app-render.tsx b/packages/next/server/app-render.tsx index e947063a7e82..a659a9218954 100644 --- a/packages/next/server/app-render.tsx +++ b/packages/next/server/app-render.tsx @@ -1,6 +1,6 @@ import type { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'http' import type { LoadComponentsReturnType } from './load-components' -import type { ServerRuntime } from './config-shared' +import type { ServerRuntime } from '../types' import React from 'react' import { ParsedUrlQuery, stringify as stringifyQuery } from 'querystring' diff --git a/packages/next/server/base-server.ts b/packages/next/server/base-server.ts index 78e51f1e708a..072d714c3161 100644 --- a/packages/next/server/base-server.ts +++ b/packages/next/server/base-server.ts @@ -6,11 +6,7 @@ import type { FontManifest } from './font-utils' import type { LoadComponentsReturnType } from './load-components' import type { RouteMatch } from '../shared/lib/router/utils/route-matcher' import type { Params } from '../shared/lib/router/utils/route-matcher' -import type { - NextConfig, - NextConfigComplete, - ServerRuntime, -} from './config-shared' +import type { NextConfig, NextConfigComplete } from './config-shared' import type { NextParsedUrlQuery, NextUrlWithParsedQuery } from './request-meta' import type { ParsedUrlQuery } from 'querystring' import type { RenderOpts, RenderOptsPartial } from './render' @@ -23,7 +19,7 @@ import { normalizeRepeatedSlashes, MissingStaticPage, } from '../shared/lib/utils' -import type { PreviewData } from 'next/types' +import type { PreviewData, ServerRuntime } from 'next/types' import type { PagesManifest } from '../build/webpack/plugins/pages-manifest-plugin' import type { BaseNextRequest, BaseNextResponse } from './base-http' import type { PayloadOptions } from './send-payload' diff --git a/packages/next/server/config-shared.ts b/packages/next/server/config-shared.ts index e0999cba59b5..9c4279f8a69a 100644 --- a/packages/next/server/config-shared.ts +++ b/packages/next/server/config-shared.ts @@ -7,8 +7,7 @@ import { imageConfigDefault, RemotePattern, } from '../shared/lib/image-config' - -export type ServerRuntime = 'nodejs' | 'experimental-edge' | undefined +import { ServerRuntime } from '../types' export type NextConfigComplete = Required & { images: Required diff --git a/packages/next/server/render.tsx b/packages/next/server/render.tsx index 5cbb709c52b4..a58aaae33715 100644 --- a/packages/next/server/render.tsx +++ b/packages/next/server/render.tsx @@ -18,10 +18,14 @@ import type { Redirect } from '../lib/load-custom-routes' import type { NextApiRequestCookies, __ApiPreviewProps } from './api-utils' import type { FontManifest } from './font-utils' import type { LoadComponentsReturnType, ManifestItem } from './load-components' -import type { GetServerSideProps, GetStaticProps, PreviewData } from '../types' +import type { + GetServerSideProps, + GetStaticProps, + PreviewData, + ServerRuntime, +} from '../types' import type { UnwrapPromise } from '../lib/coalesced-function' import type { ReactReadableStream } from './node-web-streams-helper' -import type { ServerRuntime } from './config-shared' import React from 'react' import { StyleRegistry, createStyleRegistry } from 'styled-jsx' diff --git a/packages/next/shared/lib/html-context.ts b/packages/next/shared/lib/html-context.ts index 7770988c9271..f0ee0901ab9f 100644 --- a/packages/next/shared/lib/html-context.ts +++ b/packages/next/shared/lib/html-context.ts @@ -1,5 +1,5 @@ import type { BuildManifest } from '../../server/get-page-files' -import type { ServerRuntime } from '../../server/config-shared' +import type { ServerRuntime } from '../../types' import type { NEXT_DATA } from './utils' import { createContext } from 'react' diff --git a/packages/next/types/index.d.ts b/packages/next/types/index.d.ts index 77afa804317d..25b63fe25533 100644 --- a/packages/next/types/index.d.ts +++ b/packages/next/types/index.d.ts @@ -22,7 +22,8 @@ import { // @ts-ignore This path is generated at build time and conflicts otherwise import next from '../dist/server/next' -import { ServerRuntime } from '../server/config-shared' + +export type ServerRuntime = 'nodejs' | 'experimental-edge' | undefined // @ts-ignore This path is generated at build time and conflicts otherwise export { NextConfig } from '../dist/server/config'