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
+111-46
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,25 +64,46 @@ 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
-
| your-application/rendering/server-components
71
-
|
72
-
|
73
-
,-[1:1]
74
-
1 | import { cookies } from 'next/headers'
75
-
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
76
-
2 |
77
-
3 | export default function Page() {
78
-
4 | return <p>hello world</p>
79
-
\`----
80
-
81
-
Import trace for requested module:
82
-
./components/Comp.js
83
-
./pages/index.js"
91
+
"./components/Comp.js
92
+
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-
93
+
| your-application/rendering/server-components
94
+
|
95
+
|
96
+
,-[1:1]
97
+
1 | import { cookies } from 'next/headers'
98
+
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
99
+
2 |
100
+
3 | export default function Page() {
101
+
4 | return <p>hello world</p>
102
+
\`----
103
+
104
+
Import trace for requested module:
105
+
./components/Comp.js
106
+
./pages/index.js"
84
107
`)
85
108
}
86
109
})
@@ -118,28 +141,49 @@ 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-
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
-
| application/rendering/server-components
131
-
|
132
-
|
133
-
,-[1:1]
134
-
1 | import 'server-only'
135
-
: ^^^^^^^^^^^^^^^^^^^^
136
-
2 |
137
-
3 | export default function Page() {
138
-
4 | return 'hello world'
139
-
\`----
140
-
141
-
Import trace for requested module:"
142
-
`)
172
+
"./components/Comp.js
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-
174
+
| application/rendering/server-components
175
+
|
176
+
|
177
+
,-[1:1]
178
+
1 | import 'server-only'
179
+
: ^^^^^^^^^^^^^^^^^^^^
180
+
2 |
181
+
3 | export default function Page() {
182
+
4 | return 'hello world'
183
+
\`----
184
+
185
+
Import trace for requested module:"
186
+
`)
143
187
}
144
188
})
145
189
@@ -176,27 +220,48 @@ 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-
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
-
| application/rendering/server-components
189
-
|
190
-
|
191
-
,-[1:1]
192
-
1 | import { after } from 'next/server'
193
-
: ^^^^^
194
-
2 |
195
-
3 | export default function Page() {
196
-
4 | return 'hello world'
197
-
\`----
198
-
199
-
Import trace for requested module:"
251
+
"./components/Comp.js
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-
253
+
| application/rendering/server-components
254
+
|
255
+
|
256
+
,-[1:1]
257
+
1 | import { after } from 'next/server'
258
+
: ^^^^^
259
+
2 |
260
+
3 | export default function Page() {
261
+
4 | return 'hello world'
262
+
\`----
263
+
264
+
Import trace for requested module:"
200
265
`)
201
266
}
202
267
})
@@ -241,7 +306,7 @@ describe('Error Overlay for server components compiler errors in pages', () => {
0 commit comments