You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/development/acceptance/server-component-compiler-errors-in-pages.test.ts
+75-10
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,8 @@ import { nextTestSetup } from 'e2e-utils'
3
3
import{createSandbox}from'development-sandbox'
4
4
import{outdent}from'outdent'
5
5
6
+
constisRspack=process.env.NEXT_RSPACK!==undefined
7
+
6
8
constinitialFiles=newMap([
7
9
['app/_.js',''],// app dir need to exists, otherwise the SWC RSC checks will not run
8
10
[
@@ -62,18 +64,39 @@ describe('Error Overlay for server components compiler errors in pages', () => {
62
64
63
65
You're importing a component that needs "next/headers". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components"
╰─▶ × Error: x You're importing a component that needs "next/headers". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-
Error: x You're importing a component that needs "next/headers". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-
70
93
| your-application/rendering/server-components
71
-
|
72
-
|
94
+
|
95
+
|
73
96
,-[1:1]
74
97
1 | import { cookies } from 'next/headers'
75
98
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
76
-
2 |
99
+
2 |
77
100
3 | export default function Page() {
78
101
4 | return <p>hello world</p>
79
102
\`----
@@ -118,6 +141,27 @@ describe('Error Overlay for server components compiler errors in pages', () => {
118
141
119
142
You're importing a component that needs "server-only". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components"
╰─▶ × Error: x You're importing a component that needs "server-only". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-
154
+
│ | application/rendering/server-components
155
+
│ |
156
+
│ |
157
+
│ ,-[1:1]
158
+
│ 1 | import 'server-only'
159
+
│ : ^^^^^^^^^^^^^^^^^^^^
160
+
│ 2 |
161
+
│ 3 | export default function Page() {
162
+
│ 4 | return 'hello world'
163
+
│ \`----"
164
+
`)
121
165
}else{
122
166
expect(
123
167
takeUpToString(
@@ -128,12 +172,12 @@ describe('Error Overlay for server components compiler errors in pages', () => {
128
172
"./components/Comp.js
129
173
Error: x You're importing a component that needs "server-only". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-
130
174
| application/rendering/server-components
131
-
|
132
-
|
175
+
|
176
+
|
133
177
,-[1:1]
134
178
1 | import 'server-only'
135
179
: ^^^^^^^^^^^^^^^^^^^^
136
-
2 |
180
+
2 |
137
181
3 | export default function Page() {
138
182
4 | return 'hello world'
139
183
\`----
@@ -176,6 +220,27 @@ describe('Error Overlay for server components compiler errors in pages', () => {
176
220
177
221
You're importing a component that needs "after". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-application/rendering/server-components"
╰─▶ × Error: x You're importing a component that needs "after". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-
233
+
│ | application/rendering/server-components
234
+
│ |
235
+
│ |
236
+
│ ,-[1:1]
237
+
│ 1 | import { after } from 'next/server'
238
+
│ : ^^^^^
239
+
│ 2 |
240
+
│ 3 | export default function Page() {
241
+
│ 4 | return 'hello world'
242
+
│ \`----"
243
+
`)
179
244
}else{
180
245
expect(
181
246
takeUpToString(
@@ -186,12 +251,12 @@ describe('Error Overlay for server components compiler errors in pages', () => {
186
251
"./components/Comp.js
187
252
Error: x You're importing a component that needs "after". That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/app/building-your-
188
253
| application/rendering/server-components
189
-
|
190
-
|
254
+
|
255
+
|
191
256
,-[1:1]
192
257
1 | import { after } from 'next/server'
193
258
: ^^^^^
194
-
2 |
259
+
2 |
195
260
3 | export default function Page() {
196
261
4 | return 'hello world'
197
262
\`----
@@ -241,7 +306,7 @@ describe('Error Overlay for server components compiler errors in pages', () => {
0 commit comments