app-router: update prefetch heuristic to traverse until until we hit a loading boundary (#49077)
This PR changes the router behaviour during prefetching.
- before: the router would prefetch the router tree + return the loading state of new router node if there were any
- after: the router will prefetch the router tree + prefetch the content of the new page up until the nearest loading boundaries
Example:
Note: `prefetched` here implies React content prefetching
```
.
└── app/
├── page.ts <- the page you're on, has links to /about and /post/[id]
├── layout.ts
├── post/
│ └── [id]/
│ ├── (comments)/
│ │ ├── loading.ts <- not prefetched
│ │ └── page.ts <- not prefetched
│ ├── layout.ts
│ └── page.ts <- not prefetched
└── about/
└── page.ts <- not prefetched
```
After
```
.
└── app/
├── page.ts <- the page you're on, has links to /about and /post/[id]
├── layout.ts
├── post/
│ └── [id]/
│ ├── (comments)/
│ │ ├── loading.ts <- prefetched
│ │ └── page.ts <- not prefetched
│ ├── layout.ts
│ └── page.ts <- prefetched
└── about/
└── page.ts <- prefetched
```
link NEXT-1078
Showing
Please
register
or
sign in
to comment