-
Notifications
You must be signed in to change notification settings - Fork 28.5k
allow empty array for generateStaticParams #61213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Same issue here, thanks @rogermparent, can't wait for this to land. Cannot proceed in any way: |
This introduces a pre-build step on Next Build, which hides the files in the app/api directory when the EXPORT_FRONTEND environment variable is true-ish. Hopefully there won't be disruption due to the post-processing step. Also check vercel/next.js#61213 for upstream updates.
This comment has been minimized.
This comment has been minimized.
Has this been fixed yet? |
I'm also experiencing this issue |
I am also experiencing this issue |
To everyone above me, it's fucking STUPID but looks like if you "return [{ slug: 'test'}]" it will build |
* build: update @tailwindcss/typography -> 0.5.15 * fix: fix tailwindcss auto order * fix: add typography * feat: add home page * feat: complete welcome page * refactor: remove unused css * fix: add @types/js-cookie * fix: workaround build failed when generateStaticParams() return [] issue: vercel/next.js#61213
* Change base font size 1 rem = 10 px. Origin is 1 rem = 16 px. For easily calculating * Implement the hero section view * Fix build error * Solve gray space * Ignore yarn builded files * feat: home page (#2) * build: update @tailwindcss/typography -> 0.5.15 * fix: fix tailwindcss auto order * fix: add typography * feat: add home page * feat: complete welcome page * refactor: remove unused css * fix: add @types/js-cookie * fix: workaround build failed when generateStaticParams() return [] issue: vercel/next.js#61213 --------- Co-authored-by: 鄭宇伸 <timmyabc10@gmail.com>
Returning an empty array is legit in some cases like here for pagination to point out the fact there is no page 2 and still avoid to create a |
How is this not fixed till now? |
Link to the code that reproduces this issue
https://codesandbox.io/p/devbox/compassionate-wilson-qcxws4?file=%2Fapp%2Ffoo%2F%5Bslug%5D%2Fpage.tsx%3A12%2C47
To Reproduce
app/foo/[slug]/page.tsx
has agenerateStaticParams
function that returns an empty array, and there are two possible ways to build the app, one withoutput: 'export'
(npm run build:export
) and one withoutput: undefined
(npm run build:ssr
)npm run build:export
and see that it fails with the error message:Current vs. Expected behavior
It is a real use case of Next.js to have two ways of running the same codebase: one in SSR mode (output: undefined) for users of the CMS (that the Next.js app is connected to) to be able to use the draft mode and preview their work, and one in SSG mode (output: 'export') that is used for production, by just hosting its output on a CDN.
Current Behavior
If a
page.tsx
has agenerateStaticParams
function that returns an empty array (for example because the writers are working on unpublished documents on the CMS, only available through the draft mode in SSR), then the same codebase cannot be used for a production SSG build as it will crash when building withoutput: 'export'
! This is problematic.Expected behavior
There should be a way to allow SSG builds (with
output: 'export'
) to proceed even if apage.tsx
has agenerateStaticParams
function that returns an empty array.Provide environment information
Which area(s) are affected? (Select all that apply)
App Router, Static HTML Export (output: "export")
Which stage(s) are affected? (Select all that apply)
next build (local)
Additional context
I'm fairly sure the problem was already present in version 13.4.
Issues #58171 and #57996 are related.
The text was updated successfully, but these errors were encountered: