Skip to content

Turbopack build: Replace process.env.TURBOPACK usage #77783

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/next/next-runtime.webpack-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ module.exports = ({ dev, turbo, bundleType, experimental, ...rest }) => {
experimental ? true : false
),
'process.env.NEXT_RUNTIME': JSON.stringify('nodejs'),
'process.turbopack': JSON.stringify(turbo),
'process.env.TURBOPACK': JSON.stringify(turbo),
}),
!!process.env.ANALYZE &&
Expand Down
1 change: 0 additions & 1 deletion packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2274,7 +2274,6 @@ export default async function build(

// @ts-expect-error internal field TODO: fix this, should use a separate mechanism to pass the info.
isExperimentalCompile: isCompileMode,
isTurbopackBuild: isTurbopack,
},
},
appDir: dir,
Expand Down
10 changes: 0 additions & 10 deletions packages/next/src/cli/next-start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,6 @@ const nextStart = async (options: NextStartOptions, directory?: string) => {
printAndExit(getReservedPortExplanation(port), 1)
}

const isTurbopack = Boolean(
options.turbo ||
options.turbopack ||
// TODO: Used for Testing in Next.js CI. Rename to something better like `NEXT_TEST_TURBOPACK`.
process.env.TURBOPACK
)
if (isTurbopack) {
process.env.TURBOPACK = '1'
}

await startServer({
dir,
isDev: false,
Expand Down
14 changes: 0 additions & 14 deletions packages/next/src/server/next-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,20 +192,6 @@ export default class NextNodeServer extends BaseServer<
this.isDev = isDev
this.sriEnabled = Boolean(options.conf.experimental?.sri?.algorithm)

// @ts-expect-error internal field not publicly exposed
const isTurbopackBuild = this.nextConfig.experimental?.isTurbopackBuild
if (!isDev && typeof isTurbopackBuild !== 'undefined') {
if (process.env.TURBOPACK && !isTurbopackBuild) {
throw new Error(
`Invariant: --turbopack is set but the build used Webpack`
)
} else if (!process.env.TURBOPACK && isTurbopackBuild) {
throw new Error(
`Invariant: --turbopack is not set but the build used Turbopack. Add --turbopack to "next start".`
)
}
}

/**
* This sets environment variable to be used at the time of SSR by head.tsx.
* Using this from process.env allows targeting SSR by calling
Expand Down
3 changes: 0 additions & 3 deletions packages/next/src/server/next.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,6 @@ export class NextServer implements NextWrapperServer {
// @ts-expect-error internal field
config.experimental.isExperimentalCompile =
serializedConfig.experimental.isExperimentalCompile
// @ts-expect-error internal field
config.experimental.isTurbopackBuild =
serializedConfig.experimental.isTurbopackBuild
} catch (_) {
// if distDir is customized we don't know until we
// load the config so fallback to loading the config
Expand Down
8 changes: 0 additions & 8 deletions test/production/app-dir/turbopack-build-marker/app/layout.tsx

This file was deleted.

3 changes: 0 additions & 3 deletions test/production/app-dir/turbopack-build-marker/app/page.tsx

This file was deleted.

6 changes: 0 additions & 6 deletions test/production/app-dir/turbopack-build-marker/next.config.js

This file was deleted.

This file was deleted.

Loading