Skip to content

Commit 7f1f4b9

Browse files
committed
Merge remote-tracking branch 'upstream/dev' into mwilcox/skip-imported-route-typegen
* upstream/dev: bump patch to minor for new API: `href` Type-safe href (remix-run#12994) docs: prerender/ssr:false (remix-run#13005) Skip action-only resource routes with prerender:true (remix-run#13004) Update docs for spa/prerendering Improvements to ssr:false + prerender scenarios (remix-run#12948)
2 parents 9d0dc64 + cd39c4f commit 7f1f4b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2486
-956
lines changed

.changeset/dull-balloons-boil.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
"@react-router/dev": patch
3+
"react-router": patch
4+
---
5+
6+
Fix typegen for repeated params
7+
8+
In React Router, path parameters are keyed by their name.
9+
So for a path pattern like `/a/:id/b/:id?/c/:id`, the last `:id` will set the value for `id` in `useParams` and the `params` prop.
10+
For example, `/a/1/b/2/c/3` will result in the value `{ id: 3 }` at runtime.
11+
12+
Previously, generated types for params incorrectly modeled repeated params with an array.
13+
So `/a/1/b/2/c/3` generated a type like `{ id: [1,2,3] }`.
14+
15+
To be consistent with runtime behavior, the generated types now correctly model the "last one wins" semantics of path parameters.
16+
So `/a/1/b/2/c/3` now generates a type like `{ id: 3 }`.

.changeset/fresh-buttons-sit.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-router": patch
3+
---
4+
5+
Don't apply Single Fetch revalidation de-optimization when in SPA mode since there is no server HTTP request

.changeset/khaki-rocks-cover.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@react-router/dev": patch
3+
---
4+
5+
Fix `ArgError: unknown or unexpected option: --version` when running `react-router --version`

.changeset/late-nails-hear.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@react-router/dev": patch
3+
---
4+
5+
Skip action-only resource routes when using `prerender:true`
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
"@react-router/dev": patch
3+
---
4+
5+
Enhance invalid export detection when using `ssr:false`
6+
7+
- `headers`/`action` are prohibited in all routes with `ssr:false` because there will be no runtime server on which to run them
8+
- `loader` functions are more nuanced and depend on whether a given route is prerendered
9+
- When using `ssr:false` without a `prerender` config, only the `root` route can have a `loader`
10+
- This is "SPA mode" which generates a single `index.html` file with the root route `HydrateFallback` so it is capable of hydrating for any path in your application - therefore we can only call a root route `loader` at build time
11+
- When using `ssr:false` with a `prerender` config, you can export a `loader` from routes matched by one of the `prerender` paths because those routes will be server rendered at build time
12+
- Exporting a `loader` from a route that is never matched by a `prerender` path will throw a build time error because there will be no runtime server to ever run the loader

.changeset/prerender-spa-fallback.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
"@react-router/dev": minor
3+
---
4+
5+
Generate a "SPA fallback" HTML file for scenarios where applications are prerendering the `/` route with `ssr:false`
6+
7+
- If you specify `ssr:false` without a `prerender` config, this is considered "SPA Mode" and the generated `index.html` file will only render down to the root route and will be able to hydrate for any valid application path
8+
- If you specify `ssr:false` with a `prerender` config but _do not_ include the `/` path (i.e., `prerender: ['/blog/post']`), then we still generate a "SPA Mode" `index.html` file that can hydrate for any path in the application
9+
- However, previously if you specified `ssr:false` and included the `/` path in your `prerender` config, we would prerender the `/` route into `index.html` as a non-SPA page
10+
- The generated HTML would include the root index route which prevented hydration for any other paths
11+
- With this change, we now generate a "SPA Mode" file in `__spa-fallback.html` that will allow you to hydrate for any non-prerendered paths
12+
- You can serve this file from your static file server for any paths that would otherwise 404 if you only want to pre-render _some_ routes in your `ssr:false` app and serve the others as a SPA
13+
- `npx sirv-cli build/client --single __spa-fallback.html`

.changeset/rotten-numbers-bathe.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@react-router/dev": patch
3+
---
4+
5+
Limit prerendered resource route `.data` files to only the target route

.changeset/spa-mode-root-loader.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@react-router/dev": minor
3+
---
4+
5+
- Allow a `loader` in the root route in SPA mode because it can be called/server-rendered at build time
6+
- `Route.HydrateFallbackProps` now also receives `loaderData`
7+
- This will be defined so long as the `HydrateFallback` is rendering while _children_ routes are loading
8+
- This will be `undefined` if the `HydrateFallback` is rendering because the route has it's own hydrating `clientLoader`
9+
- In SPA mode, this will allow you to render loader root data into the SPA `index.html`

.changeset/stale-ways-ring.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"react-router": patch
3+
---
4+
5+
Align dev server behavior with static file server behavior when `ssr:false` is set
6+
7+
- When no `prerender` config exists, only SSR down to the root `HydrateFallback` (SPA Mode)
8+
- When a `prerender` config exists but the current path is not prerendered, only SSR down to the root `HydrateFallback` (SPA Fallback)
9+
- Return a 404 on `.data` requests to non-pre-rendered paths

.changeset/three-eyes-flow.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
"@react-router/dev": minor
3+
"react-router": minor
4+
---
5+
6+
New type-safe `href` utility that guarantees links point to actual paths in your app
7+
8+
```tsx
9+
import { href } from "react-router";
10+
11+
export default function Component() {
12+
const link = href("/blog/:slug", { slug: "my-first-post" });
13+
return (
14+
<main>
15+
<Link to={href("/products/:id", { id: "asdf" })} />
16+
<NavLink to={href("/:lang?/about", { lang: "en" })} />
17+
</main>
18+
);
19+
}
20+
```

0 commit comments

Comments
 (0)