Skip to content

Commit 7217ec6

Browse files
authored
Add --webpack to pnpm dev for Next 16 (#165)
* Add --webpack to pnpm dev for Next 16 to fix turbo on vercel sandbox * Set project repo to vercel sandbox * Remove turbo flag since next 16 uses it by default * Fix format check failing in ci --------- Co-authored-by: Chris Tate <ctate@users.noreply.github.com>
1 parent f2540d4 commit 7217ec6

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

app/api/tasks/[taskId]/restart-dev/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { eq } from 'drizzle-orm'
55
import { Sandbox } from '@vercel/sandbox'
66
import { getServerSession } from '@/lib/session/get-server-session'
77
import { runCommandInSandbox } from '@/lib/sandbox/commands'
8-
import { detectPackageManager } from '@/lib/sandbox/package-manager'
8+
import { detectPackageManager, getDevCommandArgs } from '@/lib/sandbox/package-manager'
99
import { createTaskLogger } from '@/lib/utils/task-logger'
1010

1111
export async function POST(_request: NextRequest, { params }: { params: Promise<{ taskId: string }> }) {
@@ -72,7 +72,7 @@ export async function POST(_request: NextRequest, { params }: { params: Promise<
7272
// Start the dev server again
7373
const packageManager = await detectPackageManager(sandbox, logger)
7474
const devCommand = packageManager === 'npm' ? 'npm' : packageManager
75-
const devArgs = packageManager === 'npm' ? ['run', 'dev'] : ['dev']
75+
const devArgs = await getDevCommandArgs(sandbox, packageManager)
7676

7777
// Start dev server in detached mode
7878
await sandbox.runCommand({

app/api/tasks/[taskId]/start-sandbox/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { getGitHubUser } from '@/lib/github/client'
88
import { getUserGitHubToken } from '@/lib/github/user-token'
99
import { registerSandbox, unregisterSandbox } from '@/lib/sandbox/sandbox-registry'
1010
import { runCommandInSandbox } from '@/lib/sandbox/commands'
11-
import { detectPackageManager, installDependencies } from '@/lib/sandbox/package-manager'
11+
import { detectPackageManager, installDependencies, getDevCommandArgs } from '@/lib/sandbox/package-manager'
1212
import { createTaskLogger } from '@/lib/utils/task-logger'
1313
import { getMaxSandboxDuration } from '@/lib/db/settings'
1414
import { detectPortFromRepo } from '@/lib/sandbox/port-detection'
@@ -181,7 +181,7 @@ export async function POST(_request: NextRequest, { params }: { params: Promise<
181181

182182
const packageManager = await detectPackageManager(sandbox, logger)
183183
const devCommand = packageManager === 'npm' ? 'npm' : packageManager
184-
const devArgs = packageManager === 'npm' ? ['run', 'dev'] : ['dev']
184+
const devArgs = await getDevCommandArgs(sandbox, packageManager)
185185

186186
// Start dev server in detached mode (runs in background)
187187
await sandbox.runCommand({

app/api/tasks/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { createSandbox } from '@/lib/sandbox/creation'
77
import { executeAgentInSandbox, AgentType } from '@/lib/sandbox/agents'
88
import { pushChangesToBranch, shutdownSandbox } from '@/lib/sandbox/git'
99
import { unregisterSandbox } from '@/lib/sandbox/sandbox-registry'
10-
import { detectPackageManager } from '@/lib/sandbox/package-manager'
10+
import { detectPackageManager, getDevCommandArgs } from '@/lib/sandbox/package-manager'
1111
import { detectPortFromRepo } from '@/lib/sandbox/port-detection'
1212
import { runCommandInSandbox } from '@/lib/sandbox/commands'
1313
import { eq, desc, or, and, isNull } from 'drizzle-orm'
@@ -681,7 +681,7 @@ async function processTask(
681681
// Detect package manager and start dev server
682682
const packageManager = await detectPackageManager(sandbox!, logger)
683683
const devCommand = packageManager === 'npm' ? 'npm' : packageManager
684-
const devArgs = packageManager === 'npm' ? ['run', 'dev'] : ['dev']
684+
const devArgs = await getDevCommandArgs(sandbox!, packageManager)
685685

686686
// Start dev server in detached mode (runs in background)
687687
await sandbox!.runCommand({

lib/sandbox/package-manager.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,11 @@ export async function installDependencies(
8181
return { success: false, error: installResult.error }
8282
}
8383
}
84+
85+
/**
86+
* Gets the appropriate dev command arguments for the given package manager.
87+
* Next.js 16+ uses Turbo by default (not Turbopack), which works on Vercel Sandbox.
88+
*/
89+
export async function getDevCommandArgs(_sandbox: Sandbox, packageManager: 'pnpm' | 'yarn' | 'npm'): Promise<string[]> {
90+
return packageManager === 'npm' ? ['run', 'dev'] : ['dev']
91+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "2.0.0",
44
"private": true,
55
"scripts": {
6-
"dev": "next dev --turbopack",
6+
"dev": "next dev --webpack",
77
"build": "next build --turbopack",
88
"start": "next start",
99
"lint": "eslint",

0 commit comments

Comments
 (0)