next.js
92b3dd2d - fix: empty generateStaticParams should still create an ISR route (#73358)

Commit
1 year ago
fix: empty generateStaticParams should still create an ISR route (#73358) Returning an empty array from `generateStaticParams` should still be deployed as an ISR route to support the `dynamicParams = true` case, where a route can be generated & cached on demand. At the moment the only way to achieve this behavior is with `export const dynamic = 'force-static'`. As a result, these routes are being treated as dynamic and never return a cached response. This PR resolves the bug by fixing several distinct things: - `prerenderedRoutes` does not need to be an array > 0 to mark a route as being a static path. This will ensure the build output shows the correct symbol and adds the path to the list of prerenders. - we initialize `prerenderedRoutes` to an empty array if we determine that the leaf-most segment (the thing rendering the current page) has a `generateStaticParams` function - the function responsible for collecting segments associated with a page only considered the `children` branch, but for something like a parallel/interception route, those segments would be inside of a different parallel route key - the regex for determining if a function was dynamic didn't consider that the dynamic route might also contain an interception marker (eg `(.)`) This appears to have regressed in #68125 Closes NEXT-3905 --------- Co-authored-by: Wyatt Johnson <accounts+github@wyattjoh.ca>
Author
Parents
Loading