Skip to content

[next-dev] Set TURBOPACK env before loading config #82162

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
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
18 changes: 9 additions & 9 deletions packages/next/src/cli/next-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,15 @@ const nextDev = async (
portSource: PortSource,
directory?: string
) => {
const isTurbopack = Boolean(
options.turbo || options.turbopack || process.env.IS_TURBOPACK_TEST
)
if (isTurbopack) {
process.env.TURBOPACK = '1'
}

isTurboSession = isTurbopack
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a test case we can add to ensure we don't regress on this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can replace usage with a util function isTurbopack(), errors when process.env.TURBOPACK is undefined?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which caused the process.env.TURBOPACK conditions within the initial loadConfig calls to be skipped unexpectedly

can we add an E2E that fails from the condition being skipped?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this while adding TURBOPACK condition in find-root.ts (which is used inside loadConfig()) at PR #82164, so I assume it wasn't breaking anything before.

x-ref: https://github.com/vercel/next.js/pull/82164/files#diff-c51e9132b41be3f589dfaae25571fb525f3be95072b9c241f13d3d2c702f28b6R43


dir = getProjectDir(process.env.NEXT_PRIVATE_DEV_DIR || directory)

// Check if pages dir exists and warn if not
Expand Down Expand Up @@ -238,15 +247,6 @@ const nextDev = async (
hostname: host,
}

const isTurbopack = Boolean(
options.turbo || options.turbopack || process.env.IS_TURBOPACK_TEST
)
if (isTurbopack) {
process.env.TURBOPACK = '1'
}

isTurboSession = isTurbopack

const distDir = path.join(dir, config.distDir ?? '.next')
setGlobal('phase', PHASE_DEVELOPMENT_SERVER)
setGlobal('distDir', distDir)
Expand Down
Loading