@@ -102,8 +102,12 @@ describe('constructWebpackConfigFunction()', () => {
102
102
'pages/_error' : [ serverConfigFilePath , 'private-next-pages/_error.js' ] ,
103
103
104
104
// original entrypoint value is a string array
105
- // (was ['./node_modules/smellOVision/index.js', 'private-next-pages/_app.js'])
106
- 'pages/_app' : [ serverConfigFilePath , './node_modules/smellOVision/index.js' , 'private-next-pages/_app.js' ] ,
105
+ // (was ['./node_modules/smellOVision/index.js', 'private-next-pages/sniffTour.js'])
106
+ 'pages/sniffTour' : [
107
+ serverConfigFilePath ,
108
+ './node_modules/smellOVision/index.js' ,
109
+ 'private-next-pages/sniffTour.js' ,
110
+ ] ,
107
111
108
112
// original entrypoint value is an object containing a string `import` value
109
113
// (was { import: 'private-next-pages/api/simulator/dogStats/[name].js' })
@@ -112,12 +116,12 @@ describe('constructWebpackConfigFunction()', () => {
112
116
} ,
113
117
114
118
// original entrypoint value is an object containing a string array `import` value
115
- // (was { import: ['./node_modules/dogPoints/converter.js', 'private-next-pages/api/ simulator/leaderboard.js'] })
116
- 'pages/api/ simulator/leaderboard' : {
119
+ // (was { import: ['./node_modules/dogPoints/converter.js', 'private-next-pages/simulator/leaderboard.js'] })
120
+ 'pages/simulator/leaderboard' : {
117
121
import : [
118
122
serverConfigFilePath ,
119
123
'./node_modules/dogPoints/converter.js' ,
120
- 'private-next-pages/api/ simulator/leaderboard.js' ,
124
+ 'private-next-pages/simulator/leaderboard.js' ,
121
125
] ,
122
126
} ,
123
127
@@ -131,7 +135,7 @@ describe('constructWebpackConfigFunction()', () => {
131
135
) ;
132
136
} ) ;
133
137
134
- it ( 'injects user config file into `_app` in both server and client bundles ' , async ( ) => {
138
+ it ( 'injects user config file into `_app` in client bundle but not in server bundle ' , async ( ) => {
135
139
const finalServerWebpackConfig = await materializeFinalWebpackConfig ( {
136
140
exportedNextConfig,
137
141
incomingWebpackConfig : serverWebpackConfig ,
@@ -145,7 +149,7 @@ describe('constructWebpackConfigFunction()', () => {
145
149
146
150
expect ( finalServerWebpackConfig . entry ) . toEqual (
147
151
expect . objectContaining ( {
148
- 'pages/_app' : expect . arrayContaining ( [ serverConfigFilePath ] ) ,
152
+ 'pages/_app' : expect . not . arrayContaining ( [ serverConfigFilePath ] ) ,
149
153
} ) ,
150
154
) ;
151
155
expect ( finalClientWebpackConfig . entry ) . toEqual (
@@ -179,7 +183,7 @@ describe('constructWebpackConfigFunction()', () => {
179
183
) ;
180
184
} ) ;
181
185
182
- it ( 'injects user config file into API routes' , async ( ) => {
186
+ it ( 'injects user config file into both API routes and non- API routes' , async ( ) => {
183
187
const finalWebpackConfig = await materializeFinalWebpackConfig ( {
184
188
exportedNextConfig,
185
189
incomingWebpackConfig : serverWebpackConfig ,
@@ -192,13 +196,13 @@ describe('constructWebpackConfigFunction()', () => {
192
196
import : expect . arrayContaining ( [ serverConfigFilePath ] ) ,
193
197
} ,
194
198
195
- 'pages/api/simulator/leaderboard' : {
196
- import : expect . arrayContaining ( [ serverConfigFilePath ] ) ,
197
- } ,
198
-
199
199
'pages/api/tricks/[trickName]' : expect . objectContaining ( {
200
200
import : expect . arrayContaining ( [ serverConfigFilePath ] ) ,
201
201
} ) ,
202
+
203
+ 'pages/simulator/leaderboard' : {
204
+ import : expect . arrayContaining ( [ serverConfigFilePath ] ) ,
205
+ } ,
202
206
} ) ,
203
207
) ;
204
208
} ) ;
@@ -218,19 +222,24 @@ describe('constructWebpackConfigFunction()', () => {
218
222
) ;
219
223
} ) ;
220
224
221
- it ( 'does not inject anything into non-_app, non-_error, non-API routes ' , async ( ) => {
225
+ it ( 'does not inject anything into non-_app pages during client build ' , async ( ) => {
222
226
const finalWebpackConfig = await materializeFinalWebpackConfig ( {
223
227
exportedNextConfig,
224
228
incomingWebpackConfig : clientWebpackConfig ,
225
229
incomingWebpackBuildContext : clientBuildContext ,
226
230
} ) ;
227
231
228
- expect ( finalWebpackConfig . entry ) . toEqual (
229
- expect . objectContaining ( {
230
- // no injected file
231
- main : './src/index.ts' ,
232
- } ) ,
233
- ) ;
232
+ expect ( finalWebpackConfig . entry ) . toEqual ( {
233
+ main : './src/index.ts' ,
234
+ // only _app has config file injected
235
+ 'pages/_app' : [ clientConfigFilePath , 'next-client-pages-loader?page=%2F_app' ] ,
236
+ 'pages/_error' : 'next-client-pages-loader?page=%2F_error' ,
237
+ 'pages/sniffTour' : [ './node_modules/smellOVision/index.js' , 'private-next-pages/sniffTour.js' ] ,
238
+ 'pages/simulator/leaderboard' : {
239
+ import : [ './node_modules/dogPoints/converter.js' , 'private-next-pages/simulator/leaderboard.js' ] ,
240
+ } ,
241
+ simulatorBundle : './src/simulator/index.ts' ,
242
+ } ) ;
234
243
} ) ;
235
244
} ) ;
236
245
} ) ;
0 commit comments