Open barroudjo opened 9 months ago
Same issue here, thanks @rogermparent, can't wait for this to land. Cannot proceed in any way:
I need to delete my /api/name/[slug]/route.ts
file before the export
.
+1
Edit by maintainer bot: Comment was automatically minimized because it was considered unhelpful. (If you think this was by mistake, let us know). Please only comment if it adds context to the issue. If you want to express that you have the same problem, use the upvote 👍 on the issue description or subscribe to the issue for updates. Thanks!
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
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 https://github.com/vercel/next.js/issues/58171 and https://github.com/vercel/next.js/issues/57996 are related.