|
1 | | -import type { NextConfigComplete } from '../server/config-shared' |
| 1 | +import type { NextConfig, NextConfigComplete } from '../server/config-shared' |
2 | 2 | import type { AppBuildManifest } from './webpack/plugins/app-build-manifest-plugin' |
3 | 3 | import type { AssetBinding } from './webpack/loaders/get-module-build-info' |
4 | 4 | import type { GetStaticPaths, PageConfig, ServerRuntime } from 'next/types' |
@@ -67,7 +67,8 @@ import { nodeFs } from '../server/lib/node-fs-methods' |
67 | 67 | import * as ciEnvironment from '../telemetry/ci-info' |
68 | 68 | import { normalizeAppPath } from '../shared/lib/router/utils/app-paths' |
69 | 69 | import { denormalizeAppPagePath } from '../shared/lib/page-path/denormalize-app-path' |
70 | | -// import { AppRouteRouteModule } from '../server/future/route-modules/app-route/module' |
| 70 | +import { needsExperimentalReact } from '../lib/needs-experimental-react' |
| 71 | + |
71 | 72 | const { AppRouteRouteModule } = |
72 | 73 | require('../server/future/route-modules/app-route/module.compiled') as typeof import('../server/future/route-modules/app-route/module') |
73 | 74 |
|
@@ -1826,13 +1827,17 @@ export async function copyTracedFiles( |
1826 | 1827 | pageKeys: readonly string[], |
1827 | 1828 | appPageKeys: readonly string[] | undefined, |
1828 | 1829 | tracingRoot: string, |
1829 | | - serverConfig: { [key: string]: any }, |
| 1830 | + serverConfig: NextConfig, |
1830 | 1831 | middlewareManifest: MiddlewareManifest, |
1831 | | - hasInstrumentationHook: boolean, |
1832 | | - hasAppDir: boolean |
| 1832 | + hasInstrumentationHook: boolean |
1833 | 1833 | ) { |
1834 | 1834 | const outputPath = path.join(distDir, 'standalone') |
1835 | 1835 | let moduleType = false |
| 1836 | + const nextConfig = { |
| 1837 | + ...serverConfig, |
| 1838 | + distDir: `./${path.relative(dir, distDir)}`, |
| 1839 | + } |
| 1840 | + const hasExperimentalReact = needsExperimentalReact(nextConfig) |
1836 | 1841 | try { |
1837 | 1842 | const packageJsonPath = path.join(distDir, '../package.json') |
1838 | 1843 | const packageJson = JSON.parse(await fs.readFile(packageJsonPath, 'utf8')) |
@@ -1956,6 +1961,7 @@ export async function copyTracedFiles( |
1956 | 1961 | 'server.js' |
1957 | 1962 | ) |
1958 | 1963 | await fs.mkdir(path.dirname(serverOutputPath), { recursive: true }) |
| 1964 | + |
1959 | 1965 | await fs.writeFile( |
1960 | 1966 | serverOutputPath, |
1961 | 1967 | `${ |
@@ -1985,17 +1991,12 @@ const currentPort = parseInt(process.env.PORT, 10) || 3000 |
1985 | 1991 | const hostname = process.env.HOSTNAME || '0.0.0.0' |
1986 | 1992 |
|
1987 | 1993 | let keepAliveTimeout = parseInt(process.env.KEEP_ALIVE_TIMEOUT, 10) |
1988 | | -const nextConfig = ${JSON.stringify({ |
1989 | | - ...serverConfig, |
1990 | | - distDir: `./${path.relative(dir, distDir)}`, |
1991 | | - })} |
| 1994 | +const nextConfig = ${JSON.stringify(nextConfig)} |
1992 | 1995 |
|
1993 | 1996 | process.env.__NEXT_PRIVATE_STANDALONE_CONFIG = JSON.stringify(nextConfig) |
1994 | | -process.env.__NEXT_PRIVATE_PREBUNDLED_REACT = ${hasAppDir} |
1995 | | - ? nextConfig.experimental && nextConfig.experimental.serverActions |
1996 | | - ? 'experimental' |
1997 | | - : 'next' |
1998 | | - : ''; |
| 1997 | +process.env.__NEXT_PRIVATE_PREBUNDLED_REACT = ${hasExperimentalReact} |
| 1998 | + ? 'experimental' |
| 1999 | + : 'next' |
1999 | 2000 |
|
2000 | 2001 | require('next') |
2001 | 2002 | const { startServer } = require('next/dist/server/lib/start-server') |
|
0 commit comments