Unverified Commit e3e76a45 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Add experimental compile/generate handling (#49491)

This implements experimental`compile`/`generate` commands to allow
separate the compilation and static generation steps of the build.
Initially this is for testing and follows same experimental rules which
aren't covered by semver.

Note: most changes are just spacing changes so disabling that in the
diff will be helpful.

x-ref: [initial
thread](https://www.notion.so/vercel/bbdbba2016ed464eb5263d325fecc02f?pvs=4)
x-ref: [slack
thread](https://vercel.slack.com/archives/C03DQ3QFV7C/p1676591260523589?thread_ts=1676554904.334789&cid=C03DQ3QFV7C)
parent ef2b8f86
...@@ -62,6 +62,11 @@ if (!foundCommand && args['--help']) { ...@@ -62,6 +62,11 @@ if (!foundCommand && args['--help']) {
} }
const command = foundCommand ? args._[0] : defaultCommand const command = foundCommand ? args._[0] : defaultCommand
if (['experimental-compile', 'experimental-generate'].includes(command)) {
args._.push('--build-mode', command)
}
const forwardedArgs = foundCommand ? args._.slice(1) : args._ const forwardedArgs = foundCommand ? args._.slice(1) : args._
if (args['--inspect']) if (args['--inspect'])
......
...@@ -210,8 +210,12 @@ export default async function build( ...@@ -210,8 +210,12 @@ export default async function build(
runLint = true, runLint = true,
noMangling = false, noMangling = false,
appDirOnly = false, appDirOnly = false,
turboNextBuild = false turboNextBuild = false,
buildMode: 'default' | 'experimental-compile' | 'experimental-generate'
): Promise<void> { ): Promise<void> {
const isCompile = buildMode === 'experimental-compile'
const isGenerate = buildMode === 'experimental-generate'
let hasAppDir = false let hasAppDir = false
try { try {
const nextBuildSpan = trace('next-build', undefined, { const nextBuildSpan = trace('next-build', undefined, {
...@@ -250,9 +254,18 @@ export default async function build( ...@@ -250,9 +254,18 @@ export default async function build(
setGlobal('phase', PHASE_PRODUCTION_BUILD) setGlobal('phase', PHASE_PRODUCTION_BUILD)
setGlobal('distDir', distDir) setGlobal('distDir', distDir)
const buildId: string = await nextBuildSpan let buildId: string = ''
.traceChild('generate-buildid')
.traceAsyncFn(() => generateBuildId(config.generateBuildId, nanoid)) if (isGenerate) {
buildId = await promises.readFile(
path.join(distDir, 'BUILD_ID'),
'utf8'
)
} else {
buildId = await nextBuildSpan
.traceChild('generate-buildid')
.traceAsyncFn(() => generateBuildId(config.generateBuildId, nanoid))
}
NextBuildContext.buildId = buildId NextBuildContext.buildId = buildId
const customRoutes: CustomRoutes = await nextBuildSpan const customRoutes: CustomRoutes = await nextBuildSpan
...@@ -350,7 +363,7 @@ export default async function build( ...@@ -350,7 +363,7 @@ export default async function build(
// For app directory, we run type checking after build. That's because // For app directory, we run type checking after build. That's because
// we dynamically generate types for each layout and page in the app // we dynamically generate types for each layout and page in the app
// directory. // directory.
if (!appDir) await startTypeChecking(typeCheckingOptions) if (!appDir && !isCompile) await startTypeChecking(typeCheckingOptions)
if (appDir && 'exportPathMap' in config) { if (appDir && 'exportPathMap' in config) {
Log.error( Log.error(
...@@ -368,10 +381,17 @@ export default async function build( ...@@ -368,10 +381,17 @@ export default async function build(
eventName: EVENT_BUILD_FEATURE_USAGE, eventName: EVENT_BUILD_FEATURE_USAGE,
payload: buildLintEvent, payload: buildLintEvent,
}) })
let buildSpinner: ReturnType<typeof createSpinner> = {
stopAndPersist() {
return this
},
} as any
const buildSpinner = createSpinner({ if (!isGenerate) {
prefixText: `${Log.prefixes.info} Creating an optimized production build`, buildSpinner = createSpinner({
}) prefixText: `${Log.prefixes.info} Creating an optimized production build`,
})
}
NextBuildContext.buildSpinner = buildSpinner NextBuildContext.buildSpinner = buildSpinner
...@@ -802,7 +822,7 @@ export default async function build( ...@@ -802,7 +822,7 @@ export default async function build(
) )
} }
if (config.cleanDistDir) { if (config.cleanDistDir && !isGenerate) {
await recursiveDelete(distDir, /^cache/) await recursiveDelete(distDir, /^cache/)
} }
...@@ -941,115 +961,118 @@ export default async function build( ...@@ -941,115 +961,118 @@ export default async function build(
return { duration, turbotraceContext: null } return { duration, turbotraceContext: null }
} }
const { duration: webpackBuildDuration, turbotraceContext } = let runTurbotrace = async (_staticPages: Set<string>) => {}
turboNextBuild ? await turbopackBuild() : await webpackBuild()
telemetry.record(
eventBuildCompleted(pagesPaths, {
durationInSeconds: webpackBuildDuration,
totalAppPagesCount,
})
)
let turboTasksForTrace: unknown let turboTasksForTrace: unknown
async function runTurbotrace(staticPages: Set<string>) { if (!isGenerate) {
if (!turbotraceContext) { const { duration: webpackBuildDuration, turbotraceContext } =
return turboNextBuild ? await turbopackBuild() : await webpackBuild()
}
if (
!binding?.isWasm &&
typeof binding.turbo.startTrace === 'function'
) {
let turbotraceOutputPath: string | undefined
let turbotraceFiles: string[] | undefined
turboTasksForTrace = binding.turbo.createTurboTasks(
(config.experimental.turbotrace?.memoryLimit ??
TURBO_TRACE_DEFAULT_MEMORY_LIMIT) *
1024 *
1024
)
const { entriesTrace, chunksTrace } = turbotraceContext telemetry.record(
if (entriesTrace) { eventBuildCompleted(pagesPaths, {
const { durationInSeconds: webpackBuildDuration,
appDir: turbotraceContextAppDir, totalAppPagesCount,
depModArray, })
entryNameMap, )
outputPath,
action,
} = entriesTrace
const depModSet = new Set(depModArray)
const filesTracedInEntries: string[] =
await binding.turbo.startTrace(action, turboTasksForTrace)
const { contextDirectory, input: entriesToTrace } = action runTurbotrace = async function (staticPages: Set<string>) {
if (!turbotraceContext) {
// only trace the assets under the appDir return
// exclude files from node_modules, entries and processed by webpack }
const filesTracedFromEntries = filesTracedInEntries if (
.map((f) => path.join(contextDirectory, f)) !binding?.isWasm &&
.filter( typeof binding.turbo.startTrace === 'function'
(f) => ) {
!f.includes('/node_modules/') && let turbotraceOutputPath: string | undefined
f.startsWith(turbotraceContextAppDir) && let turbotraceFiles: string[] | undefined
!entriesToTrace.includes(f) && turboTasksForTrace = binding.turbo.createTurboTasks(
!depModSet.has(f) (config.experimental.turbotrace?.memoryLimit ??
) TURBO_TRACE_DEFAULT_MEMORY_LIMIT) *
if (filesTracedFromEntries.length) { 1024 *
// The turbo trace doesn't provide the traced file type and reason at present 1024
// let's write the traced files into the first [entry].nft.json )
const [[, entryName]] = Array.from<[string, string]>(
entryNameMap.entries() const { entriesTrace, chunksTrace } = turbotraceContext
).filter(([k]) => k.startsWith(turbotraceContextAppDir)) if (entriesTrace) {
const traceOutputPath = path.join( const {
appDir: turbotraceContextAppDir,
depModArray,
entryNameMap,
outputPath, outputPath,
`../${entryName}.js.nft.json` action,
) } = entriesTrace
const traceOutputDir = path.dirname(traceOutputPath) const depModSet = new Set(depModArray)
const filesTracedInEntries: string[] =
await binding.turbo.startTrace(action, turboTasksForTrace)
const { contextDirectory, input: entriesToTrace } = action
// only trace the assets under the appDir
// exclude files from node_modules, entries and processed by webpack
const filesTracedFromEntries = filesTracedInEntries
.map((f) => path.join(contextDirectory, f))
.filter(
(f) =>
!f.includes('/node_modules/') &&
f.startsWith(turbotraceContextAppDir) &&
!entriesToTrace.includes(f) &&
!depModSet.has(f)
)
if (filesTracedFromEntries.length) {
// The turbo trace doesn't provide the traced file type and reason at present
// let's write the traced files into the first [entry].nft.json
const [[, entryName]] = Array.from<[string, string]>(
entryNameMap.entries()
).filter(([k]) => k.startsWith(turbotraceContextAppDir))
const traceOutputPath = path.join(
outputPath,
`../${entryName}.js.nft.json`
)
const traceOutputDir = path.dirname(traceOutputPath)
turbotraceOutputPath = traceOutputPath turbotraceOutputPath = traceOutputPath
turbotraceFiles = filesTracedFromEntries.map((file) => turbotraceFiles = filesTracedFromEntries.map((file) =>
path.relative(traceOutputDir, file) path.relative(traceOutputDir, file)
) )
}
} }
} if (chunksTrace) {
if (chunksTrace) { const { action, outputPath } = chunksTrace
const { action, outputPath } = chunksTrace action.input = action.input.filter((f: any) => {
action.input = action.input.filter((f: any) => { const outputPagesPath = path.join(outputPath, '..', 'pages')
const outputPagesPath = path.join(outputPath, '..', 'pages') return (
return ( !f.startsWith(outputPagesPath) ||
!f.startsWith(outputPagesPath) || !staticPages.has(
!staticPages.has( // strip `outputPagesPath` and file ext from absolute
// strip `outputPagesPath` and file ext from absolute f.substring(outputPagesPath.length, f.length - 3)
f.substring(outputPagesPath.length, f.length - 3) )
) )
) })
}) await binding.turbo.startTrace(action, turboTasksForTrace)
await binding.turbo.startTrace(action, turboTasksForTrace) if (turbotraceOutputPath && turbotraceFiles) {
if (turbotraceOutputPath && turbotraceFiles) { const existedNftFile = await promises
const existedNftFile = await promises .readFile(turbotraceOutputPath, 'utf8')
.readFile(turbotraceOutputPath, 'utf8') .then((existedContent) => JSON.parse(existedContent))
.then((existedContent) => JSON.parse(existedContent)) .catch(() => ({
.catch(() => ({ version: TRACE_OUTPUT_VERSION,
version: TRACE_OUTPUT_VERSION, files: [],
files: [], }))
})) existedNftFile.files.push(...turbotraceFiles)
existedNftFile.files.push(...turbotraceFiles) const filesSet = new Set(existedNftFile.files)
const filesSet = new Set(existedNftFile.files) existedNftFile.files = [...filesSet]
existedNftFile.files = [...filesSet] await promises.writeFile(
await promises.writeFile( turbotraceOutputPath,
turbotraceOutputPath, JSON.stringify(existedNftFile),
JSON.stringify(existedNftFile), 'utf8'
'utf8' )
) }
} }
} }
} }
} }
// For app directory, we run type checking after build. // For app directory, we run type checking after build.
if (appDir) { if (appDir && !(isCompile || isGenerate)) {
await startTypeChecking(typeCheckingOptions) await startTypeChecking(typeCheckingOptions)
} }
...@@ -1233,6 +1256,16 @@ export default async function build( ...@@ -1233,6 +1256,16 @@ export default async function build(
hasSsrAmpPages, hasSsrAmpPages,
hasNonStaticErrorPage, hasNonStaticErrorPage,
} = await staticCheckSpan.traceAsyncFn(async () => { } = await staticCheckSpan.traceAsyncFn(async () => {
if (isCompile) {
return {
customAppGetInitialProps: false,
namedExports: [],
isNextImageImported: true,
hasSsrAmpPages: !!pagesDir,
hasNonStaticErrorPage: true,
}
}
const { configFileName, publicRuntimeConfig, serverRuntimeConfig } = const { configFileName, publicRuntimeConfig, serverRuntimeConfig } =
config config
const runtimeEnvConfig = { publicRuntimeConfig, serverRuntimeConfig } const runtimeEnvConfig = { publicRuntimeConfig, serverRuntimeConfig }
...@@ -1366,7 +1399,6 @@ export default async function build( ...@@ -1366,7 +1399,6 @@ export default async function build(
let isServerComponent = false let isServerComponent = false
let isHybridAmp = false let isHybridAmp = false
let ssgPageRoutes: string[] | null = null let ssgPageRoutes: string[] | null = null
let pagePath = '' let pagePath = ''
if (pageType === 'pages') { if (pageType === 'pages') {
...@@ -1413,238 +1445,240 @@ export default async function build( ...@@ -1413,238 +1445,240 @@ export default async function build(
? 'edge' ? 'edge'
: staticInfo?.runtime : staticInfo?.runtime
isServerComponent = if (!isCompile) {
pageType === 'app' && isServerComponent =
staticInfo?.rsc !== RSC_MODULE_TYPES.client pageType === 'app' &&
staticInfo?.rsc !== RSC_MODULE_TYPES.client
if (pageType === 'app' || !isReservedPage(page)) {
try {
let edgeInfo: any
if (isEdgeRuntime(pageRuntime)) { if (pageType === 'app' || !isReservedPage(page)) {
if (pageType === 'app') { try {
edgeRuntimeAppCount++ let edgeInfo: any
} else {
edgeRuntimePagesCount++
}
const manifestKey = if (isEdgeRuntime(pageRuntime)) {
pageType === 'pages' ? page : originalAppPath || '' if (pageType === 'app') {
edgeRuntimeAppCount++
} else {
edgeRuntimePagesCount++
}
edgeInfo = middlewareManifest.functions[manifestKey] const manifestKey =
} pageType === 'pages' ? page : originalAppPath || ''
let isPageStaticSpan = edgeInfo = middlewareManifest.functions[manifestKey]
checkPageSpan.traceChild('is-page-static')
let workerResult = await isPageStaticSpan.traceAsyncFn(
() => {
return (
pageType === 'app'
? appStaticWorkers
: pagesStaticWorkers
)!.isPageStatic({
page,
originalAppPath,
distDir,
configFileName,
runtimeEnvConfig,
httpAgentOptions: config.httpAgentOptions,
locales: config.i18n?.locales,
defaultLocale: config.i18n?.defaultLocale,
parentId: isPageStaticSpan.id,
pageRuntime,
edgeInfo,
pageType,
hasServerComponents: !!appDir,
incrementalCacheHandlerPath:
config.experimental.incrementalCacheHandlerPath,
isrFlushToDisk: config.experimental.isrFlushToDisk,
maxMemoryCacheSize:
config.experimental.isrMemoryCacheSize,
nextConfigOutput: config.output,
})
} }
)
if (pageType === 'app' && originalAppPath) { let isPageStaticSpan =
appNormalizedPaths.set(originalAppPath, page) checkPageSpan.traceChild('is-page-static')
// TODO-APP: handle prerendering with edge let workerResult = await isPageStaticSpan.traceAsyncFn(
if (isEdgeRuntime(pageRuntime)) { () => {
isStatic = false return (
isSsg = false pageType === 'app'
} else { ? appStaticWorkers
// If a page has action and it is static, we need to : pagesStaticWorkers
// change it to SSG to keep the worker created. )!.isPageStatic({
// TODO: This is a workaround for now, we should have a page,
// dedicated worker defined in a heuristic way.
const hasAction = entriesWithAction?.has(
'app' + originalAppPath
)
if (
workerResult.encodedPrerenderRoutes &&
workerResult.prerenderRoutes
) {
appStaticPaths.set(
originalAppPath,
workerResult.prerenderRoutes
)
appStaticPathsEncoded.set(
originalAppPath, originalAppPath,
workerResult.encodedPrerenderRoutes distDir,
) configFileName,
ssgPageRoutes = workerResult.prerenderRoutes runtimeEnvConfig,
isSsg = true httpAgentOptions: config.httpAgentOptions,
locales: config.i18n?.locales,
defaultLocale: config.i18n?.defaultLocale,
parentId: isPageStaticSpan.id,
pageRuntime,
edgeInfo,
pageType,
hasServerComponents: !!appDir,
incrementalCacheHandlerPath:
config.experimental.incrementalCacheHandlerPath,
isrFlushToDisk: config.experimental.isrFlushToDisk,
maxMemoryCacheSize:
config.experimental.isrMemoryCacheSize,
nextConfigOutput: config.output,
})
} }
)
const appConfig = workerResult.appConfig || {} if (pageType === 'app' && originalAppPath) {
if (appConfig.revalidate !== 0 && !hasAction) { appNormalizedPaths.set(originalAppPath, page)
const isDynamic = isDynamicRoute(page) // TODO-APP: handle prerendering with edge
const hasGenerateStaticParams = if (isEdgeRuntime(pageRuntime)) {
!!workerResult.prerenderRoutes?.length isStatic = false
isSsg = false
} else {
// If a page has action and it is static, we need to
// change it to SSG to keep the worker created.
// TODO: This is a workaround for now, we should have a
// dedicated worker defined in a heuristic way.
const hasAction = entriesWithAction?.has(
'app' + originalAppPath
)
if ( if (
// Mark the app as static if: workerResult.encodedPrerenderRoutes &&
// - It has no dynamic param workerResult.prerenderRoutes
// - It doesn't have generateStaticParams but `dynamic` is set to
// `error` or `force-static`
!isDynamic
) {
appStaticPaths.set(originalAppPath, [page])
appStaticPathsEncoded.set(originalAppPath, [page])
isStatic = true
} else if (
isDynamic &&
!hasGenerateStaticParams &&
(appConfig.dynamic === 'error' ||
appConfig.dynamic === 'force-static')
) { ) {
appStaticPaths.set(originalAppPath, []) appStaticPaths.set(
appStaticPathsEncoded.set(originalAppPath, []) originalAppPath,
isStatic = true workerResult.prerenderRoutes
)
appStaticPathsEncoded.set(
originalAppPath,
workerResult.encodedPrerenderRoutes
)
ssgPageRoutes = workerResult.prerenderRoutes
isSsg = true
}
const appConfig = workerResult.appConfig || {}
if (appConfig.revalidate !== 0 && !hasAction) {
const isDynamic = isDynamicRoute(page)
const hasGenerateStaticParams =
!!workerResult.prerenderRoutes?.length
if (
// Mark the app as static if:
// - It has no dynamic param
// - It doesn't have generateStaticParams but `dynamic` is set to
// `error` or `force-static`
!isDynamic
) {
appStaticPaths.set(originalAppPath, [page])
appStaticPathsEncoded.set(originalAppPath, [page])
isStatic = true
} else if (
isDynamic &&
!hasGenerateStaticParams &&
(appConfig.dynamic === 'error' ||
appConfig.dynamic === 'force-static')
) {
appStaticPaths.set(originalAppPath, [])
appStaticPathsEncoded.set(originalAppPath, [])
isStatic = true
}
} }
}
if (workerResult.prerenderFallback) { if (workerResult.prerenderFallback) {
// whether or not to allow requests for paths not // whether or not to allow requests for paths not
// returned from generateStaticParams // returned from generateStaticParams
appDynamicParamPaths.add(originalAppPath) appDynamicParamPaths.add(originalAppPath)
}
appDefaultConfigs.set(originalAppPath, appConfig)
} }
appDefaultConfigs.set(originalAppPath, appConfig) } else {
} if (isEdgeRuntime(pageRuntime)) {
} else { if (workerResult.hasStaticProps) {
if (isEdgeRuntime(pageRuntime)) { console.warn(
if (workerResult.hasStaticProps) { `"getStaticProps" is not yet supported fully with "experimental-edge", detected on ${page}`
console.warn( )
`"getStaticProps" is not yet supported fully with "experimental-edge", detected on ${page}` }
) // TODO: add handling for statically rendering edge
// pages and allow edge with Prerender outputs
workerResult.isStatic = false
workerResult.hasStaticProps = false
} }
// TODO: add handling for statically rendering edge
// pages and allow edge with Prerender outputs
workerResult.isStatic = false
workerResult.hasStaticProps = false
}
if ( if (
workerResult.isStatic === false && workerResult.isStatic === false &&
(workerResult.isHybridAmp || workerResult.isAmpOnly) (workerResult.isHybridAmp || workerResult.isAmpOnly)
) { ) {
hasSsrAmpPages = true hasSsrAmpPages = true
} }
if (workerResult.isHybridAmp) { if (workerResult.isHybridAmp) {
isHybridAmp = true isHybridAmp = true
hybridAmpPages.add(page) hybridAmpPages.add(page)
} }
if (workerResult.isNextImageImported) { if (workerResult.isNextImageImported) {
isNextImageImported = true isNextImageImported = true
} }
if (workerResult.hasStaticProps) { if (workerResult.hasStaticProps) {
ssgPages.add(page) ssgPages.add(page)
isSsg = true isSsg = true
if ( if (
workerResult.prerenderRoutes && workerResult.prerenderRoutes &&
workerResult.encodedPrerenderRoutes
) {
additionalSsgPaths.set(
page,
workerResult.prerenderRoutes
)
additionalSsgPathsEncoded.set(
page,
workerResult.encodedPrerenderRoutes workerResult.encodedPrerenderRoutes
) ) {
ssgPageRoutes = workerResult.prerenderRoutes additionalSsgPaths.set(
page,
workerResult.prerenderRoutes
)
additionalSsgPathsEncoded.set(
page,
workerResult.encodedPrerenderRoutes
)
ssgPageRoutes = workerResult.prerenderRoutes
}
if (workerResult.prerenderFallback === 'blocking') {
ssgBlockingFallbackPages.add(page)
} else if (workerResult.prerenderFallback === true) {
ssgStaticFallbackPages.add(page)
}
} else if (workerResult.hasServerProps) {
serverPropsPages.add(page)
} else if (
workerResult.isStatic &&
!isServerComponent &&
(await customAppGetInitialPropsPromise) === false
) {
staticPages.add(page)
isStatic = true
} else if (isServerComponent) {
// This is a static server component page that doesn't have
// gSP or gSSP. We still treat it as a SSG page.
ssgPages.add(page)
isSsg = true
} }
if (workerResult.prerenderFallback === 'blocking') { if (hasPages404 && page === '/404') {
ssgBlockingFallbackPages.add(page) if (
} else if (workerResult.prerenderFallback === true) { !workerResult.isStatic &&
ssgStaticFallbackPages.add(page) !workerResult.hasStaticProps
) {
throw new Error(
`\`pages/404\` ${STATIC_STATUS_PAGE_GET_INITIAL_PROPS_ERROR}`
)
}
// we need to ensure the 404 lambda is present since we use
// it when _app has getInitialProps
if (
(await customAppGetInitialPropsPromise) &&
!workerResult.hasStaticProps
) {
staticPages.delete(page)
}
} }
} else if (workerResult.hasServerProps) {
serverPropsPages.add(page)
} else if (
workerResult.isStatic &&
!isServerComponent &&
(await customAppGetInitialPropsPromise) === false
) {
staticPages.add(page)
isStatic = true
} else if (isServerComponent) {
// This is a static server component page that doesn't have
// gSP or gSSP. We still treat it as a SSG page.
ssgPages.add(page)
isSsg = true
}
if (hasPages404 && page === '/404') {
if ( if (
STATIC_STATUS_PAGES.includes(page) &&
!workerResult.isStatic && !workerResult.isStatic &&
!workerResult.hasStaticProps !workerResult.hasStaticProps
) { ) {
throw new Error( throw new Error(
`\`pages/404\` ${STATIC_STATUS_PAGE_GET_INITIAL_PROPS_ERROR}` `\`pages${page}\` ${STATIC_STATUS_PAGE_GET_INITIAL_PROPS_ERROR}`
) )
} }
// we need to ensure the 404 lambda is present since we use
// it when _app has getInitialProps
if (
(await customAppGetInitialPropsPromise) &&
!workerResult.hasStaticProps
) {
staticPages.delete(page)
}
} }
} catch (err) {
if ( if (
STATIC_STATUS_PAGES.includes(page) && !isError(err) ||
!workerResult.isStatic && err.message !== 'INVALID_DEFAULT_EXPORT'
!workerResult.hasStaticProps )
) { throw err
throw new Error( invalidPages.add(page)
`\`pages${page}\` ${STATIC_STATUS_PAGE_GET_INITIAL_PROPS_ERROR}`
)
}
} }
} catch (err) {
if (
!isError(err) ||
err.message !== 'INVALID_DEFAULT_EXPORT'
)
throw err
invalidPages.add(page)
} }
}
if (pageType === 'app') { if (pageType === 'app') {
if (isSsg || isStatic) { if (isSsg || isStatic) {
staticAppPagesCount++ staticAppPagesCount++
} else { } else {
serverAppPagesCount++ serverAppPagesCount++
}
} }
} }
...@@ -1720,7 +1754,7 @@ export default async function build( ...@@ -1720,7 +1754,7 @@ export default async function build(
'next-server.js.nft.json' 'next-server.js.nft.json'
) )
if (config.outputFileTracing) { if (!isGenerate && config.outputFileTracing) {
let nodeFileTrace: any let nodeFileTrace: any
if (config.experimental.turbotrace) { if (config.experimental.turbotrace) {
if (!binding?.isWasm) { if (!binding?.isWasm) {
...@@ -2231,10 +2265,11 @@ export default async function build( ...@@ -2231,10 +2265,11 @@ export default async function build(
// - getStaticProps paths // - getStaticProps paths
// - experimental app is enabled // - experimental app is enabled
if ( if (
combinedPages.length > 0 || !isCompile &&
useStatic404 || (combinedPages.length > 0 ||
useDefaultStatic500 || useStatic404 ||
isAppDirEnabled useDefaultStatic500 ||
isAppDirEnabled)
) { ) {
const staticGenerationSpan = const staticGenerationSpan =
nextBuildSpan.traceChild('static-generation') nextBuildSpan.traceChild('static-generation')
......
...@@ -18,6 +18,7 @@ const nextBuild: CliCommand = (argv) => { ...@@ -18,6 +18,7 @@ const nextBuild: CliCommand = (argv) => {
'--no-mangling': Boolean, '--no-mangling': Boolean,
'--experimental-app-only': Boolean, '--experimental-app-only': Boolean,
'--experimental-turbo': Boolean, '--experimental-turbo': Boolean,
'--build-mode': String,
// Aliases // Aliases
'-h': '--help', '-h': '--help',
'-d': '--debug', '-d': '--debug',
...@@ -78,7 +79,8 @@ const nextBuild: CliCommand = (argv) => { ...@@ -78,7 +79,8 @@ const nextBuild: CliCommand = (argv) => {
!args['--no-lint'], !args['--no-lint'],
args['--no-mangling'], args['--no-mangling'],
args['--experimental-app-only'], args['--experimental-app-only'],
args['--experimental-turbo'] args['--experimental-turbo'],
args['--build-mode'] || 'default'
).catch((err) => { ).catch((err) => {
console.error('') console.error('')
if ( if (
......
...@@ -9,4 +9,8 @@ export const commands: { [command: string]: () => Promise<CliCommand> } = { ...@@ -9,4 +9,8 @@ export const commands: { [command: string]: () => Promise<CliCommand> } = {
telemetry: () => telemetry: () =>
Promise.resolve(require('../cli/next-telemetry').nextTelemetry), Promise.resolve(require('../cli/next-telemetry').nextTelemetry),
info: () => Promise.resolve(require('../cli/next-info').nextInfo), info: () => Promise.resolve(require('../cli/next-info').nextInfo),
'experimental-compile': () =>
Promise.resolve(require('../cli/next-build').nextBuild),
'experimental-generate': () =>
Promise.resolve(require('../cli/next-build').nextBuild),
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment