Repository: next.js
Issue: Conditional building pages with export: output is not supported
Labels: bug,Output (export/standalone)

### Link to the code that reproduces this issue

[Sandbox Link](https://codesandbox.io/p/devbox/nostalgic-benz-kvvqk2?workspaceId=e31ff887-e28d-4cc0-9110-18046c9484ab&layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522clzvrr1cs00063b6jx24oaw7r%2522%252C%2522sizes%2522%253A%255B70%252C30%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522clzvrr1cs00023b6jz4wx13u9%2522%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522clzvrr1cs00043b6j1yr2tsbu%2522%257D%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522clzvrr1cs00053b6j7yg3ceqi%2522%257D%255D%257D%255D%252C%2522sizes%2522%253A%255B50%252C50%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522clzvrr1cs00023b6jz4wx13u9%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clzvrr1cs00013b6jjq8oosyl%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252FREADME.md%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%252C%257B%2522id%2522%253A%2522clzvrtsvp00133b6j9ayc82e6%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522initialSelections%2522%253A%255B%257B%2522startLineNumber%2522%253A5%252C%2522startColumn%2522%253A25%252C%2522endLineNumber%2522%253A5%252C%2522endColumn%2522%253A25%257D%255D%252C%2522filepath%2522%253A%2522%252Fnext.config.mjs%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%255D%252C%2522id%2522%253A%2522clzvrr1cs00023b6jz4wx13u9%2522%252C%2522activeTabId%2522%253A%2522clzvrtsvp00133b6j9ayc82e6%2522%257D%252C%2522clzvrr1cs00053b6j7yg3ceqi%2522%253A%257B%2522id%2522%253A%2522clzvrr1cs00053b6j7yg3ceqi%2522%252C%2522activeTabId%2522%253A%2522clzvrvlw7000y3b6jp815rk7h%2522%252C%2522tabs%2522%253A%255B%257B%2522type%2522%253A%2522UNASSIGNED_PORT%2522%252C%2522port%2522%253A3000%252C%2522id%2522%253A%2522clzvrvlw7000y3b6jp815rk7h%2522%252C%2522mode%2522%253A%2522permanent%2522%257D%255D%257D%252C%2522clzvrr1cs00043b6j1yr2tsbu%2522%253A%257B%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clzvrr1cs00033b6jrpt7sicf%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522dev%2522%257D%255D%252C%2522id%2522%253A%2522clzvrr1cs00043b6j1yr2tsbu%2522%252C%2522activeTabId%2522%253A%2522clzvrr1cs00033b6jrpt7sicf%2522%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Atrue%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%257D)

### To Reproduce

1. Run `npm run build` 
2. You get the error `Page "${page}" is missing "generateStaticParams()" so it cannot be used with "output: export" config.`

### Current vs. Expected behavior

When building a static site with output: "export", I expect the empty dynamic routes to be ignored. 
The current behavior is to throw an error on build, forcing me to change the name of the file from page.tsx to something else thus making the build ignore this dynamic route page generation. 

### Provide environment information

```bash
Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Sun Aug  6 20:05:33 UTC 2023
  Available memory (MB): 4102
  Available CPU cores: 2
Binaries:
  Node: 20.9.0
  npm: 9.8.1
  Yarn: 1.22.19
  pnpm: 8.10.2
Relevant Packages:
  next: 15.0.0-canary.115 // Latest available version is detected (15.0.0-canary.115).
  eslint-config-next: N/A
  react: 19.0.0-rc-187dd6a7-20240806
  react-dom: 19.0.0-rc-187dd6a7-20240806
  typescript: 5.3.3
Next.js Config:
  output: export
```


### Which area(s) are affected? (Select all that apply)

Output (export/standalone)

### Which stage(s) are affected? (Select all that apply)

next build (local)

### Additional context

Structuring multiple sites on a single NextJS code base gets tough with the current behavior. 
Also some sites are generated daily and without specific set of routes provided in the code (loading the dynamic routes from a CMS), days when a dynamic route will be empty is highly likely. 

This issue can be fixed by changing the `hasGenerateStaticParams` condition to allow empty arrays (currently checking the length). 
Breadcrumbs: `next > src > build > index.ts > Line 2140 `
**I'm unfamiliar with the implications of this condition on other export methods, take it only as a suggestion**

I would be happy to get a workaround without editing the code for each build.