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
18 lines
1.1 KiB
JavaScript
18 lines
1.1 KiB
JavaScript
/* global jest */
|
|
jest.autoMockOff()
|
|
const defineTest = require('jscodeshift/dist/testUtils').defineTest
|
|
|
|
const fixtureDir = 'next-experimental-turbo-to-turbopack'
|
|
|
|
defineTest(__dirname, fixtureDir, null, `${fixtureDir}/commonjs-var`, { parser: 'js' })
|
|
defineTest(__dirname, fixtureDir, null, `${fixtureDir}/esm`, { parser: 'js' })
|
|
defineTest(__dirname, fixtureDir, null, `${fixtureDir}/mixed-config`, { parser: 'js' })
|
|
defineTest(__dirname, fixtureDir, null, `${fixtureDir}/modified-var`, { parser: 'js' })
|
|
defineTest(__dirname, fixtureDir, null, `${fixtureDir}/wrapped-function`, { parser: 'js' })
|
|
defineTest(__dirname, fixtureDir, null, `${fixtureDir}/no-change`, { parser: 'js' })
|
|
defineTest(__dirname, fixtureDir, null, `${fixtureDir}/property-assignment`, { parser: 'js' })
|
|
defineTest(__dirname, fixtureDir, null, `${fixtureDir}/typescript-as-const`, { parser: 'ts' })
|
|
defineTest(__dirname, fixtureDir, null, `${fixtureDir}/typescript`, { parser: 'ts' })
|
|
defineTest(__dirname, fixtureDir, null, `${fixtureDir}/typescript-satisfies`, { parser: 'ts' })
|
|
defineTest(__dirname, fixtureDir, null, `${fixtureDir}/typescript-satisfies-wrapped`, { parser: 'ts' })
|