@@ -102,8 +102,12 @@ describe('constructWebpackConfigFunction()', () => {
102102 'pages/_error' : [ serverConfigFilePath , 'private-next-pages/_error.js' ] ,
103103
104104 // 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+ ] ,
107111
108112 // original entrypoint value is an object containing a string `import` value
109113 // (was { import: 'private-next-pages/api/simulator/dogStats/[name].js' })
@@ -112,12 +116,12 @@ describe('constructWebpackConfigFunction()', () => {
112116 } ,
113117
114118 // 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' : {
117121 import : [
118122 serverConfigFilePath ,
119123 './node_modules/dogPoints/converter.js' ,
120- 'private-next-pages/api/ simulator/leaderboard.js' ,
124+ 'private-next-pages/simulator/leaderboard.js' ,
121125 ] ,
122126 } ,
123127
@@ -131,7 +135,7 @@ describe('constructWebpackConfigFunction()', () => {
131135 ) ;
132136 } ) ;
133137
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 ( ) => {
135139 const finalServerWebpackConfig = await materializeFinalWebpackConfig ( {
136140 exportedNextConfig,
137141 incomingWebpackConfig : serverWebpackConfig ,
@@ -145,7 +149,7 @@ describe('constructWebpackConfigFunction()', () => {
145149
146150 expect ( finalServerWebpackConfig . entry ) . toEqual (
147151 expect . objectContaining ( {
148- 'pages/_app' : expect . arrayContaining ( [ serverConfigFilePath ] ) ,
152+ 'pages/_app' : expect . not . arrayContaining ( [ serverConfigFilePath ] ) ,
149153 } ) ,
150154 ) ;
151155 expect ( finalClientWebpackConfig . entry ) . toEqual (
@@ -179,7 +183,7 @@ describe('constructWebpackConfigFunction()', () => {
179183 ) ;
180184 } ) ;
181185
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 ( ) => {
183187 const finalWebpackConfig = await materializeFinalWebpackConfig ( {
184188 exportedNextConfig,
185189 incomingWebpackConfig : serverWebpackConfig ,
@@ -192,13 +196,13 @@ describe('constructWebpackConfigFunction()', () => {
192196 import : expect . arrayContaining ( [ serverConfigFilePath ] ) ,
193197 } ,
194198
195- 'pages/api/simulator/leaderboard' : {
196- import : expect . arrayContaining ( [ serverConfigFilePath ] ) ,
197- } ,
198-
199199 'pages/api/tricks/[trickName]' : expect . objectContaining ( {
200200 import : expect . arrayContaining ( [ serverConfigFilePath ] ) ,
201201 } ) ,
202+
203+ 'pages/simulator/leaderboard' : {
204+ import : expect . arrayContaining ( [ serverConfigFilePath ] ) ,
205+ } ,
202206 } ) ,
203207 ) ;
204208 } ) ;
@@ -218,19 +222,24 @@ describe('constructWebpackConfigFunction()', () => {
218222 ) ;
219223 } ) ;
220224
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 ( ) => {
222226 const finalWebpackConfig = await materializeFinalWebpackConfig ( {
223227 exportedNextConfig,
224228 incomingWebpackConfig : clientWebpackConfig ,
225229 incomingWebpackBuildContext : clientBuildContext ,
226230 } ) ;
227231
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+ } ) ;
234243 } ) ;
235244 } ) ;
236245} ) ;
0 commit comments