mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
This adds a new transform to `@next/codemod` that updates
`next.config.{js,ts}` that updates the deprecated `experimental.turbo`
property to the new top-level `turbopack` property.
Details:
- Only operates on files called next.config.js or next.config.ts, in the
case the codemod tool is run on a large codebase.
- Updates _any_ object literal with a `experimental.turbo` property to
use `turbopack`. Since this transform is constrained to Next.js configs,
there shouldn’t be many false positives.
- Much of this change was written by Copilot. I simplified it, and
refactored it to make it more readable and safe.
Test Plan:
- `pnpm run build && pnpm test -- -t
next-experimental-turbo-to-turbopack` in the codemod directory
- Tested on several publicly available next configs that used the
deprecated property
24 lines
498 B
JavaScript
24 lines
498 B
JavaScript
// Next.js config with wrapper function
|
|
const nextConfig = {
|
|
experimental: {
|
|
turbo: {
|
|
resolveAlias: {
|
|
underscore: 'lodash',
|
|
mocha: { browser: 'mocha/browser-entry.js' },
|
|
},
|
|
memoryLimit: 4096,
|
|
minify: true,
|
|
treeShaking: false,
|
|
sourceMaps: true
|
|
},
|
|
typedRoutes: true,
|
|
},
|
|
images: {
|
|
formats: ['image/avif', 'image/webp'],
|
|
},
|
|
};
|
|
|
|
// Wrapper function
|
|
const withMDX = require("@next/mdx")();
|
|
module.exports = withMDX(nextConfig);
|