feat(nextjs): add experimental-build-mode option to support compile only (#26465)
## Current Behavior The nextjs build executor does not support all build flags such as `--experimental-build-mode` (see https://nextjs.org/docs/app/api-reference/next-cli#build). ## Expected Behavior For certain deployment models (e.g. mult-environment builds), it is helpful to only compile but not generate pages at build time. See https://github.com/vercel/next.js/discussions/46544 for a discussion. --------- Co-authored-by: Emily Xiong <xiongemi@gmail.com> Co-authored-by: Craigory Coppola <craigorycoppola@gmail.com>
This commit is contained in:
parent
86412cb99a
commit
0ca7df7495
@ -72,6 +72,11 @@
|
|||||||
"experimentalAppOnly": {
|
"experimentalAppOnly": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Only build 'app' routes"
|
"description": "Only build 'app' routes"
|
||||||
|
},
|
||||||
|
"experimentalBuildMode": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Change the build mode.",
|
||||||
|
"enum": ["compile", "generate"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["outputPath"],
|
"required": ["outputPath"],
|
||||||
|
|||||||
@ -124,13 +124,24 @@ function runCliBuild(
|
|||||||
projectRoot: string,
|
projectRoot: string,
|
||||||
options: NextBuildBuilderOptions
|
options: NextBuildBuilderOptions
|
||||||
) {
|
) {
|
||||||
const { experimentalAppOnly, profile, debug, outputPath } = options;
|
const {
|
||||||
|
experimentalAppOnly,
|
||||||
|
experimentalBuildMode,
|
||||||
|
profile,
|
||||||
|
debug,
|
||||||
|
outputPath,
|
||||||
|
} = options;
|
||||||
|
|
||||||
// Set output path here since it can also be set via CLI
|
// Set output path here since it can also be set via CLI
|
||||||
// We can retrieve it inside plugins/with-nx
|
// We can retrieve it inside plugins/with-nx
|
||||||
process.env.NX_NEXT_OUTPUT_PATH ??= outputPath;
|
process.env.NX_NEXT_OUTPUT_PATH ??= outputPath;
|
||||||
|
|
||||||
const args = createCliOptions({ experimentalAppOnly, profile, debug });
|
const args = createCliOptions({
|
||||||
|
experimentalAppOnly,
|
||||||
|
experimentalBuildMode,
|
||||||
|
profile,
|
||||||
|
debug,
|
||||||
|
});
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
childProcess = fork(
|
childProcess = fork(
|
||||||
require.resolve('next/dist/bin/next'),
|
require.resolve('next/dist/bin/next'),
|
||||||
|
|||||||
@ -69,6 +69,11 @@
|
|||||||
"experimentalAppOnly": {
|
"experimentalAppOnly": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Only build 'app' routes"
|
"description": "Only build 'app' routes"
|
||||||
|
},
|
||||||
|
"experimentalBuildMode": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Change the build mode.",
|
||||||
|
"enum": ["compile", "generate"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["outputPath"],
|
"required": ["outputPath"],
|
||||||
|
|||||||
@ -39,6 +39,7 @@ export interface NextBuildBuilderOptions {
|
|||||||
debug?: boolean;
|
debug?: boolean;
|
||||||
profile?: boolean;
|
profile?: boolean;
|
||||||
experimentalAppOnly?: boolean;
|
experimentalAppOnly?: boolean;
|
||||||
|
experimentalBuildMode?: 'compile' | 'generate';
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface NextServeBuilderOptions {
|
export interface NextServeBuilderOptions {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user