Skip to content
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

next-upgrade: do not add --turbopack flag when --turbo exists in next dev #71730

Merged
merged 1 commit into from
Oct 23, 2024
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
35 changes: 23 additions & 12 deletions packages/next-codemod/bin/upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,23 +412,34 @@ function isUsingAppDir(projectPath: string): boolean {
*/
async function suggestTurbopack(packageJson: any): Promise<void> {
const devScript: string = packageJson.scripts['dev']
if (devScript?.includes('--turbopack')) return

const responseTurbopack = await prompts(
{
type: 'confirm',
name: 'enable',
message: 'Enable Turbopack for next dev?',
initial: true,
},
{ onCancel }
)

if (!responseTurbopack.enable) {
if (!devScript) {
console.log(
`${pc.red('⨯')} Could not find a "dev" script in your package.json.`
)
return
}

if (devScript.includes('next dev')) {
// covers "--turbopack" as well
if (devScript.includes('--turbo')) {
Comment on lines +424 to +425
Copy link
Member

Choose a reason for hiding this comment

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

Good call to add a comment here. We might need to be more fine-grained here in the future so important to ensure we always handle --turbo and --turbopack

return
}

const responseTurbopack = await prompts(
{
type: 'confirm',
name: 'enable',
message: `Enable Turbopack for ${pc.bold('next dev')}?`,
initial: true,
},
{ onCancel }
)

if (!responseTurbopack.enable) {
return
}

packageJson.scripts['dev'] = devScript.replace(
'next dev',
'next dev --turbopack'
Expand Down
Loading