Skip to content

Commit 498c7fc

Browse files
authored
Turbopack: Remove the deprecated .turbo config object (#84109)
This config name was previously deprecated in a 15.x release (renamed to `turbopack`), and there's already a codemod to migrate these over.
1 parent 5834e0c commit 498c7fc

File tree

10 files changed

+2
-185
lines changed

10 files changed

+2
-185
lines changed

docs/01-app/03-api-reference/08-turbopack.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,6 @@ Turbopack can be configured via `next.config.js` (or `next.config.ts`) under the
188188
Change or extend file extensions for module resolution.
189189
- **`moduleIds`**
190190
Set how module IDs are generated (`'named'` vs `'deterministic'`).
191-
- **`memoryLimit`**
192-
Set a memory limit (in bytes) for Turbopack.
193191

194192
```js filename="next.config.js"
195193
module.exports = {

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

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import type { SizeLimit } from '../types'
88
import type {
99
ExportPathMap,
1010
TurbopackLoaderItem,
11-
DeprecatedExperimentalTurboOptions,
1211
TurbopackOptions,
1312
TurbopackRuleConfigItem,
1413
TurbopackRuleConfigCollection,
@@ -163,32 +162,6 @@ const zTurbopackConfig: zod.ZodType<TurbopackOptions> = z.strictObject({
163162
root: z.string().optional(),
164163
})
165164

166-
// Same as zTurbopackConfig but with deprecated properties. Unfortunately, base
167-
// properties are duplicated here as `ZodType`s do not export `extend()`.
168-
const zDeprecatedExperimentalTurboConfig: zod.ZodType<DeprecatedExperimentalTurboOptions> =
169-
z.strictObject({
170-
loaders: z.record(z.string(), z.array(zTurbopackLoaderItem)).optional(),
171-
rules: z.record(z.string(), zTurbopackRuleConfigCollection).optional(),
172-
resolveAlias: z
173-
.record(
174-
z.string(),
175-
z.union([
176-
z.string(),
177-
z.array(z.string()),
178-
z.record(z.string(), z.union([z.string(), z.array(z.string())])),
179-
])
180-
)
181-
.optional(),
182-
resolveExtensions: z.array(z.string()).optional(),
183-
treeShaking: z.boolean().optional(),
184-
persistentCaching: z.union([z.number(), z.literal(false)]).optional(),
185-
memoryLimit: z.number().optional(),
186-
moduleIds: z.enum(['named', 'deterministic']).optional(),
187-
minify: z.boolean().optional(),
188-
sourceMaps: z.boolean().optional(),
189-
root: z.string().optional(),
190-
})
191-
192165
export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
193166
z.strictObject({
194167
allowedDevOrigins: z.array(z.string()).optional(),
@@ -462,10 +435,6 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
462435
typedRoutes: z.boolean().optional(),
463436
webpackBuildWorker: z.boolean().optional(),
464437
webpackMemoryOptimizations: z.boolean().optional(),
465-
/**
466-
* @deprecated Use `config.turbopack` instead.
467-
*/
468-
turbo: zDeprecatedExperimentalTurboConfig.optional(),
469438
turbopackMemoryLimit: z.number().optional(),
470439
turbopackMinify: z.boolean().optional(),
471440
turbopackPersistentCaching: z.boolean().optional(),

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

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export type NextConfigComplete = Required<NextConfig> & {
2525
// override NextConfigComplete.experimental.htmlLimitedBots to string
2626
// because it's not defined in NextConfigComplete.experimental
2727
htmlLimitedBots: string | undefined
28-
experimental: Omit<ExperimentalConfig, 'turbo'>
28+
experimental: ExperimentalConfig
2929
}
3030

3131
export type I18NDomains = readonly DomainLocale[]
@@ -182,40 +182,6 @@ export interface TurbopackOptions {
182182
root?: string
183183
}
184184

185-
export interface DeprecatedExperimentalTurboOptions extends TurbopackOptions {
186-
/**
187-
* (`next --turbopack` only) A list of webpack loaders to apply when running with Turbopack.
188-
*
189-
* @deprecated Use `rules` instead.
190-
* @see [Turbopack Loaders](https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack#configuring-webpack-loaders)
191-
*/
192-
loaders?: Record<string, TurbopackLoaderItem[]>
193-
194-
/**
195-
* A target memory limit for turbo, in bytes.
196-
* @deprecated Use `experimental.turbopackMemoryLimit` instead.
197-
*/
198-
memoryLimit?: number
199-
200-
/**
201-
* Enable minification. Defaults to true in build mode and false in dev mode.
202-
* @deprecated Use `experimental.turbopackMinify` instead.
203-
*/
204-
minify?: boolean
205-
206-
/**
207-
* Enable tree shaking for the turbopack dev server and build.
208-
* @deprecated Use `experimental.turbopackTreeShaking` instead.
209-
*/
210-
treeShaking?: boolean
211-
212-
/**
213-
* Enable source maps. Defaults to true.
214-
* @deprecated Use `experimental.turbopackSourceMaps` instead.
215-
*/
216-
sourceMaps?: boolean
217-
}
218-
219185
export interface WebpackConfigContext {
220186
/** Next.js root directory */
221187
dir: string
@@ -444,12 +410,6 @@ export interface ExperimentalConfig {
444410
*/
445411
optimizeServerReact?: boolean
446412

447-
/**
448-
* @deprecated Use `config.turbopack` instead.
449-
* Run `npx @next/codemod@latest next-experimental-turbo-to-turbopack .` to migrate automatically.
450-
*/
451-
turbo?: DeprecatedExperimentalTurboOptions
452-
453413
/**
454414
* A target memory limit for turbo, in bytes.
455415
*/
@@ -1487,7 +1447,6 @@ export const defaultConfig = Object.freeze({
14871447
disablePostcssPresetEnv: undefined,
14881448
amp: undefined,
14891449
urlImports: undefined,
1490-
turbo: undefined,
14911450
typedEnv: false,
14921451
clientTraceMetadata: undefined,
14931452
parallelServerCompiles: false,

packages/next/src/server/config.ts

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import type {
1616
ExperimentalConfig,
1717
NextConfigComplete,
1818
NextConfig,
19-
TurbopackLoaderItem,
2019
} from './config-shared'
2120

2221
import { loadWebpackHook } from './config-utils'
@@ -1458,7 +1457,7 @@ export default async function loadConfig(
14581457
) as (keyof ExperimentalConfig)[]) {
14591458
const value = loadedConfig.experimental[name]
14601459

1461-
if (name === 'turbo' && !process.env.TURBOPACK) {
1460+
if (name.startsWith('turbopack') && !process.env.TURBOPACK) {
14621461
// Ignore any Turbopack config if Turbopack is not enabled
14631462
continue
14641463
}
@@ -1502,47 +1501,6 @@ export default async function loadConfig(
15021501
userConfig.reactProductionProfiling = reactProductionProfiling
15031502
}
15041503

1505-
if (
1506-
userConfig.experimental?.turbo?.loaders &&
1507-
!userConfig.experimental?.turbo?.rules
1508-
) {
1509-
curLog.warn(
1510-
'experimental.turbo.loaders is now deprecated. Please update next.config.js to use experimental.turbo.rules as soon as possible.\n' +
1511-
'The new option is similar, but the key should be a glob instead of an extension.\n' +
1512-
'Example: loaders: { ".mdx": ["mdx-loader"] } -> rules: { "*.mdx": ["mdx-loader"] }" }\n' +
1513-
'See more info here https://nextjs.org/docs/app/api-reference/next-config-js/turbo'
1514-
)
1515-
1516-
const rules: Record<string, TurbopackLoaderItem[]> = {}
1517-
for (const [ext, loaders] of Object.entries(
1518-
userConfig.experimental.turbo.loaders
1519-
)) {
1520-
rules['*' + ext] = loaders as TurbopackLoaderItem[]
1521-
}
1522-
1523-
userConfig.experimental.turbo.rules = rules
1524-
}
1525-
1526-
if (userConfig.experimental?.turbo) {
1527-
curLog.warn(
1528-
'The config property `experimental.turbo` is deprecated. Move this setting to `config.turbopack` or run `npx @next/codemod@latest next-experimental-turbo-to-turbopack .`'
1529-
)
1530-
1531-
// Merge the two configs, preferring values in `config.turbopack`.
1532-
userConfig.turbopack = {
1533-
...userConfig.experimental.turbo,
1534-
...userConfig.turbopack,
1535-
}
1536-
userConfig.experimental.turbopackMemoryLimit ??=
1537-
userConfig.experimental.turbo.memoryLimit
1538-
userConfig.experimental.turbopackMinify ??=
1539-
userConfig.experimental.turbo.minify
1540-
userConfig.experimental.turbopackTreeShaking ??=
1541-
userConfig.experimental.turbo.treeShaking
1542-
userConfig.experimental.turbopackSourceMaps ??=
1543-
userConfig.experimental.turbo.sourceMaps
1544-
}
1545-
15461504
if (userConfig.experimental?.useLightningcss) {
15471505
const { loadBindings } =
15481506
require('../build/swc') as typeof import('../build/swc')

test/e2e/turbopack-turbo-config-compatibility/app/layout.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

test/e2e/turbopack-turbo-config-compatibility/app/page.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

test/e2e/turbopack-turbo-config-compatibility/index.test.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.

test/e2e/turbopack-turbo-config-compatibility/next.config.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

test/e2e/turbopack-turbo-config-compatibility/turbo.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/e2e/turbopack-turbo-config-compatibility/turbopack.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)