@react-router/dev 7.1.5 → 7.2.0-pre.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,92 @@
1
1
  # `@react-router/dev`
2
2
 
3
+ ## 7.2.0-pre.1
4
+
5
+ ### Minor Changes
6
+
7
+ - New type-safe `href` utility that guarantees links point to actual paths in your app ([#13012](https://github.com/remix-run/react-router/pull/13012))
8
+
9
+ ```tsx
10
+ import { href } from "react-router";
11
+
12
+ export default function Component() {
13
+ const link = href("/blog/:slug", { slug: "my-first-post" });
14
+ return (
15
+ <main>
16
+ <Link to={href("/products/:id", { id: "asdf" })} />
17
+ <NavLink to={href("/:lang?/about", { lang: "en" })} />
18
+ </main>
19
+ );
20
+ }
21
+ ```
22
+
23
+ ### Patch Changes
24
+
25
+ - Fix typegen for repeated params ([#13012](https://github.com/remix-run/react-router/pull/13012))
26
+
27
+ In React Router, path parameters are keyed by their name.
28
+ 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.
29
+ For example, `/a/1/b/2/c/3` will result in the value `{ id: 3 }` at runtime.
30
+
31
+ Previously, generated types for params incorrectly modeled repeated params with an array.
32
+ So `/a/1/b/2/c/3` generated a type like `{ id: [1,2,3] }`.
33
+
34
+ To be consistent with runtime behavior, the generated types now correctly model the "last one wins" semantics of path parameters.
35
+ So `/a/1/b/2/c/3` now generates a type like `{ id: 3 }`.
36
+
37
+ - Fix `ArgError: unknown or unexpected option: --version` when running `react-router --version` ([#13012](https://github.com/remix-run/react-router/pull/13012))
38
+ - Updated dependencies:
39
+ - `react-router@7.2.0-pre.1`
40
+ - `@react-router/node@7.2.0-pre.1`
41
+ - `@react-router/serve@7.2.0-pre.1`
42
+
43
+ ## 7.2.0-pre.0
44
+
45
+ ### Minor Changes
46
+
47
+ - Generate a "SPA fallback" HTML file for scenarios where applications are prerendering the `/` route with `ssr:false` ([#12948](https://github.com/remix-run/react-router/pull/12948))
48
+
49
+ - 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
50
+ - 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
51
+ - 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
52
+ - The generated HTML would include the root index route which prevented hydration for any other paths
53
+ - 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
54
+ - 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
55
+ - `npx sirv-cli build/client --single __spa-fallback.html`
56
+
57
+ - - Allow a `loader` in the root route in SPA mode because it can be called/server-rendered at build time ([#12948](https://github.com/remix-run/react-router/pull/12948))
58
+ - `Route.HydrateFallbackProps` now also receives `loaderData`
59
+ - This will be defined so long as the `HydrateFallback` is rendering while _children_ routes are loading
60
+ - This will be `undefined` if the `HydrateFallback` is rendering because the route has it's own hydrating `clientLoader`
61
+ - In SPA mode, this will allow you to render loader root data into the SPA `index.html`
62
+
63
+ ### Patch Changes
64
+
65
+ - Handle custom `envDir` in Vite config ([#12969](https://github.com/remix-run/react-router/pull/12969))
66
+ - Fix CLI parsing to allow argumentless `npx react-router` usage ([#12925](https://github.com/remix-run/react-router/pull/12925))
67
+ - Skip action-only resource routes when using `prerender:true` ([#13004](https://github.com/remix-run/react-router/pull/13004))
68
+ - Enhance invalid export detection when using `ssr:false` ([#12948](https://github.com/remix-run/react-router/pull/12948))
69
+
70
+ - `headers`/`action` are prohibited in all routes with `ssr:false` because there will be no runtime server on which to run them
71
+ - `loader` functions are more nuanced and depend on whether a given route is prerendered
72
+ - When using `ssr:false` without a `prerender` config, only the `root` route can have a `loader`
73
+ - 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
74
+ - 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
75
+ - 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
76
+
77
+ - Limit prerendered resource route `.data` files to only the target route ([#13004](https://github.com/remix-run/react-router/pull/13004))
78
+ - Add unstable support for splitting route modules in framework mode via `future.unstable_splitRouteModules` ([#11871](https://github.com/remix-run/react-router/pull/11871))
79
+ - Add `future.unstable_viteEnvironmentApi` flag to enable experimental Vite Environment API support ([#12936](https://github.com/remix-run/react-router/pull/12936))
80
+ - Disable Lazy Route Discovery for all `ssr:false` apps and not just "SPA Mode" because there is no runtime server to serve the search-param-configured `__manifest` requests ([#12894](https://github.com/remix-run/react-router/pull/12894))
81
+
82
+ - We previously only disabled this for "SPA Mode" which is `ssr:false` and no `prerender` config but we realized it should apply to all `ssr:false` apps, including those prerendering multiple pages
83
+ - In those `prerender` scenarios we would prerender the `/__manifest` file assuming the static file server would serve it but that makes some unneccesary assumptions about the static file server behaviors
84
+
85
+ - Updated dependencies:
86
+ - `react-router@7.2.0-pre.0`
87
+ - `@react-router/node@7.2.0-pre.0`
88
+ - `@react-router/serve@7.2.0-pre.0`
89
+
3
90
  ## 7.1.5
4
91
 
5
92
  ### Patch Changes
@@ -117,7 +204,7 @@
117
204
  +import { cloudflareDevProxy } from "@react-router/dev/vite/cloudflare";
118
205
  ```
119
206
 
120
- - Remove single\_fetch future flag. ([#11522](https://github.com/remix-run/react-router/pull/11522))
207
+ - Remove single_fetch future flag. ([#11522](https://github.com/remix-run/react-router/pull/11522))
121
208
 
122
209
  - update minimum node version to 18 ([#11690](https://github.com/remix-run/react-router/pull/11690))
123
210
 
package/bin.js CHANGED
@@ -5,8 +5,8 @@ let arg = require("arg");
5
5
  // default `NODE_ENV` so React loads the proper version in it's CJS entry script.
6
6
  // We have to do this before importing `run.ts` since that is what imports
7
7
  // `react` (indirectly via `react-router`)
8
- let args = arg({}, { argv: process.argv.slice(2), stopAtPositional: true });
9
- if (args._[0] === "dev") {
8
+ let args = arg({}, { argv: process.argv.slice(2), permissive: true });
9
+ if (args._.length === 0 || args._[0] === "dev") {
10
10
  process.env.NODE_ENV = process.env.NODE_ENV ?? "development";
11
11
  } else {
12
12
  process.env.NODE_ENV = process.env.NODE_ENV ?? "production";