vercel / next.js

The React Framework
https://nextjs.org
MIT License
127.54k stars 27.05k forks source link

Static Export Not Working with modal example in official docs #58115

Open kingwingfly opened 1 year ago

kingwingfly commented 1 year ago

Link to the code that reproduces this issue

https://github.com/kingwingfly/downloader/tree/Louis/src

To Reproduce

I'm using Tauri, so it needs static export. And I also use Modal following the docs' example. Here's the code.

Here's the app dir tree:

app
├── @modal
│   ├── (.)config
│   │   └── page.tsx
│   ├── (.)newTask
│   │   └── page.tsx
│   ├── (.)taskList
│   │   └── page.tsx
│   └── default.tsx
├── config
│   └── page.tsx
├── newTask
│   └── page.tsx
├── taskList
│   └── page.tsx
├── layout.tsx
└── page.tsx

The modal works well in dev model.

image

Then npm run build

> downloader@0.1.0 build
> next build

   ▲ Next.js 14.0.2-canary.17
   - Environments: .env

 ✓ Creating an optimized production build
 ✓ Compiled successfully
 ✓ Linting and checking validity of types
 ✓ Collecting page data
 ✓ Generating static pages (11/11)
 ✓ Finalizing page optimization

Route (app)                              Size     First Load JS
┌ ○ /                                    5.28 kB        97.9 kB
├ ○ /_not-found                          882 B          86.5 kB
├ ○ /(.)config                           2.07 kB        87.7 kB
├ ○ /(.)newTask                          1.91 kB        87.6 kB
├ ○ /(.)taskList                         2.29 kB          88 kB
├ ○ /config                              1.77 kB        94.4 kB
├ ○ /newTask                             1.62 kB        94.3 kB
└ ○ /taskList                            2 kB           94.7 kB
+ First Load JS shared by all            85.7 kB
  ├ chunks/472-8bd514f8ddb073e6.js       30.5 kB
  ├ chunks/fd9d1056-685ae801652a0369.js  53.2 kB
  ├ chunks/main-app-2766da115c76ee26.js  232 B
  └ chunks/webpack-42ab295a268467a8.js   1.73 kB

○  (Static)  prerendered as static content

Use npx serve@latest out to serve the out static pages.

Certainly, if I visit /config, it just jump to the config page without modal.

image

However, if I visit /(.)config, it works again.

I know it must not be the right practice with static export, and it may need node runtime to support the parallel and intercepting routes.

Due to my poor knowledge, I don't know the detailed reason for its not working, and the docs' deploying/static export/unsupported features does not contain this either.

I wonder whether there's anything I did not notice, or maybe a doc patch is needed.

Current vs. Expected behavior

Current:

Modal impl with parallel and intercepting routes can not work properly with static export.

Expected:

Correct knowledge about modal with static export. And maybe the docs' deploying/static export/unsupported features need a patch.

Verify canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.2.0: Fri Oct 13 09:28:27 PDT 2023; root:xnu-10002.60.54~14/RELEASE_ARM64_T8103
Binaries:
  Node: 21.1.0
  npm: 10.2.0
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.0.2-canary.17
  eslint-config-next: 13.5.4
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.2.2
Next.js Config:
  output: export


### Which area(s) are affected? (Select all that apply)

App Router, Static HTML Export (output: "export")

### Additional context

_No response_
indiejoseph commented 11 months ago

any update? facing same issue

Edit by maintainers: 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!

kingwingfly commented 11 months ago

@indiejoseph

Maybe we should implement a server to serve the static pages in the same way as the next start does.

The server or tauri backend cannot recognize request to @xx/xx and /(.)xx, they just return /xx. And I remember the static page in the client implements parallel route (On page /xx, manually requesting /(.)xx could get the parallel route working). So I guess serving the right page at the server side according to the referrer or host in the headers can solve the problem.

indiejoseph commented 11 months ago

I tried rename /(.)about.html with cli, but there already a about.html which the none modal page, on the other hand my site deploying to github page which no way to configurate how to route the folder structure, so i think we need to make some change in the next's router programmatically.