File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -139,8 +139,8 @@ export const generateRedirects = async ({
139139 )
140140 }
141141 } )
142- // Add rewrites for all static SSR routes
143- staticRoutes . forEach ( ( route ) => {
142+ // Add rewrites for all static SSR routes. This is Next 12+
143+ staticRoutes ? .forEach ( ( route ) => {
144144 if ( staticRoutePaths . has ( route . page ) || isApiRoute ( route . page ) ) {
145145 // Prerendered static routes are either handled by the CDN or are ISR
146146 return
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ export interface RoutesManifest {
4646 redirects : Redirect [ ]
4747 headers : Header [ ]
4848 dynamicRoutes : DynamicRoute [ ]
49- staticRoutes : StaticRoute [ ]
49+ staticRoutes ? : StaticRoute [ ]
5050 dataRoutes : DataRoute [ ]
5151 i18n : I18n
5252 rewrites : Rewrites
Original file line number Diff line number Diff line change @@ -409,6 +409,16 @@ describe('onBuild()', () => {
409409 expect ( readFileSync ( handlerFile , 'utf8' ) ) . toMatch ( `require("../../../.next/required-server-files.json")` )
410410 expect ( readFileSync ( odbHandlerFile , 'utf8' ) ) . toMatch ( `require("../../../.next/required-server-files.json")` )
411411 } )
412+
413+ test ( 'handles empty routesManifest.staticRoutes' , async ( ) => {
414+ await moveNextDist ( )
415+ const manifestPath = path . resolve ( '.next/routes-manifest.json' )
416+ const routesManifest = await readJson ( manifestPath )
417+ delete routesManifest . staticRoutes
418+ await writeJSON ( manifestPath , routesManifest )
419+ // The function is supposed to return undefined, but we want to check if it throws
420+ expect ( await plugin . onBuild ( defaultArgs ) ) . toBeUndefined ( )
421+ } )
412422} )
413423
414424describe ( 'onPostBuild' , ( ) => {
You can’t perform that action at this time.
0 commit comments