Skip to content

Commit cfa003c

Browse files
Add --turbopack CLI flag (#71657)
Changes `--turbo` -> `--turbopack` to avoid confusion. - Updated docs - Updates create-next-app -- For create-next-app it's a rename as otherwise there is an ordering problem with the prompts - For the CLI `next dev --turbo` is still supported, will eventually be a warning in a future version to swap with `--turbopack` but is not a requirement today, can be handled automatically by the upgrade codemod - New CLI flag: `next dev --turbopack` <!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: ## For Contributors ### Improving Documentation - Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Adding or Updating Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Closes NEXT- Fixes # --> --------- Co-authored-by: Will Binns-Smith <wbinnssmith@gmail.com>
1 parent 9bd38dd commit cfa003c

File tree

33 files changed

+88
-85
lines changed

33 files changed

+88
-85
lines changed

.github/actions/next-integration-stat/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ const createCommentPostAsync =
735735
console.log('Created a new comment', result.data.html_url)
736736
}
737737

738-
// An action report failed next.js integration test with --turbo
738+
// An action report failed next.js integration test with --turbopack
739739
async function run() {
740740
const {
741741
token,

bench/heavy-npm-deps/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.1.0",
44
"private": true,
55
"scripts": {
6-
"dev-turbopack": "next dev --turbo",
6+
"dev-turbopack": "next dev --turbopack",
77
"dev-webpack": "next dev",
88
"build-turbopack": "TURBOPACK=1 TURBOPACK_BUILD=1 next build",
99
"build-webpack": "next build",

crates/napi/src/turbopack.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::next_api::project::NapiDefineEnv;
1313
#[napi(object, object_to_js = false)]
1414
#[derive(Debug)]
1515
pub struct NextBuildContext {
16-
// Added by Next.js for next build --turbo specifically.
16+
// Added by Next.js for next build --turbopack specifically.
1717
/// The root directory of the workspace.
1818
pub root: Option<String>,
1919

crates/next-core/src/mode.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use turbopack_ecmascript_runtime::RuntimeType;
66
#[turbo_tasks::value(shared)]
77
#[derive(Debug, Copy, Clone, TaskInput, Ord, PartialOrd, Hash)]
88
pub enum NextMode {
9-
/// `next dev --turbo`
9+
/// `next dev --turbopack`
1010
Development,
1111
/// `next build`
1212
Build,

docs/02-app/01-building-your-application/07-configuring/05-mdx.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ module.exports = withMDX({
784784

785785
> **Good to know**:
786786
>
787-
> This option is required when processing markdown and MDX while using [Turbopack](/docs/architecture/turbopack) (`next dev --turbo`).
787+
> This option is required when processing markdown and MDX while using [Turbopack](/docs/architecture/turbopack) (`next dev --turbopack`).
788788
789789
## Helpful Links
790790

docs/02-app/01-building-your-application/11-upgrading/05-from-create-react-app.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ Create React App and Next.js both default to using webpack for bundling.
480480

481481
When migrating your CRA application to Next.js, you might have a custom webpack configuration you're looking to migrate. Next.js supports providing a [custom webpack configuration](/docs/app/api-reference/next-config-js/webpack).
482482

483-
Further, Next.js has support for [Turbopack](/docs/app/api-reference/next-config-js/turbo) through `next dev --turbo` to improve your local dev performance. Turbopack supports some [webpack loaders](/docs/app/api-reference/next-config-js/turbo) as well for compatibility and incremental adoption.
483+
Further, Next.js has support for [Turbopack](/docs/app/api-reference/next-config-js/turbo) through `next dev --turbopack` to improve your local dev performance. Turbopack supports some [webpack loaders](/docs/app/api-reference/next-config-js/turbo) as well for compatibility and incremental adoption.
484484

485485
## Next Steps
486486

docs/02-app/02-api-reference/06-cli/create-next-app.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ The following options are available:
2828
| `--eslint` | Initialize with ESLint config |
2929
| `--app` | Initialize as an App Router project |
3030
| `--src-dir` | Initialize inside a `src/` directory |
31-
| `--turbo` | Enable Turbopack by default for development |
31+
| `--turbopack` | Enable Turbopack by default for development |
3232
| `--import-alias <alias-to-configure>` | Specify import alias to use (default "@/\*") |
3333
| `--empty` | Initialize an empty project |
3434
| `--use-npm` | Explicitly tell the CLI to bootstrap the application using npm |

docs/02-app/02-api-reference/06-cli/next.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ The following commands are available:
4545
| ---------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
4646
| `-h, --help` | Show all available options. |
4747
| `[directory]` | A directory in which to build the application. If not provided, current directory is used. |
48-
| `--turbo` | Starts development mode using [Turbopack](https://nextjs.org/docs/architecture/turbopack). |
48+
| `--turbopack` | Starts development mode using [Turbopack](https://nextjs.org/docs/architecture/turbopack). |
4949
| `-p` or `--port <port>` | Specify a port number on which to start the application. Default: 3000, env: PORT |
5050
| `-H`or `--hostname <hostname>` | Specify a hostname on which to start the application. Useful for making the application available for other devices on the network. Default: 0.0.0.0 |
5151
| `--experimental-https` | Starts the server with HTTPS and generates a self-signed certificate. |

docs/04-architecture/turbopack.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ description: Turbopack is an incremental bundler optimized for JavaScript and Ty
77

88
## Usage
99

10-
Turbopack can be used in Next.js in both the `pages` and `app` directories for faster local development. To enable Turbopack, use the `--turbo` flag when running the Next.js development server.
10+
Turbopack can be used in Next.js in both the `pages` and `app` directories for faster local development. To enable Turbopack, use the `--turbopack` flag when running the Next.js development server.
1111

1212
```json filename="package.json" highlight={3}
1313
{
1414
"scripts": {
15-
"dev": "next dev --turbo",
15+
"dev": "next dev --turbopack",
1616
"build": "next build",
1717
"start": "next start",
1818
"lint": "next lint"
@@ -76,6 +76,6 @@ These features are currently not supported:
7676

7777
## Generating Trace Files
7878

79-
Trace files allow the Next.js team to investigate and improve performance metrics and memory usage. To generate a trace file, append `NEXT_TURBOPACK_TRACING=1` to the `next dev --turbo` command, this will generate a `.next/trace.log` file.
79+
Trace files allow the Next.js team to investigate and improve performance metrics and memory usage. To generate a trace file, append `NEXT_TURBOPACK_TRACING=1` to the `next dev --turbopack` command, this will generate a `.next/trace.log` file.
8080

8181
When reporting issues related to Turbopack performance and memory usage, please include the trace file in your [GitHub](https://github.com/vercel/next.js) issue.

packages/create-next-app/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Options:
5959

6060
Initialize inside a `src/` directory.
6161

62-
--turbo
62+
--turbopack
6363

6464
Enable Turbopack by default for development.
6565

packages/create-next-app/create-app.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export async function createApp({
3636
importAlias,
3737
skipInstall,
3838
empty,
39-
turbo,
39+
turbopack,
4040
disableGit,
4141
}: {
4242
appPath: string
@@ -51,7 +51,7 @@ export async function createApp({
5151
importAlias: string
5252
skipInstall: boolean
5353
empty: boolean
54-
turbo: boolean
54+
turbopack: boolean
5555
disableGit?: boolean
5656
}): Promise<void> {
5757
let repoInfo: RepoInfo | undefined
@@ -233,7 +233,7 @@ export async function createApp({
233233
srcDir,
234234
importAlias,
235235
skipInstall,
236-
turbo,
236+
turbopack,
237237
})
238238
}
239239

packages/create-next-app/index.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const program = new Command(packageJson.name)
5252
.option('--eslint', 'Initialize with ESLint config.')
5353
.option('--app', 'Initialize as an App Router project.')
5454
.option('--src-dir', "Initialize inside a 'src/' directory.")
55-
.option('--turbo', 'Enable Turbopack by default for development.')
55+
.option('--turbopack', 'Enable Turbopack by default for development.')
5656
.option(
5757
'--import-alias <prefix/*>',
5858
'Specify import alias to use (default "@/*").'
@@ -233,7 +233,7 @@ async function run(): Promise<void> {
233233
importAlias: '@/*',
234234
customizeImportAlias: false,
235235
empty: false,
236-
turbo: false,
236+
turbopack: false,
237237
disableGit: false,
238238
}
239239
const getPrefOrDefault = (field: string) =>
@@ -351,22 +351,22 @@ async function run(): Promise<void> {
351351
}
352352
}
353353

354-
if (!opts.turbo && !args.includes('--no-turbo')) {
354+
if (!opts.turbopack && !args.includes('--no-turbopack')) {
355355
if (skipPrompt) {
356-
opts.turbo = getPrefOrDefault('turbo')
356+
opts.turbopack = getPrefOrDefault('turbopack')
357357
} else {
358358
const styledTurbo = blue('Turbopack')
359-
const { turbo } = await prompts({
359+
const { turbopack } = await prompts({
360360
onState: onPromptState,
361361
type: 'toggle',
362-
name: 'turbo',
362+
name: 'turbopack',
363363
message: `Would you like to use ${styledTurbo} for ${`next dev`}?`,
364-
initial: getPrefOrDefault('turbo'),
364+
initial: getPrefOrDefault('turbopack'),
365365
active: 'Yes',
366366
inactive: 'No',
367367
})
368-
opts.turbo = Boolean(turbo)
369-
preferences.turbo = Boolean(turbo)
368+
opts.turbopack = Boolean(turbopack)
369+
preferences.turbopack = Boolean(turbopack)
370370
}
371371
}
372372

@@ -429,7 +429,7 @@ async function run(): Promise<void> {
429429
importAlias: opts.importAlias,
430430
skipInstall: opts.skipInstall,
431431
empty: opts.empty,
432-
turbo: opts.turbo,
432+
turbopack: opts.turbopack,
433433
disableGit: opts.disableGit,
434434
})
435435
} catch (reason) {
@@ -461,7 +461,7 @@ async function run(): Promise<void> {
461461
importAlias: opts.importAlias,
462462
skipInstall: opts.skipInstall,
463463
empty: opts.empty,
464-
turbo: opts.turbo,
464+
turbopack: opts.turbopack,
465465
disableGit: opts.disableGit,
466466
})
467467
}

packages/create-next-app/templates/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const installTemplate = async ({
4343
srcDir,
4444
importAlias,
4545
skipInstall,
46-
turbo,
46+
turbopack,
4747
}: InstallTemplateArgs) => {
4848
console.log(bold(`Using ${packageManager}.`));
4949

@@ -188,7 +188,7 @@ export const installTemplate = async ({
188188
version: "0.1.0",
189189
private: true,
190190
scripts: {
191-
dev: `next dev${turbo ? " --turbo" : ""}`,
191+
dev: `next dev${turbopack ? " --turbopack" : ""}`,
192192
build: "next build",
193193
start: "next start",
194194
lint: "next lint",

packages/create-next-app/templates/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ export interface InstallTemplateArgs {
2929
srcDir: boolean;
3030
importAlias: string;
3131
skipInstall: boolean;
32-
turbo: boolean;
32+
turbopack: boolean;
3333
}

packages/next-codemod/bin/upgrade.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -403,16 +403,16 @@ function isUsingAppDir(projectPath: string): boolean {
403403
* Heuristics are used to determine whether to Turbopack is enabled or not and
404404
* to determine how to update the dev script.
405405
*
406-
* 1. If the dev script contains `--turbo` option, we assume that Turbopack is
406+
* 1. If the dev script contains `--turbopack` option, we assume that Turbopack is
407407
* already enabled.
408408
* 2. If the dev script contains the string `next dev`, we replace it to
409-
* `next dev --turbo`.
410-
* 3. Otherwise, we ask the user to manually add `--turbo` to their dev command,
409+
* `next dev --turbopack`.
410+
* 3. Otherwise, we ask the user to manually add `--turbopack` to their dev command,
411411
* showing the current dev command as the initial value.
412412
*/
413413
async function suggestTurbopack(packageJson: any): Promise<void> {
414414
const devScript: string = packageJson.scripts['dev']
415-
if (devScript.includes('--turbo')) return
415+
if (devScript.includes('--turbopack')) return
416416

417417
const responseTurbopack = await prompts(
418418
{
@@ -431,7 +431,7 @@ async function suggestTurbopack(packageJson: any): Promise<void> {
431431
if (devScript.includes('next dev')) {
432432
packageJson.scripts['dev'] = devScript.replace(
433433
'next dev',
434-
'next dev --turbo'
434+
'next dev --turbopack'
435435
)
436436
return
437437
}
@@ -444,7 +444,7 @@ async function suggestTurbopack(packageJson: any): Promise<void> {
444444
{
445445
type: 'text',
446446
name: 'customDevScript',
447-
message: 'Please manually add "--turbo" to your dev command.',
447+
message: 'Please manually add "--turbopack" to your dev command.',
448448
initial: devScript,
449449
},
450450
{ onCancel }

packages/next/src/bin/next.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,8 @@ program
157157
'If no directory is provided, the current directory will be used.'
158158
)}`
159159
)
160-
.option('--turbo', 'Starts development mode using Turbopack (beta).')
160+
.option('--turbo', 'Starts development mode using Turbopack.')
161+
.option('--turbopack', 'Starts development mode using Turbopack.')
161162
.addOption(
162163
new Option(
163164
'-p, --port <port>',

packages/next/src/cli/next-dev.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import { flushAllTraces, trace } from '../trace'
4040

4141
export type NextDevOptions = {
4242
turbo?: boolean
43+
turbopack?: boolean
4344
port: number
4445
hostname?: string
4546
experimentalHttps?: boolean
@@ -232,7 +233,7 @@ const nextDev = async (
232233
hostname: host,
233234
}
234235

235-
if (options.turbo) {
236+
if (options.turbo || options.turbopack) {
236237
process.env.TURBOPACK = '1'
237238
}
238239

packages/next/src/client/components/react-dev-overlay/internal/components/VersionStalenessInfo/VersionStalenessInfo.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function VersionStalenessInfo({
2828
(learn more)
2929
</a>
3030
)}
31-
{process.env.TURBOPACK ? ' (turbo)' : ''}
31+
{process.env.TURBOPACK ? ' (Turbopack)' : ''}
3232
</span>
3333
)
3434
}

packages/next/src/lib/turbopack-warning.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const unsupportedTurbopackNextConfigOptions = [
4747
'experimental.urlImports',
4848
]
4949

50-
// The following will need to be supported by `next build --turbo`
50+
// The following will need to be supported by `next build --turbopack`
5151
const unsupportedProductionSpecificTurbopackNextConfigOptions: string[] = [
5252
// TODO: Support disabling sourcemaps, currently they're always enabled.
5353
// 'productionBrowserSourceMaps',

packages/next/src/server/config-shared.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export type TurboRuleConfigItem =
115115

116116
export interface ExperimentalTurboOptions {
117117
/**
118-
* (`next --turbo` only) A mapping of aliased imports to modules to load in their place.
118+
* (`next --turbopack` only) A mapping of aliased imports to modules to load in their place.
119119
*
120120
* @see [Resolve Alias](https://nextjs.org/docs/app/api-reference/next-config-js/turbo#resolve-alias)
121121
*/
@@ -125,21 +125,21 @@ export interface ExperimentalTurboOptions {
125125
>
126126

127127
/**
128-
* (`next --turbo` only) A list of extensions to resolve when importing files.
128+
* (`next --turbopack` only) A list of extensions to resolve when importing files.
129129
*
130130
* @see [Resolve Extensions](https://nextjs.org/docs/app/api-reference/next-config-js/turbo#resolve-extensions)
131131
*/
132132
resolveExtensions?: string[]
133133

134134
/**
135-
* (`next --turbo` only) A list of webpack loaders to apply when running with Turbopack.
135+
* (`next --turbopack` only) A list of webpack loaders to apply when running with Turbopack.
136136
*
137137
* @see [Turbopack Loaders](https://nextjs.org/docs/app/api-reference/next-config-js/turbo#webpack-loaders)
138138
*/
139139
loaders?: Record<string, TurboLoaderItem[]>
140140

141141
/**
142-
* (`next --turbo` only) A list of webpack loaders to apply when running with Turbopack.
142+
* (`next --turbopack` only) A list of webpack loaders to apply when running with Turbopack.
143143
*
144144
* @see [Turbopack Loaders](https://nextjs.org/docs/app/api-reference/next-config-js/turbo#webpack-loaders)
145145
*/

packages/next/src/server/lib/app-info-log.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function logStartInfo({
2323
Log.bootstrap(
2424
`${bold(
2525
purple(`${Log.prefixes.ready} Next.js ${process.env.__NEXT_VERSION}`)
26-
)}${process.env.TURBOPACK ? ' (turbo)' : ''}`
26+
)}${process.env.TURBOPACK ? ' (Turbopack)' : ''}`
2727
)
2828
if (appUrl) {
2929
Log.bootstrap(`- Local: ${appUrl}`)

packages/next/src/server/next.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,10 @@ class NextCustomServer extends NextServer {
354354
function createServer(
355355
options: NextServerOptions & {
356356
turbo?: boolean
357+
turbopack?: boolean
357358
}
358359
): NextServer {
359-
if (options && options.turbo) {
360+
if (options && (options.turbo || options.turbopack)) {
360361
process.env.TURBOPACK = '1'
361362
}
362363
// The package is used as a TypeScript plugin.

test/development/acceptance-app/version-staleness.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe('Error Overlay version staleness', () => {
4949

5050
if (process.env.TURBOPACK) {
5151
expect(await getStaleness(browser)).toMatchInlineSnapshot(
52-
`"Next.js (1.0.0) is outdated (learn more) (turbo)"`
52+
`"Next.js (1.0.0) is outdated (learn more) (Turbopack)"`
5353
)
5454
} else {
5555
expect(await getStaleness(browser)).toMatchInlineSnapshot(
@@ -86,7 +86,7 @@ describe('Error Overlay version staleness', () => {
8686

8787
if (process.env.TURBOPACK) {
8888
expect(await getStaleness(browser)).toMatchInlineSnapshot(
89-
`"Next.js (2.0.0) is outdated (learn more) (turbo)"`
89+
`"Next.js (2.0.0) is outdated (learn more) (Turbopack)"`
9090
)
9191
} else {
9292
expect(await getStaleness(browser)).toMatchInlineSnapshot(
@@ -120,7 +120,7 @@ describe('Error Overlay version staleness', () => {
120120

121121
if (process.env.TURBOPACK) {
122122
expect(await getStaleness(browser)).toMatchInlineSnapshot(
123-
`"Next.js (3.0.0) is outdated (learn more) (turbo)"`
123+
`"Next.js (3.0.0) is outdated (learn more) (Turbopack)"`
124124
)
125125
} else {
126126
expect(await getStaleness(browser)).toMatchInlineSnapshot(

0 commit comments

Comments
 (0)