Skip to content
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
8 changes: 6 additions & 2 deletions test/development/lockfile/lockfile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import execa from 'execa'
import stripAnsi from 'strip-ansi'

describe('lockfile', () => {
const { next, isTurbopack } = nextTestSetup({
const { next, isTurbopack, isRspack } = nextTestSetup({
files: __dirname,
})

Expand All @@ -13,7 +13,11 @@ describe('lockfile', () => {

const { stdout, stderr, exitCode } = await execa(
'pnpm',
['next', 'dev', isTurbopack ? '--turbopack' : '--webpack'],
[
'next',
'dev',
...(isRspack ? [] : [isTurbopack ? '--turbopack' : '--webpack']),
],
Copy link
Contributor

Choose a reason for hiding this comment

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

When running with rspack (isRspack is true), the environment variable NEXT_RSPACK is not passed to the spawned next dev process, causing it to default to turbopack instead of using rspack like the first instance.

View Details
📝 Patch Details
diff --git a/test/development/lockfile/lockfile.test.ts b/test/development/lockfile/lockfile.test.ts
index 6852de600e..272e0a8441 100644
--- a/test/development/lockfile/lockfile.test.ts
+++ b/test/development/lockfile/lockfile.test.ts
@@ -20,7 +20,10 @@ describe('lockfile', () => {
       ],
       {
         cwd: next.testDir,
-        env: next.env as NodeJS.ProcessEnv,
+        env: {
+          ...next.env,
+          ...(isRspack ? { NEXT_RSPACK: '1' } : {}),
+        } as NodeJS.ProcessEnv,
         reject: false,
       }
     )

Analysis

Inconsistent bundler selection in lockfile test when isRspack is enabled

What fails: In test/development/lockfile/lockfile.test.ts, when isRspack is true (tests run with NEXT_RSPACK=1), the spawned next dev process doesn't receive the NEXT_RSPACK environment variable, causing it to default to turbopack instead of rspack.

How to reproduce:

NEXT_TEST_USE_RSPACK=1 pnpm test test/development/lockfile/lockfile.test.ts

Result: The first Next.js instance (started by nextTestSetup) uses rspack because NextDevInstance.start() merges process.env with this.env, inheriting NEXT_RSPACK. The second instance spawned via execa only receives next.env (which doesn't include NEXT_RSPACK), so parseBundlerArgs() in packages/next/src/lib/bundler.ts defaults to turbopack when no bundler flags are set and process.env.NEXT_RSPACK is missing.

Expected: Both instances should use the same bundler (rspack) to maintain test consistency and avoid masking bundler-specific issues. Per the logic in bundler.ts lines 55-57, when NEXT_RSPACK is set, Rspack should be selected.

{
cwd: next.testDir,
env: next.env as NodeJS.ProcessEnv,
Expand Down
Loading