-
-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/dev' into mwilcox/skip-importe…
…d-route-typegen * upstream/dev: bump patch to minor for new API: `href` Type-safe href (#12994) docs: prerender/ssr:false (#13005) Skip action-only resource routes with prerender:true (#13004) Update docs for spa/prerendering Improvements to ssr:false + prerender scenarios (#12948)
- Loading branch information
Showing
47 changed files
with
2,486 additions
and
956 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
"@react-router/dev": patch | ||
"react-router": patch | ||
--- | ||
|
||
Fix typegen for repeated params | ||
|
||
In React Router, path parameters are keyed by their name. | ||
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. | ||
For example, `/a/1/b/2/c/3` will result in the value `{ id: 3 }` at runtime. | ||
|
||
Previously, generated types for params incorrectly modeled repeated params with an array. | ||
So `/a/1/b/2/c/3` generated a type like `{ id: [1,2,3] }`. | ||
|
||
To be consistent with runtime behavior, the generated types now correctly model the "last one wins" semantics of path parameters. | ||
So `/a/1/b/2/c/3` now generates a type like `{ id: 3 }`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"react-router": patch | ||
--- | ||
|
||
Don't apply Single Fetch revalidation de-optimization when in SPA mode since there is no server HTTP request |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@react-router/dev": patch | ||
--- | ||
|
||
Fix `ArgError: unknown or unexpected option: --version` when running `react-router --version` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@react-router/dev": patch | ||
--- | ||
|
||
Skip action-only resource routes when using `prerender:true` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
"@react-router/dev": patch | ||
--- | ||
|
||
Enhance invalid export detection when using `ssr:false` | ||
|
||
- `headers`/`action` are prohibited in all routes with `ssr:false` because there will be no runtime server on which to run them | ||
- `loader` functions are more nuanced and depend on whether a given route is prerendered | ||
- When using `ssr:false` without a `prerender` config, only the `root` route can have a `loader` | ||
- 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 | ||
- 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 | ||
- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
"@react-router/dev": minor | ||
--- | ||
|
||
Generate a "SPA fallback" HTML file for scenarios where applications are prerendering the `/` route with `ssr:false` | ||
|
||
- 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 | ||
- 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 | ||
- 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 | ||
- The generated HTML would include the root index route which prevented hydration for any other paths | ||
- 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 | ||
- 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 | ||
- `npx sirv-cli build/client --single __spa-fallback.html` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@react-router/dev": patch | ||
--- | ||
|
||
Limit prerendered resource route `.data` files to only the target route |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
"@react-router/dev": minor | ||
--- | ||
|
||
- Allow a `loader` in the root route in SPA mode because it can be called/server-rendered at build time | ||
- `Route.HydrateFallbackProps` now also receives `loaderData` | ||
- This will be defined so long as the `HydrateFallback` is rendering while _children_ routes are loading | ||
- This will be `undefined` if the `HydrateFallback` is rendering because the route has it's own hydrating `clientLoader` | ||
- In SPA mode, this will allow you to render loader root data into the SPA `index.html` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
"react-router": patch | ||
--- | ||
|
||
Align dev server behavior with static file server behavior when `ssr:false` is set | ||
|
||
- When no `prerender` config exists, only SSR down to the root `HydrateFallback` (SPA Mode) | ||
- When a `prerender` config exists but the current path is not prerendered, only SSR down to the root `HydrateFallback` (SPA Fallback) | ||
- Return a 404 on `.data` requests to non-pre-rendered paths |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
"@react-router/dev": minor | ||
"react-router": minor | ||
--- | ||
|
||
New type-safe `href` utility that guarantees links point to actual paths in your app | ||
|
||
```tsx | ||
import { href } from "react-router"; | ||
|
||
export default function Component() { | ||
const link = href("/blog/:slug", { slug: "my-first-post" }); | ||
return ( | ||
<main> | ||
<Link to={href("/products/:id", { id: "asdf" })} /> | ||
<NavLink to={href("/:lang?/about", { lang: "en" })} /> | ||
</main> | ||
); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.