Skip to content

Commit f9d4066

Browse files
authored
feat(next-codemod): add app-dir-runtime-config-experimental-edge (#70968)
### Why? We had breaking change in App Router at #70480 where it strictly checks `runtime` route segment config. If it is set to `experimental-edge`, will throw. Therefore we support a codemod to replace it to `edge`.
1 parent 3f39303 commit f9d4066

File tree

11 files changed

+90
-0
lines changed

11 files changed

+90
-0
lines changed

packages/next-codemod/lib/utils.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,10 @@ export const TRANSFORMER_INQUIRER_CHOICES = [
116116
value: 'next-async-request-api',
117117
version: '15.0.0-canary.171',
118118
},
119+
{
120+
title:
121+
'Transforms `experimental-edge` to `edge` in the `runtime` route segment configuration within the App Router',
122+
value: 'app-dir-runtime-config-experimental-edge',
123+
version: '15.0.0-canary.179',
124+
},
119125
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const runtime = "edge";
2+
export default function Page() {
3+
return <div>hello world</div>;
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const runtime = "edge";
2+
export default function Page() {
3+
return <div>hello world</div>;
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const runtime = "experimental-edge";
2+
export default function Page() {
3+
return <div>hello world</div>;
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const runtime = "edge";
2+
export default function Page() {
3+
return <div>hello world</div>;
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function Page() {
2+
return <div>hello world</div>;
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export default function Page() {
2+
return <div>hello world</div>;
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const runtime = "nodejs";
2+
export default function Page() {
3+
return <div>hello world</div>;
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export const runtime = "nodejs";
2+
export default function Page() {
3+
return <div>hello world</div>;
4+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/* global jest */
2+
jest.autoMockOff()
3+
const defineTest = require('jscodeshift/dist/testUtils').defineTest
4+
const { readdirSync } = require('fs')
5+
const { join } = require('path')
6+
const fixtureDir = 'app-dir-runtime-config-experimental-edge'
7+
const fixtureDirPath = join(__dirname, '..', '__testfixtures__', fixtureDir)
8+
const fixtures = readdirSync(fixtureDirPath)
9+
.filter(file => file.endsWith('.input.tsx'))
10+
.map(file => file.replace('.input.tsx', ''))
11+
for (const fixture of fixtures) {
12+
const prefix = `${fixtureDir}/${fixture}`;
13+
defineTest(__dirname, fixtureDir, null, prefix, { parser: 'tsx' });
14+
}

0 commit comments

Comments
 (0)