@@ -7,10 +7,7 @@ import {
7
7
CLIENT_SDK_CONFIG_FILE ,
8
8
clientBuildContext ,
9
9
clientWebpackConfig ,
10
- EDGE_SDK_CONFIG_FILE ,
11
- edgeBuildContext ,
12
10
exportedNextConfig ,
13
- SERVER_SDK_CONFIG_FILE ,
14
11
serverBuildContext ,
15
12
serverWebpackConfig ,
16
13
userNextConfig ,
@@ -88,143 +85,22 @@ describe('constructWebpackConfigFunction()', () => {
88
85
} ) ;
89
86
90
87
describe ( 'webpack `entry` property config' , ( ) => {
91
- const serverConfigFilePath = `./${ SERVER_SDK_CONFIG_FILE } ` ;
92
88
const clientConfigFilePath = `./${ CLIENT_SDK_CONFIG_FILE } ` ;
93
- const edgeConfigFilePath = `./${ EDGE_SDK_CONFIG_FILE } ` ;
94
-
95
- it ( 'handles various entrypoint shapes' , async ( ) => {
96
- const finalWebpackConfig = await materializeFinalWebpackConfig ( {
97
- exportedNextConfig,
98
- incomingWebpackConfig : serverWebpackConfig ,
99
- incomingWebpackBuildContext : serverBuildContext ,
100
- } ) ;
101
-
102
- expect ( finalWebpackConfig . entry ) . toEqual (
103
- expect . objectContaining ( {
104
- // original entrypoint value is a string
105
- // (was 'private-next-pages/_error.js')
106
- 'pages/_error' : [ serverConfigFilePath , 'private-next-pages/_error.js' ] ,
107
-
108
- // original entrypoint value is a string array
109
- // (was ['./node_modules/smellOVision/index.js', 'private-next-pages/sniffTour.js'])
110
- 'pages/sniffTour' : [
111
- serverConfigFilePath ,
112
- './node_modules/smellOVision/index.js' ,
113
- 'private-next-pages/sniffTour.js' ,
114
- ] ,
115
-
116
- // original entrypoint value is an object containing a string `import` value
117
- // (was { import: 'private-next-pages/api/simulator/dogStats/[name].js' })
118
- 'pages/api/simulator/dogStats/[name]' : {
119
- import : [ serverConfigFilePath , 'private-next-pages/api/simulator/dogStats/[name].js' ] ,
120
- } ,
121
-
122
- // original entrypoint value is an object containing a string array `import` value
123
- // (was { import: ['./node_modules/dogPoints/converter.js', 'private-next-pages/simulator/leaderboard.js'] })
124
- 'pages/simulator/leaderboard' : {
125
- import : [
126
- serverConfigFilePath ,
127
- './node_modules/dogPoints/converter.js' ,
128
- 'private-next-pages/simulator/leaderboard.js' ,
129
- ] ,
130
- } ,
131
-
132
- // original entrypoint value is an object containg properties besides `import`
133
- // (was { import: 'private-next-pages/api/tricks/[trickName].js', dependOn: 'treats', })
134
- 'pages/api/tricks/[trickName]' : {
135
- import : [ serverConfigFilePath , 'private-next-pages/api/tricks/[trickName].js' ] ,
136
- dependOn : 'treats' , // untouched
137
- } ,
138
- } ) ,
139
- ) ;
140
- } ) ;
141
89
142
90
it ( 'injects user config file into `_app` in server bundle and in the client bundle' , async ( ) => {
143
- const finalServerWebpackConfig = await materializeFinalWebpackConfig ( {
144
- exportedNextConfig,
145
- incomingWebpackConfig : serverWebpackConfig ,
146
- incomingWebpackBuildContext : serverBuildContext ,
147
- } ) ;
148
91
const finalClientWebpackConfig = await materializeFinalWebpackConfig ( {
149
92
exportedNextConfig,
150
93
incomingWebpackConfig : clientWebpackConfig ,
151
94
incomingWebpackBuildContext : clientBuildContext ,
152
95
} ) ;
153
96
154
- expect ( finalServerWebpackConfig . entry ) . toEqual (
155
- expect . objectContaining ( {
156
- 'pages/_app' : expect . arrayContaining ( [ serverConfigFilePath ] ) ,
157
- } ) ,
158
- ) ;
159
97
expect ( finalClientWebpackConfig . entry ) . toEqual (
160
98
expect . objectContaining ( {
161
99
'pages/_app' : expect . arrayContaining ( [ clientConfigFilePath ] ) ,
162
100
} ) ,
163
101
) ;
164
102
} ) ;
165
103
166
- it ( 'injects user config file into `_error` in server bundle but not client bundle' , async ( ) => {
167
- const finalServerWebpackConfig = await materializeFinalWebpackConfig ( {
168
- exportedNextConfig,
169
- incomingWebpackConfig : serverWebpackConfig ,
170
- incomingWebpackBuildContext : serverBuildContext ,
171
- } ) ;
172
- const finalClientWebpackConfig = await materializeFinalWebpackConfig ( {
173
- exportedNextConfig,
174
- incomingWebpackConfig : clientWebpackConfig ,
175
- incomingWebpackBuildContext : clientBuildContext ,
176
- } ) ;
177
-
178
- expect ( finalServerWebpackConfig . entry ) . toEqual (
179
- expect . objectContaining ( {
180
- 'pages/_error' : expect . arrayContaining ( [ serverConfigFilePath ] ) ,
181
- } ) ,
182
- ) ;
183
- expect ( finalClientWebpackConfig . entry ) . toEqual (
184
- expect . objectContaining ( {
185
- 'pages/_error' : expect . not . arrayContaining ( [ clientConfigFilePath ] ) ,
186
- } ) ,
187
- ) ;
188
- } ) ;
189
-
190
- it ( 'injects user config file into both API routes and non-API routes' , async ( ) => {
191
- const finalWebpackConfig = await materializeFinalWebpackConfig ( {
192
- exportedNextConfig,
193
- incomingWebpackConfig : serverWebpackConfig ,
194
- incomingWebpackBuildContext : serverBuildContext ,
195
- } ) ;
196
-
197
- expect ( finalWebpackConfig . entry ) . toEqual (
198
- expect . objectContaining ( {
199
- 'pages/api/simulator/dogStats/[name]' : {
200
- import : expect . arrayContaining ( [ serverConfigFilePath ] ) ,
201
- } ,
202
-
203
- 'pages/api/tricks/[trickName]' : expect . objectContaining ( {
204
- import : expect . arrayContaining ( [ serverConfigFilePath ] ) ,
205
- } ) ,
206
-
207
- 'pages/simulator/leaderboard' : {
208
- import : expect . arrayContaining ( [ serverConfigFilePath ] ) ,
209
- } ,
210
- } ) ,
211
- ) ;
212
- } ) ;
213
-
214
- it ( 'injects user config file into API middleware' , async ( ) => {
215
- const finalWebpackConfig = await materializeFinalWebpackConfig ( {
216
- exportedNextConfig,
217
- incomingWebpackConfig : serverWebpackConfig ,
218
- incomingWebpackBuildContext : edgeBuildContext ,
219
- } ) ;
220
-
221
- expect ( finalWebpackConfig . entry ) . toEqual (
222
- expect . objectContaining ( {
223
- middleware : [ edgeConfigFilePath , 'private-next-pages/middleware.js' ] ,
224
- } ) ,
225
- ) ;
226
- } ) ;
227
-
228
104
it ( 'does not inject anything into non-_app pages during client build' , async ( ) => {
229
105
const finalWebpackConfig = await materializeFinalWebpackConfig ( {
230
106
exportedNextConfig,
@@ -244,30 +120,5 @@ describe('constructWebpackConfigFunction()', () => {
244
120
simulatorBundle : './src/simulator/index.ts' ,
245
121
} ) ;
246
122
} ) ;
247
-
248
- it ( 'does not inject into routes included in `excludeServerRoutes`' , async ( ) => {
249
- const nextConfigWithExcludedRoutes = {
250
- ...exportedNextConfig ,
251
- sentry : {
252
- excludeServerRoutes : [ / s i m u l a t o r / ] ,
253
- } ,
254
- } ;
255
- const finalWebpackConfig = await materializeFinalWebpackConfig ( {
256
- exportedNextConfig : nextConfigWithExcludedRoutes ,
257
- incomingWebpackConfig : serverWebpackConfig ,
258
- incomingWebpackBuildContext : serverBuildContext ,
259
- } ) ;
260
-
261
- expect ( finalWebpackConfig . entry ) . toEqual (
262
- expect . objectContaining ( {
263
- 'pages/simulator/leaderboard' : {
264
- import : expect . not . arrayContaining ( [ serverConfigFilePath ] ) ,
265
- } ,
266
- 'pages/api/simulator/dogStats/[name]' : {
267
- import : expect . not . arrayContaining ( [ serverConfigFilePath ] ) ,
268
- } ,
269
- } ) ,
270
- ) ;
271
- } ) ;
272
123
} ) ;
273
124
} ) ;
0 commit comments