Unverified Commit 60ad8aff authored by Arindam Majumder's avatar Arindam Majumder Committed by GitHub

feat: Add option to enable Turbopack with create-next-app (#65926)

This PR addresses an issue where the `dev` script in `package.json` was
not correctly updated to use the `--turbo` option when specified. The
changes ensure that the `dev` script is set to `next dev --turbo` if the
`turbo` option is enabled.

### Changes:
1. **Function Modification**:
- Updated the `modifyPackageJson` function to include a check for the
`turbo` parameter.
- If `turbo` is true, the `dev` script in `package.json` is set to `next
dev --turbo`.
   - If `turbo` is false, the `dev` script remains `next dev`.

2. **Integration in App Creation**:
- Integrated the `modifyPackageJson` function into the app creation
process to ensure the `dev` script is correctly set based on the `turbo`
parameter.

### Testing:
- Verified that the `dev` script in `package.json` is correctly updated
to `next dev --turbo` when the `turbo` option is enabled.
- Ensured that the `dev` script remains `next dev` when the `turbo`
option is not enabled.

### Related Issues:
- Fixes #65924

### Notes:
- This change ensures that developers opting to use Turbopack for
development will have the correct script set up automatically.

---------
Signed-off-by: 's avatarArindam Majumder <arindammajumder2020@gmail.com>
Co-authored-by: 's avatarLee Robinson <me@leerob.io>
Co-authored-by: 's avatardevjiwonchoi <devjiwonchoi@gmail.com>
Co-authored-by: 's avatarJiachi Liu <inbox@huozhi.im>
Co-authored-by: 's avatarSam Ko <sam@vercel.com>
parent 0eedddbf
...@@ -30,6 +30,7 @@ Would you like to use ESLint? No / Yes ...@@ -30,6 +30,7 @@ Would you like to use ESLint? No / Yes
Would you like to use Tailwind CSS? No / Yes Would you like to use Tailwind CSS? No / Yes
Would you like to use `src/` directory? No / Yes Would you like to use `src/` directory? No / Yes
Would you like to use App Router? (recommended) No / Yes Would you like to use App Router? (recommended) No / Yes
Would you like to use Turbopack for `next dev`? No / Yes
Would you like to customize the default import alias (@/*)? No / Yes Would you like to customize the default import alias (@/*)? No / Yes
What import alias would you like configured? @/* What import alias would you like configured? @/*
``` ```
......
...@@ -38,6 +38,7 @@ Would you like to use ESLint? No / Yes ...@@ -38,6 +38,7 @@ Would you like to use ESLint? No / Yes
Would you like to use Tailwind CSS? No / Yes Would you like to use Tailwind CSS? No / Yes
Would you like to use `src/` directory? No / Yes Would you like to use `src/` directory? No / Yes
Would you like to use App Router? (recommended) No / Yes Would you like to use App Router? (recommended) No / Yes
Would you like to use Turbopack for `next dev`? No / Yes
Would you like to customize the default import alias (@/*)? No / Yes Would you like to customize the default import alias (@/*)? No / Yes
``` ```
...@@ -80,6 +81,10 @@ Options: ...@@ -80,6 +81,10 @@ Options:
Initialize inside a `src/` directory. Initialize inside a `src/` directory.
--turbo
Enable Turbopack by default for development.
--import-alias <alias-to-configure> --import-alias <alias-to-configure>
Specify import alias to use (default "@/*"). Specify import alias to use (default "@/*").
......
...@@ -59,6 +59,10 @@ Options: ...@@ -59,6 +59,10 @@ Options:
Initialize inside a `src/` directory. Initialize inside a `src/` directory.
--turbo
Enable Turbopack by default for development.
--import-alias <alias-to-configure> --import-alias <alias-to-configure>
Specify import alias to use (default "@/*"). Specify import alias to use (default "@/*").
......
...@@ -36,6 +36,7 @@ export async function createApp({ ...@@ -36,6 +36,7 @@ export async function createApp({
importAlias, importAlias,
skipInstall, skipInstall,
empty, empty,
turbo,
}: { }: {
appPath: string appPath: string
packageManager: PackageManager packageManager: PackageManager
...@@ -49,6 +50,7 @@ export async function createApp({ ...@@ -49,6 +50,7 @@ export async function createApp({
importAlias: string importAlias: string
skipInstall: boolean skipInstall: boolean
empty: boolean empty: boolean
turbo: boolean
}): Promise<void> { }): Promise<void> {
let repoInfo: RepoInfo | undefined let repoInfo: RepoInfo | undefined
const mode: TemplateMode = typescript ? 'ts' : 'js' const mode: TemplateMode = typescript ? 'ts' : 'js'
...@@ -229,6 +231,7 @@ export async function createApp({ ...@@ -229,6 +231,7 @@ export async function createApp({
srcDir, srcDir,
importAlias, importAlias,
skipInstall, skipInstall,
turbo,
}) })
} }
......
...@@ -83,6 +83,13 @@ const program = new Commander.Command(packageJson.name) ...@@ -83,6 +83,13 @@ const program = new Commander.Command(packageJson.name)
` `
Initialize inside a \`src/\` directory. Initialize inside a \`src/\` directory.
`
)
.option(
'--turbo',
`
Enable Turbopack by default for development.
` `
) )
.option( .option(
...@@ -272,6 +279,7 @@ async function run(): Promise<void> { ...@@ -272,6 +279,7 @@ async function run(): Promise<void> {
importAlias: '@/*', importAlias: '@/*',
customizeImportAlias: false, customizeImportAlias: false,
empty: false, empty: false,
turbo: false,
} }
const getPrefOrDefault = (field: string) => const getPrefOrDefault = (field: string) =>
preferences[field] ?? defaults[field] preferences[field] ?? defaults[field]
...@@ -396,6 +404,25 @@ async function run(): Promise<void> { ...@@ -396,6 +404,25 @@ async function run(): Promise<void> {
} }
} }
if (!program.turbo && !process.argv.includes('--no-turbo')) {
if (ciInfo.isCI) {
program.turbo = getPrefOrDefault('turbo')
} else {
const styledTurbo = blue('Turbopack')
const { turbo } = await prompts({
onState: onPromptState,
type: 'toggle',
name: 'turbo',
message: `Would you like to use ${styledTurbo} for ${`next dev`}?`,
initial: getPrefOrDefault('turbo'),
active: 'Yes',
inactive: 'No',
})
program.turbo = Boolean(turbo)
preferences.turbo = Boolean(turbo)
}
}
const importAliasPattern = /^[^*"]+\/\*\s*$/ const importAliasPattern = /^[^*"]+\/\*\s*$/
if ( if (
typeof program.importAlias !== 'string' || typeof program.importAlias !== 'string' ||
...@@ -455,6 +482,7 @@ async function run(): Promise<void> { ...@@ -455,6 +482,7 @@ async function run(): Promise<void> {
importAlias: program.importAlias, importAlias: program.importAlias,
skipInstall: program.skipInstall, skipInstall: program.skipInstall,
empty: program.empty, empty: program.empty,
turbo: program.turbo,
}) })
} catch (reason) { } catch (reason) {
if (!(reason instanceof DownloadError)) { if (!(reason instanceof DownloadError)) {
...@@ -485,6 +513,7 @@ async function run(): Promise<void> { ...@@ -485,6 +513,7 @@ async function run(): Promise<void> {
importAlias: program.importAlias, importAlias: program.importAlias,
skipInstall: program.skipInstall, skipInstall: program.skipInstall,
empty: program.empty, empty: program.empty,
turbo: program.turbo,
}) })
} }
conf.set('preferences', preferences) conf.set('preferences', preferences)
......
...@@ -39,6 +39,7 @@ export const installTemplate = async ({ ...@@ -39,6 +39,7 @@ export const installTemplate = async ({
srcDir, srcDir,
importAlias, importAlias,
skipInstall, skipInstall,
turbo,
}: InstallTemplateArgs) => { }: InstallTemplateArgs) => {
console.log(bold(`Using ${packageManager}.`)); console.log(bold(`Using ${packageManager}.`));
...@@ -174,7 +175,7 @@ export const installTemplate = async ({ ...@@ -174,7 +175,7 @@ export const installTemplate = async ({
version: "0.1.0", version: "0.1.0",
private: true, private: true,
scripts: { scripts: {
dev: "next dev", dev: `next dev${turbo ? " --turbo" : ""}`,
build: "next build", build: "next build",
start: "next start", start: "next start",
lint: "next lint", lint: "next lint",
......
...@@ -29,4 +29,5 @@ export interface InstallTemplateArgs { ...@@ -29,4 +29,5 @@ export interface InstallTemplateArgs {
srcDir: boolean; srcDir: boolean;
importAlias: string; importAlias: string;
skipInstall: boolean; skipInstall: boolean;
turbo: boolean;
} }
...@@ -30,6 +30,7 @@ describe.skip('create-next-app', () => { ...@@ -30,6 +30,7 @@ describe.skip('create-next-app', () => {
projectName, projectName,
'--ts', '--ts',
'--app', '--app',
'--no-turbo',
'--no-eslint', '--no-eslint',
'--no-tailwind', '--no-tailwind',
'--no-src-dir', '--no-src-dir',
...@@ -99,6 +100,7 @@ describe.skip('create-next-app', () => { ...@@ -99,6 +100,7 @@ describe.skip('create-next-app', () => {
projectName, projectName,
'--ts', '--ts',
'--app', '--app',
'--no-turbo',
'--no-eslint', '--no-eslint',
'--no-tailwind', '--no-tailwind',
'--no-src-dir', '--no-src-dir',
......
...@@ -36,6 +36,7 @@ describe.skip('create-next-app with package manager bun', () => { ...@@ -36,6 +36,7 @@ describe.skip('create-next-app with package manager bun', () => {
'--ts', '--ts',
'--app', '--app',
'--use-bun', '--use-bun',
'--no-turbo',
'--no-eslint', '--no-eslint',
'--no-src-dir', '--no-src-dir',
'--no-tailwind', '--no-tailwind',
...@@ -55,72 +56,73 @@ describe.skip('create-next-app with package manager bun', () => { ...@@ -55,72 +56,73 @@ describe.skip('create-next-app with package manager bun', () => {
}) })
}) })
}) })
})
it('should use bun when user-agent is bun', async () => { it('should use bun when user-agent is bun', async () => {
await useTempDir(async (cwd) => { await useTempDir(async (cwd) => {
const projectName = 'user-agent-bun' const projectName = 'user-agent-bun'
const res = await run( const res = await run(
[ [
projectName, projectName,
'--ts', '--ts',
'--app', '--app',
'--no-eslint', '--no-turbo',
'--no-src-dir', '--no-eslint',
'--no-tailwind', '--no-src-dir',
'--no-import-alias', '--no-tailwind',
], '--no-import-alias',
nextInstall.installDir, ],
{ nextInstall.installDir,
cwd, {
env: { npm_config_user_agent: 'bun' }, cwd,
} env: { npm_config_user_agent: 'bun' },
) }
)
expect(res.exitCode).toBe(0) expect(res.exitCode).toBe(0)
projectFilesShouldExist({ projectFilesShouldExist({
cwd, cwd,
projectName, projectName,
files, files,
})
}) })
}) })
})
it('should use bun for --use-bun flag with example', async () => { it('should use bun for --use-bun flag with example', async () => {
await useTempDir(async (cwd) => { await useTempDir(async (cwd) => {
const projectName = 'use-bun-with-example' const projectName = 'use-bun-with-example'
const res = await run( const res = await run(
[projectName, '--use-bun', '--example', FULL_EXAMPLE_PATH], [projectName, '--use-bun', '--example', FULL_EXAMPLE_PATH],
nextInstall.installDir, nextInstall.installDir,
{ cwd } { cwd }
) )
expect(res.exitCode).toBe(0) expect(res.exitCode).toBe(0)
projectFilesShouldExist({ projectFilesShouldExist({
cwd, cwd,
projectName, projectName,
files, files,
})
}) })
}) })
})
it('should use bun when user-agent is bun with example', async () => { it('should use bun when user-agent is bun with example', async () => {
await useTempDir(async (cwd) => { await useTempDir(async (cwd) => {
const projectName = 'user-agent-bun-with-example' const projectName = 'user-agent-bun-with-example'
const res = await run( const res = await run(
[projectName, '--example', FULL_EXAMPLE_PATH], [projectName, '--example', FULL_EXAMPLE_PATH],
nextInstall.installDir, nextInstall.installDir,
{ {
cwd, cwd,
env: { npm_config_user_agent: 'bun' }, env: { npm_config_user_agent: 'bun' },
} }
) )
expect(res.exitCode).toBe(0) expect(res.exitCode).toBe(0)
projectFilesShouldExist({ projectFilesShouldExist({
cwd, cwd,
projectName, projectName,
files, files,
})
}) })
}) })
}) })
...@@ -29,6 +29,7 @@ describe.skip('create-next-app with package manager npm', () => { ...@@ -29,6 +29,7 @@ describe.skip('create-next-app with package manager npm', () => {
'--ts', '--ts',
'--app', '--app',
'--use-npm', '--use-npm',
'--no-turbo',
'--no-eslint', '--no-eslint',
'--no-src-dir', '--no-src-dir',
'--no-tailwind', '--no-tailwind',
...@@ -48,72 +49,73 @@ describe.skip('create-next-app with package manager npm', () => { ...@@ -48,72 +49,73 @@ describe.skip('create-next-app with package manager npm', () => {
}) })
}) })
}) })
})
it('should use npm when user-agent is npm', async () => { it('should use npm when user-agent is npm', async () => {
await useTempDir(async (cwd) => { await useTempDir(async (cwd) => {
const projectName = 'user-agent-npm' const projectName = 'user-agent-npm'
const res = await run( const res = await run(
[ [
projectName, projectName,
'--ts', '--ts',
'--app', '--app',
'--no-eslint', '--no-turbo',
'--no-src-dir', '--no-eslint',
'--no-tailwind', '--no-src-dir',
'--no-import-alias', '--no-tailwind',
], '--no-import-alias',
nextInstall.installDir, ],
{ nextInstall.installDir,
cwd, {
env: { npm_config_user_agent: 'npm' }, cwd,
} env: { npm_config_user_agent: 'npm' },
) }
)
expect(res.exitCode).toBe(0) expect(res.exitCode).toBe(0)
projectFilesShouldExist({ projectFilesShouldExist({
cwd, cwd,
projectName, projectName,
files, files,
})
}) })
}) })
})
it('should use npm for --use-npm flag with example', async () => { it('should use npm for --use-npm flag with example', async () => {
await useTempDir(async (cwd) => { await useTempDir(async (cwd) => {
const projectName = 'use-npm-with-example' const projectName = 'use-npm-with-example'
const res = await run( const res = await run(
[projectName, '--use-npm', '--example', FULL_EXAMPLE_PATH], [projectName, '--use-npm', '--example', FULL_EXAMPLE_PATH],
nextInstall.installDir, nextInstall.installDir,
{ cwd } { cwd }
) )
expect(res.exitCode).toBe(0) expect(res.exitCode).toBe(0)
projectFilesShouldExist({ projectFilesShouldExist({
cwd, cwd,
projectName, projectName,
files, files,
})
}) })
}) })
})
it('should use npm when user-agent is npm with example', async () => { it('should use npm when user-agent is npm with example', async () => {
await useTempDir(async (cwd) => { await useTempDir(async (cwd) => {
const projectName = 'user-agent-npm-with-example' const projectName = 'user-agent-npm-with-example'
const res = await run( const res = await run(
[projectName, '--example', FULL_EXAMPLE_PATH], [projectName, '--example', FULL_EXAMPLE_PATH],
nextInstall.installDir, nextInstall.installDir,
{ {
cwd, cwd,
env: { npm_config_user_agent: 'npm' }, env: { npm_config_user_agent: 'npm' },
} }
) )
expect(res.exitCode).toBe(0) expect(res.exitCode).toBe(0)
projectFilesShouldExist({ projectFilesShouldExist({
cwd, cwd,
projectName, projectName,
files, files,
})
}) })
}) })
}) })
...@@ -37,6 +37,7 @@ describe.skip('create-next-app with package manager pnpm', () => { ...@@ -37,6 +37,7 @@ describe.skip('create-next-app with package manager pnpm', () => {
'--ts', '--ts',
'--app', '--app',
'--use-pnpm', '--use-pnpm',
'--no-turbo',
'--no-eslint', '--no-eslint',
'--no-src-dir', '--no-src-dir',
'--no-tailwind', '--no-tailwind',
...@@ -56,72 +57,73 @@ describe.skip('create-next-app with package manager pnpm', () => { ...@@ -56,72 +57,73 @@ describe.skip('create-next-app with package manager pnpm', () => {
}) })
}) })
}) })
})
it('should use pnpm when user-agent is pnpm', async () => { it('should use pnpm when user-agent is pnpm', async () => {
await useTempDir(async (cwd) => { await useTempDir(async (cwd) => {
const projectName = 'user-agent-pnpm' const projectName = 'user-agent-pnpm'
const res = await run( const res = await run(
[ [
projectName, projectName,
'--ts', '--ts',
'--app', '--app',
'--no-eslint', '--no-turbo',
'--no-src-dir', '--no-eslint',
'--no-tailwind', '--no-src-dir',
'--no-import-alias', '--no-tailwind',
], '--no-import-alias',
nextInstall.installDir, ],
{ nextInstall.installDir,
cwd, {
env: { npm_config_user_agent: 'pnpm' }, cwd,
} env: { npm_config_user_agent: 'pnpm' },
) }
)
expect(res.exitCode).toBe(0) expect(res.exitCode).toBe(0)
projectFilesShouldExist({ projectFilesShouldExist({
cwd, cwd,
projectName, projectName,
files, files,
})
}) })
}) })
})
it('should use pnpm for --use-pnpm flag with example', async () => { it('should use pnpm for --use-pnpm flag with example', async () => {
await useTempDir(async (cwd) => { await useTempDir(async (cwd) => {
const projectName = 'use-pnpm-with-example' const projectName = 'use-pnpm-with-example'
const res = await run( const res = await run(
[projectName, '--use-pnpm', '--example', FULL_EXAMPLE_PATH], [projectName, '--use-pnpm', '--example', FULL_EXAMPLE_PATH],
nextInstall.installDir, nextInstall.installDir,
{ cwd } { cwd }
) )
expect(res.exitCode).toBe(0) expect(res.exitCode).toBe(0)
projectFilesShouldExist({ projectFilesShouldExist({
cwd, cwd,
projectName, projectName,
files, files,
})
}) })
}) })
})
it('should use pnpm when user-agent is pnpm with example', async () => { it('should use pnpm when user-agent is pnpm with example', async () => {
await useTempDir(async (cwd) => { await useTempDir(async (cwd) => {
const projectName = 'user-agent-pnpm-with-example' const projectName = 'user-agent-pnpm-with-example'
const res = await run( const res = await run(
[projectName, '--example', FULL_EXAMPLE_PATH], [projectName, '--example', FULL_EXAMPLE_PATH],
nextInstall.installDir, nextInstall.installDir,
{ {
cwd, cwd,
env: { npm_config_user_agent: 'pnpm' }, env: { npm_config_user_agent: 'pnpm' },
} }
) )
expect(res.exitCode).toBe(0) expect(res.exitCode).toBe(0)
projectFilesShouldExist({ projectFilesShouldExist({
cwd, cwd,
projectName, projectName,
files, files,
})
}) })
}) })
}) })
...@@ -30,6 +30,7 @@ describe.skip('create-next-app with package manager yarn', () => { ...@@ -30,6 +30,7 @@ describe.skip('create-next-app with package manager yarn', () => {
'--ts', '--ts',
'--app', '--app',
'--use-yarn', '--use-yarn',
'--no-turbo',
'--no-eslint', '--no-eslint',
'--no-src-dir', '--no-src-dir',
'--no-tailwind', '--no-tailwind',
...@@ -49,72 +50,73 @@ describe.skip('create-next-app with package manager yarn', () => { ...@@ -49,72 +50,73 @@ describe.skip('create-next-app with package manager yarn', () => {
}) })
}) })
}) })
})
it('should use yarn when user-agent is yarn', async () => { it('should use yarn when user-agent is yarn', async () => {
await useTempDir(async (cwd) => { await useTempDir(async (cwd) => {
const projectName = 'user-agent-yarn' const projectName = 'user-agent-yarn'
const res = await run( const res = await run(
[ [
projectName, projectName,
'--ts', '--ts',
'--app', '--app',
'--no-eslint', '--no-turbo',
'--no-src-dir', '--no-eslint',
'--no-tailwind', '--no-src-dir',
'--no-import-alias', '--no-tailwind',
], '--no-import-alias',
'canary', ],
{ 'canary',
cwd, {
env: { npm_config_user_agent: 'yarn' }, cwd,
} env: { npm_config_user_agent: 'yarn' },
) }
)
expect(res.exitCode).toBe(0) expect(res.exitCode).toBe(0)
projectFilesShouldExist({ projectFilesShouldExist({
cwd, cwd,
projectName, projectName,
files, files,
})
}) })
}) })
})
it('should use yarn for --use-yarn flag with example', async () => { it('should use yarn for --use-yarn flag with example', async () => {
await useTempDir(async (cwd) => { await useTempDir(async (cwd) => {
const projectName = 'use-yarn-with-example' const projectName = 'use-yarn-with-example'
const res = await run( const res = await run(
[projectName, '--use-yarn', '--example', FULL_EXAMPLE_PATH], [projectName, '--use-yarn', '--example', FULL_EXAMPLE_PATH],
'canary', 'canary',
{ cwd } { cwd }
) )
expect(res.exitCode).toBe(0) expect(res.exitCode).toBe(0)
projectFilesShouldExist({ projectFilesShouldExist({
cwd, cwd,
projectName, projectName,
files, files,
})
}) })
}) })
})
it('should use yarn when user-agent is yarn with example', async () => { it('should use yarn when user-agent is yarn with example', async () => {
await useTempDir(async (cwd) => { await useTempDir(async (cwd) => {
const projectName = 'user-agent-yarn-with-example' const projectName = 'user-agent-yarn-with-example'
const res = await run( const res = await run(
[projectName, '--example', FULL_EXAMPLE_PATH], [projectName, '--example', FULL_EXAMPLE_PATH],
'canary', 'canary',
{ {
cwd, cwd,
env: { npm_config_user_agent: 'yarn' }, env: { npm_config_user_agent: 'yarn' },
} }
) )
expect(res.exitCode).toBe(0) expect(res.exitCode).toBe(0)
projectFilesShouldExist({ projectFilesShouldExist({
cwd, cwd,
projectName, projectName,
files, files,
})
}) })
}) })
}) })
...@@ -22,6 +22,7 @@ describe.skip('create-next-app prompts', () => { ...@@ -22,6 +22,7 @@ describe.skip('create-next-app prompts', () => {
'--ts', '--ts',
'--app', '--app',
'--eslint', '--eslint',
'--no-turbo',
'--no-src-dir', '--no-src-dir',
'--no-tailwind', '--no-tailwind',
'--no-import-alias', '--no-import-alias',
...@@ -59,6 +60,7 @@ describe.skip('create-next-app prompts', () => { ...@@ -59,6 +60,7 @@ describe.skip('create-next-app prompts', () => {
projectName, projectName,
'--app', '--app',
'--eslint', '--eslint',
'--no-turbo',
'--no-tailwind', '--no-tailwind',
'--no-src-dir', '--no-src-dir',
'--no-import-alias', '--no-import-alias',
...@@ -95,6 +97,7 @@ describe.skip('create-next-app prompts', () => { ...@@ -95,6 +97,7 @@ describe.skip('create-next-app prompts', () => {
'--ts', '--ts',
'--app', '--app',
'--eslint', '--eslint',
'--no-turbo',
'--no-src-dir', '--no-src-dir',
'--no-import-alias', '--no-import-alias',
], ],
...@@ -130,6 +133,7 @@ describe.skip('create-next-app prompts', () => { ...@@ -130,6 +133,7 @@ describe.skip('create-next-app prompts', () => {
'--ts', '--ts',
'--app', '--app',
'--eslint', '--eslint',
'--no-turbo',
'--no-tailwind', '--no-tailwind',
'--no-src-dir', '--no-src-dir',
], ],
......
import { join } from 'node:path'
import { import {
createNextApp, createNextApp,
projectShouldHaveNoGitChanges, projectShouldHaveNoGitChanges,
...@@ -7,7 +8,7 @@ import { ...@@ -7,7 +8,7 @@ import {
useTempDir, useTempDir,
} from '../utils' } from '../utils'
let testVersion let testVersion: string
beforeAll(async () => { beforeAll(async () => {
if (testVersion) return if (testVersion) return
// TODO: investigate moving this post publish or create deployed GH#57025 // TODO: investigate moving this post publish or create deployed GH#57025
...@@ -222,4 +223,32 @@ describe.skip('create-next-app --app (App Router)', () => { ...@@ -222,4 +223,32 @@ describe.skip('create-next-app --app (App Router)', () => {
}) })
}) })
}) })
it('should enable turbopack dev with --turbo flag', async () => {
await useTempDir(async (cwd) => {
const projectName = 'app-turbo'
const childProcess = createNextApp(
[
projectName,
'--ts',
'--app',
'--eslint',
'--turbo',
'--no-src-dir',
'--no-tailwind',
'--no-import-alias',
],
{
cwd,
},
testVersion
)
const exitCode = await spawnExitPromise(childProcess)
expect(exitCode).toBe(0)
const projectRoot = join(cwd, projectName)
const pkgJson = require(join(projectRoot, 'package.json'))
expect(pkgJson.scripts.dev).toBe('next dev --turbo')
})
})
}) })
import { join } from 'node:path'
import { import {
createNextApp, createNextApp,
projectShouldHaveNoGitChanges, projectShouldHaveNoGitChanges,
...@@ -7,7 +8,7 @@ import { ...@@ -7,7 +8,7 @@ import {
useTempDir, useTempDir,
} from '../utils' } from '../utils'
let testVersion let testVersion: string
beforeAll(async () => { beforeAll(async () => {
// TODO: investigate moving this post publish or create deployed GH#57025 // TODO: investigate moving this post publish or create deployed GH#57025
// tarballs to avoid these failing while a publish is in progress // tarballs to avoid these failing while a publish is in progress
...@@ -232,4 +233,32 @@ describe.skip('create-next-app --no-app (Pages Router)', () => { ...@@ -232,4 +233,32 @@ describe.skip('create-next-app --no-app (Pages Router)', () => {
}) })
}) })
}) })
it('should enable turbopack dev with --turbo flag', async () => {
await useTempDir(async (cwd) => {
const projectName = 'pages-turbo'
const childProcess = createNextApp(
[
projectName,
'--ts',
'--no-app',
'--eslint',
'--turbo',
'--no-src-dir',
'--no-tailwind',
'--no-import-alias',
],
{
cwd,
},
testVersion
)
const exitCode = await spawnExitPromise(childProcess)
expect(exitCode).toBe(0)
const projectRoot = join(cwd, projectName)
const pkgJson = require(join(projectRoot, 'package.json'))
expect(pkgJson.scripts.dev).toBe('next dev --turbo')
})
})
}) })
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment