Unverified Commit 2b54a007 authored by Will Binns-Smith's avatar Will Binns-Smith Committed by GitHub

Turbopack builds: Remove canary-gate and add experimental warning (#77808)

parent e69918dc
...@@ -3709,6 +3709,10 @@ export default async function build( ...@@ -3709,6 +3709,10 @@ export default async function build(
// Ensure we wait for lockfile patching if present // Ensure we wait for lockfile patching if present
await lockfilePatchPromise.cur await lockfilePatchPromise.cur
if (isTurbopack && !process.env.__NEXT_TEST_MODE) {
warnAboutTurbopackBuilds(loadedConfig)
}
// Ensure all traces are flushed before finishing the command // Ensure all traces are flushed before finishing the command
await flushAllTraces() await flushAllTraces()
teardownTraceSubscriber() teardownTraceSubscriber()
...@@ -3725,3 +3729,25 @@ export default async function build( ...@@ -3725,3 +3729,25 @@ export default async function build(
} }
} }
} }
function warnAboutTurbopackBuilds(config?: NextConfigComplete) {
let warningStr =
`Support for Turbopack builds is experimental. ` +
bold(
`We don't recommend deploying mission-critical applications to production.`
)
warningStr +=
'\n\n- It is expected that your bundle size might be different from `next build` with webpack. This will be improved as we work towards stability.'
if (!config?.experimental.turbo?.unstablePersistentCaching) {
warningStr +=
'\n- This build is without disk caching; subsequent builds will become faster when disk caching becomes available.'
}
warningStr +=
'\n- When comparing output to webpack builds, make sure to first clear the Next.js cache by deleting the `.next` directory.'
warningStr +=
'\n\nProvide feedback for Turbopack builds at https://github.com/vercel/next.js/discussions/77721'
Log.warn(warningStr)
}
...@@ -19,19 +19,12 @@ import loadConfig from '../../server/config' ...@@ -19,19 +19,12 @@ import loadConfig from '../../server/config'
import { hasCustomExportOutput } from '../../export/utils' import { hasCustomExportOutput } from '../../export/utils'
import { Telemetry } from '../../telemetry/storage' import { Telemetry } from '../../telemetry/storage'
import { setGlobal } from '../../trace' import { setGlobal } from '../../trace'
import { isStableBuild, CanaryOnlyError } from '../../shared/lib/canary-only'
export async function turbopackBuild(): Promise<{ export async function turbopackBuild(): Promise<{
duration: number duration: number
buildTraceContext: undefined buildTraceContext: undefined
shutdownPromise: Promise<void> shutdownPromise: Promise<void>
}> { }> {
if (isStableBuild()) {
throw new CanaryOnlyError(
'Turbopack builds are only available in canary builds of Next.js.'
)
}
await validateTurboNextConfig({ await validateTurboNextConfig({
dir: NextBuildContext.dir!, dir: NextBuildContext.dir!,
isDev: false, isDev: false,
......
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