Unverified Commit 498c7fce authored by Benjamin Woodruff's avatar Benjamin Woodruff Committed by GitHub

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.
parent 5834e0cb
...@@ -188,8 +188,6 @@ Turbopack can be configured via `next.config.js` (or `next.config.ts`) under the ...@@ -188,8 +188,6 @@ Turbopack can be configured via `next.config.js` (or `next.config.ts`) under the
Change or extend file extensions for module resolution. Change or extend file extensions for module resolution.
- **`moduleIds`** - **`moduleIds`**
Set how module IDs are generated (`'named'` vs `'deterministic'`). Set how module IDs are generated (`'named'` vs `'deterministic'`).
- **`memoryLimit`**
Set a memory limit (in bytes) for Turbopack.
```js filename="next.config.js" ```js filename="next.config.js"
module.exports = { module.exports = {
......
...@@ -8,7 +8,6 @@ import type { SizeLimit } from '../types' ...@@ -8,7 +8,6 @@ import type { SizeLimit } from '../types'
import type { import type {
ExportPathMap, ExportPathMap,
TurbopackLoaderItem, TurbopackLoaderItem,
DeprecatedExperimentalTurboOptions,
TurbopackOptions, TurbopackOptions,
TurbopackRuleConfigItem, TurbopackRuleConfigItem,
TurbopackRuleConfigCollection, TurbopackRuleConfigCollection,
...@@ -163,32 +162,6 @@ const zTurbopackConfig: zod.ZodType<TurbopackOptions> = z.strictObject({ ...@@ -163,32 +162,6 @@ const zTurbopackConfig: zod.ZodType<TurbopackOptions> = z.strictObject({
root: z.string().optional(), root: z.string().optional(),
}) })
// Same as zTurbopackConfig but with deprecated properties. Unfortunately, base
// properties are duplicated here as `ZodType`s do not export `extend()`.
const zDeprecatedExperimentalTurboConfig: zod.ZodType<DeprecatedExperimentalTurboOptions> =
z.strictObject({
loaders: z.record(z.string(), z.array(zTurbopackLoaderItem)).optional(),
rules: z.record(z.string(), zTurbopackRuleConfigCollection).optional(),
resolveAlias: z
.record(
z.string(),
z.union([
z.string(),
z.array(z.string()),
z.record(z.string(), z.union([z.string(), z.array(z.string())])),
])
)
.optional(),
resolveExtensions: z.array(z.string()).optional(),
treeShaking: z.boolean().optional(),
persistentCaching: z.union([z.number(), z.literal(false)]).optional(),
memoryLimit: z.number().optional(),
moduleIds: z.enum(['named', 'deterministic']).optional(),
minify: z.boolean().optional(),
sourceMaps: z.boolean().optional(),
root: z.string().optional(),
})
export const configSchema: zod.ZodType<NextConfig> = z.lazy(() => export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
z.strictObject({ z.strictObject({
allowedDevOrigins: z.array(z.string()).optional(), allowedDevOrigins: z.array(z.string()).optional(),
...@@ -462,10 +435,6 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() => ...@@ -462,10 +435,6 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
typedRoutes: z.boolean().optional(), typedRoutes: z.boolean().optional(),
webpackBuildWorker: z.boolean().optional(), webpackBuildWorker: z.boolean().optional(),
webpackMemoryOptimizations: z.boolean().optional(), webpackMemoryOptimizations: z.boolean().optional(),
/**
* @deprecated Use `config.turbopack` instead.
*/
turbo: zDeprecatedExperimentalTurboConfig.optional(),
turbopackMemoryLimit: z.number().optional(), turbopackMemoryLimit: z.number().optional(),
turbopackMinify: z.boolean().optional(), turbopackMinify: z.boolean().optional(),
turbopackPersistentCaching: z.boolean().optional(), turbopackPersistentCaching: z.boolean().optional(),
......
...@@ -25,7 +25,7 @@ export type NextConfigComplete = Required<NextConfig> & { ...@@ -25,7 +25,7 @@ export type NextConfigComplete = Required<NextConfig> & {
// override NextConfigComplete.experimental.htmlLimitedBots to string // override NextConfigComplete.experimental.htmlLimitedBots to string
// because it's not defined in NextConfigComplete.experimental // because it's not defined in NextConfigComplete.experimental
htmlLimitedBots: string | undefined htmlLimitedBots: string | undefined
experimental: Omit<ExperimentalConfig, 'turbo'> experimental: ExperimentalConfig
} }
export type I18NDomains = readonly DomainLocale[] export type I18NDomains = readonly DomainLocale[]
...@@ -182,40 +182,6 @@ export interface TurbopackOptions { ...@@ -182,40 +182,6 @@ export interface TurbopackOptions {
root?: string root?: string
} }
export interface DeprecatedExperimentalTurboOptions extends TurbopackOptions {
/**
* (`next --turbopack` only) A list of webpack loaders to apply when running with Turbopack.
*
* @deprecated Use `rules` instead.
* @see [Turbopack Loaders](https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack#configuring-webpack-loaders)
*/
loaders?: Record<string, TurbopackLoaderItem[]>
/**
* A target memory limit for turbo, in bytes.
* @deprecated Use `experimental.turbopackMemoryLimit` instead.
*/
memoryLimit?: number
/**
* Enable minification. Defaults to true in build mode and false in dev mode.
* @deprecated Use `experimental.turbopackMinify` instead.
*/
minify?: boolean
/**
* Enable tree shaking for the turbopack dev server and build.
* @deprecated Use `experimental.turbopackTreeShaking` instead.
*/
treeShaking?: boolean
/**
* Enable source maps. Defaults to true.
* @deprecated Use `experimental.turbopackSourceMaps` instead.
*/
sourceMaps?: boolean
}
export interface WebpackConfigContext { export interface WebpackConfigContext {
/** Next.js root directory */ /** Next.js root directory */
dir: string dir: string
...@@ -444,12 +410,6 @@ export interface ExperimentalConfig { ...@@ -444,12 +410,6 @@ export interface ExperimentalConfig {
*/ */
optimizeServerReact?: boolean optimizeServerReact?: boolean
/**
* @deprecated Use `config.turbopack` instead.
* Run `npx @next/codemod@latest next-experimental-turbo-to-turbopack .` to migrate automatically.
*/
turbo?: DeprecatedExperimentalTurboOptions
/** /**
* A target memory limit for turbo, in bytes. * A target memory limit for turbo, in bytes.
*/ */
...@@ -1487,7 +1447,6 @@ export const defaultConfig = Object.freeze({ ...@@ -1487,7 +1447,6 @@ export const defaultConfig = Object.freeze({
disablePostcssPresetEnv: undefined, disablePostcssPresetEnv: undefined,
amp: undefined, amp: undefined,
urlImports: undefined, urlImports: undefined,
turbo: undefined,
typedEnv: false, typedEnv: false,
clientTraceMetadata: undefined, clientTraceMetadata: undefined,
parallelServerCompiles: false, parallelServerCompiles: false,
......
...@@ -16,7 +16,6 @@ import type { ...@@ -16,7 +16,6 @@ import type {
ExperimentalConfig, ExperimentalConfig,
NextConfigComplete, NextConfigComplete,
NextConfig, NextConfig,
TurbopackLoaderItem,
} from './config-shared' } from './config-shared'
import { loadWebpackHook } from './config-utils' import { loadWebpackHook } from './config-utils'
...@@ -1458,7 +1457,7 @@ export default async function loadConfig( ...@@ -1458,7 +1457,7 @@ export default async function loadConfig(
) as (keyof ExperimentalConfig)[]) { ) as (keyof ExperimentalConfig)[]) {
const value = loadedConfig.experimental[name] const value = loadedConfig.experimental[name]
if (name === 'turbo' && !process.env.TURBOPACK) { if (name.startsWith('turbopack') && !process.env.TURBOPACK) {
// Ignore any Turbopack config if Turbopack is not enabled // Ignore any Turbopack config if Turbopack is not enabled
continue continue
} }
...@@ -1502,47 +1501,6 @@ export default async function loadConfig( ...@@ -1502,47 +1501,6 @@ export default async function loadConfig(
userConfig.reactProductionProfiling = reactProductionProfiling userConfig.reactProductionProfiling = reactProductionProfiling
} }
if (
userConfig.experimental?.turbo?.loaders &&
!userConfig.experimental?.turbo?.rules
) {
curLog.warn(
'experimental.turbo.loaders is now deprecated. Please update next.config.js to use experimental.turbo.rules as soon as possible.\n' +
'The new option is similar, but the key should be a glob instead of an extension.\n' +
'Example: loaders: { ".mdx": ["mdx-loader"] } -> rules: { "*.mdx": ["mdx-loader"] }" }\n' +
'See more info here https://nextjs.org/docs/app/api-reference/next-config-js/turbo'
)
const rules: Record<string, TurbopackLoaderItem[]> = {}
for (const [ext, loaders] of Object.entries(
userConfig.experimental.turbo.loaders
)) {
rules['*' + ext] = loaders as TurbopackLoaderItem[]
}
userConfig.experimental.turbo.rules = rules
}
if (userConfig.experimental?.turbo) {
curLog.warn(
'The config property `experimental.turbo` is deprecated. Move this setting to `config.turbopack` or run `npx @next/codemod@latest next-experimental-turbo-to-turbopack .`'
)
// Merge the two configs, preferring values in `config.turbopack`.
userConfig.turbopack = {
...userConfig.experimental.turbo,
...userConfig.turbopack,
}
userConfig.experimental.turbopackMemoryLimit ??=
userConfig.experimental.turbo.memoryLimit
userConfig.experimental.turbopackMinify ??=
userConfig.experimental.turbo.minify
userConfig.experimental.turbopackTreeShaking ??=
userConfig.experimental.turbo.treeShaking
userConfig.experimental.turbopackSourceMaps ??=
userConfig.experimental.turbo.sourceMaps
}
if (userConfig.experimental?.useLightningcss) { if (userConfig.experimental?.useLightningcss) {
const { loadBindings } = const { loadBindings } =
require('../build/swc') as typeof import('../build/swc') require('../build/swc') as typeof import('../build/swc')
......
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>{children}</body>
</html>
)
}
import foo from 'foo'
export default function Page() {
return <div id="result">Hello {foo}</div>
}
/* eslint-disable jest/no-standalone-expect */
import { nextTestSetup } from 'e2e-utils'
;(process.env.IS_TURBOPACK_TEST ? describe : describe.skip)(
'turbopack-turbo-config-compatibility',
() => {
describe('including both turbopack and deprecated experimental turbo config', () => {
const { next } = nextTestSetup({
files: __dirname,
})
it('prefers turbopack config over deprecated experimental turbo config', async () => {
const $ = await next.render$('/')
expect($('#result').text()).toEqual('Hello turbopack')
})
})
describe('only including deprecated experimental turbo config', () => {
const { next } = nextTestSetup({
files: __dirname,
overrideFiles: {
'next.config.js': `module.exports = {
experimental: {
turbo: {
resolveAlias: {
foo: './turbo.js',
},
},
},
}`,
},
})
it('still uses the deprecated experimental turbo config', async () => {
const $ = await next.render$('/')
expect($('#result').text()).toEqual('Hello turbo')
})
})
}
)
module.exports = {
turbopack: {
resolveAlias: {
foo: './turbopack.js',
},
},
experimental: {
turbo: {
resolveAlias: {
foo: './turbo.js',
},
},
},
}
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