Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
dc1901a2
Unverified
Commit
dc1901a2
authored
Oct 24, 2024
by
Jiwon Choi
Committed by
GitHub
Oct 24, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
next-upgrade: change `--turbo` to `--turbopack` if applicable (#71737)
parent
dfa35c46
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
47 additions
and
5 deletions
+47
-5
README.md
.../bin/__testfixtures__/change-turbo-to-turbopack/README.md
+1
-0
package.json
...n/__testfixtures__/change-turbo-to-turbopack/package.json
+11
-0
pnpm-workspace.yaml
...tfixtures__/change-turbo-to-turbopack/pnpm-workspace.yaml
+0
-0
README.md
...-codemod/bin/__testfixtures__/suggest-turbopack/README.md
+1
-0
package.json
...demod/bin/__testfixtures__/suggest-turbopack/package.json
+11
-0
pnpm-workspace.yaml
...in/__testfixtures__/suggest-turbopack/pnpm-workspace.yaml
+0
-0
upgrade.ts
packages/next-codemod/bin/upgrade.ts
+23
-5
No files found.
packages/next-codemod/bin/__testfixtures__/change-turbo-to-turbopack/README.md
0 → 100644
View file @
dc1901a2
Change
`--turbo`
to
`--turbopack`
in
`next dev`
script.
packages/next-codemod/bin/__testfixtures__/change-turbo-to-turbopack/package.json
0 → 100644
View file @
dc1901a2
{
"name"
:
"change-turbo-to-turbopack"
,
"scripts"
:
{
"dev"
:
"next dev --turbo"
},
"dependencies"
:
{
"next"
:
"15.0.0-canary.0"
,
"react"
:
"19.0.0-rc.0"
,
"react-dom"
:
"19.0.0-rc.0"
}
}
packages/next-codemod/bin/__testfixtures__/change-turbo-to-turbopack/pnpm-workspace.yaml
0 → 100644
View file @
dc1901a2
packages/next-codemod/bin/__testfixtures__/suggest-turbopack/README.md
0 → 100644
View file @
dc1901a2
Suggest adding
`--turbopack`
to
`next dev`
script.
packages/next-codemod/bin/__testfixtures__/suggest-turbopack/package.json
0 → 100644
View file @
dc1901a2
{
"name"
:
"suggest-turbopack"
,
"scripts"
:
{
"dev"
:
"next dev"
},
"dependencies"
:
{
"next"
:
"15.0.0-canary.0"
,
"react"
:
"19.0.0-rc.0"
,
"react-dom"
:
"19.0.0-rc.0"
}
}
packages/next-codemod/bin/__testfixtures__/suggest-turbopack/pnpm-workspace.yaml
0 → 100644
View file @
dc1901a2
packages/next-codemod/bin/upgrade.ts
View file @
dc1901a2
...
@@ -177,7 +177,7 @@ export async function runUpgrade(
...
@@ -177,7 +177,7 @@ export async function runUpgrade(
)
)
if
(
compareVersions
(
targetNextVersion
,
'15.0.0-canary'
)
>=
0
)
{
if
(
compareVersions
(
targetNextVersion
,
'15.0.0-canary'
)
>=
0
)
{
await
suggestTurbopack
(
appPackageJson
)
await
suggestTurbopack
(
appPackageJson
,
targetNextVersion
)
}
}
const
codemods
=
await
suggestCodemods
(
const
codemods
=
await
suggestCodemods
(
...
@@ -410,12 +410,21 @@ function isUsingAppDir(projectPath: string): boolean {
...
@@ -410,12 +410,21 @@ function isUsingAppDir(projectPath: string): boolean {
* 3. Otherwise, we ask the user to manually add `--turbopack` to their dev command,
* 3. Otherwise, we ask the user to manually add `--turbopack` to their dev command,
* showing the current dev command as the initial value.
* showing the current dev command as the initial value.
*/
*/
async
function
suggestTurbopack
(
packageJson
:
any
):
Promise
<
void
>
{
async
function
suggestTurbopack
(
packageJson
:
any
,
targetNextVersion
:
string
):
Promise
<
void
>
{
const
devScript
:
string
=
packageJson
.
scripts
[
'dev'
]
const
devScript
:
string
=
packageJson
.
scripts
[
'dev'
]
// Turbopack flag was changed from `--turbo` to `--turbopack` in v15.0.1-canary.3
// PR: https://github.com/vercel/next.js/pull/71657
// Release: https://github.com/vercel/next.js/releases/tag/v15.0.1-canary.3
const
isAfterTurbopackFlagChange
=
compareVersions
(
targetNextVersion
,
'15.0.1-canary.3'
)
>=
0
const
turboPackFlag
=
isAfterTurbopackFlagChange
?
'--turbopack'
:
'--turbo'
if
(
!
devScript
)
{
if
(
!
devScript
)
{
console
.
log
(
console
.
log
(
`
${
pc
.
red
(
'⨯'
)}
Could not find a "dev" script in your package.js
on.`
`
${
pc
.
yellow
(
'⚠'
)}
No "dev" script found in your package.json. Skipping Turbopack suggesti
on.`
)
)
return
return
}
}
...
@@ -423,6 +432,15 @@ async function suggestTurbopack(packageJson: any): Promise<void> {
...
@@ -423,6 +432,15 @@ async function suggestTurbopack(packageJson: any): Promise<void> {
if
(
devScript
.
includes
(
'next dev'
))
{
if
(
devScript
.
includes
(
'next dev'
))
{
// covers "--turbopack" as well
// covers "--turbopack" as well
if
(
devScript
.
includes
(
'--turbo'
))
{
if
(
devScript
.
includes
(
'--turbo'
))
{
if
(
isAfterTurbopackFlagChange
&&
!
devScript
.
includes
(
'--turbopack'
))
{
console
.
log
()
// new line
console
.
log
(
`
${
pc
.
green
(
'✔'
)}
Replaced "--turbo" with "--turbopack" in your dev script.`
)
console
.
log
()
// new line
packageJson
.
scripts
[
'dev'
]
=
devScript
.
replace
(
'--turbo'
,
'--turbopack'
)
return
}
return
return
}
}
...
@@ -442,7 +460,7 @@ async function suggestTurbopack(packageJson: any): Promise<void> {
...
@@ -442,7 +460,7 @@ async function suggestTurbopack(packageJson: any): Promise<void> {
packageJson
.
scripts
[
'dev'
]
=
devScript
.
replace
(
packageJson
.
scripts
[
'dev'
]
=
devScript
.
replace
(
'next dev'
,
'next dev'
,
'next dev --turbopack'
`next dev
${
turboPackFlag
}
`
)
)
return
return
}
}
...
@@ -455,7 +473,7 @@ async function suggestTurbopack(packageJson: any): Promise<void> {
...
@@ -455,7 +473,7 @@ async function suggestTurbopack(packageJson: any): Promise<void> {
{
{
type
:
'text'
,
type
:
'text'
,
name
:
'customDevScript'
,
name
:
'customDevScript'
,
message
:
'Please manually add "--turbopack" to your dev command.'
,
message
:
`Please manually add "
${
turboPackFlag
}
" to your dev command.`
,
initial
:
devScript
,
initial
:
devScript
,
},
},
{
onCancel
}
{
onCancel
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment