@react-router/dev 7.6.0 → 7.6.1-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 +121 -0
- package/dist/cli/index.js +397 -219
- package/dist/config.js +1 -1
- package/dist/routes.js +1 -1
- package/dist/vite/cloudflare.js +1 -1
- package/dist/vite.js +467 -240
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,126 @@
|
|
|
1
1
|
# `@react-router/dev`
|
|
2
2
|
|
|
3
|
+
## 7.6.1-pre.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies:
|
|
8
|
+
- `react-router@7.6.1-pre.1`
|
|
9
|
+
- `@react-router/node@7.6.1-pre.1`
|
|
10
|
+
- `@react-router/serve@7.6.1-pre.1`
|
|
11
|
+
|
|
12
|
+
## 7.6.1-pre.0
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Prevent typegen with route files are outside the app directory ([#12996](https://github.com/remix-run/react-router/pull/12996))
|
|
17
|
+
- Fix typegen when same route is used at multiple paths ([#13574](https://github.com/remix-run/react-router/pull/13574))
|
|
18
|
+
|
|
19
|
+
For example, `routes/route.tsx` is used at 4 different paths here:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { type RouteConfig, route } from "@react-router/dev/routes";
|
|
23
|
+
export default [
|
|
24
|
+
route("base/:base", "routes/base.tsx", [
|
|
25
|
+
route("home/:home", "routes/route.tsx", { id: "home" }),
|
|
26
|
+
route("changelog/:changelog", "routes/route.tsx", { id: "changelog" }),
|
|
27
|
+
route("splat/*", "routes/route.tsx", { id: "splat" }),
|
|
28
|
+
]),
|
|
29
|
+
route("other/:other", "routes/route.tsx", { id: "other" }),
|
|
30
|
+
] satisfies RouteConfig;
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Previously, typegen would arbitrarily pick one of these paths to be the "winner" and generate types for the route module based on that path.
|
|
34
|
+
Now, typegen creates unions as necessary for alternate paths for the same route file.
|
|
35
|
+
|
|
36
|
+
- Add additional logging to `build` command output when cleaning assets from server build ([#13547](https://github.com/remix-run/react-router/pull/13547))
|
|
37
|
+
- Better types for `params` ([#13543](https://github.com/remix-run/react-router/pull/13543))
|
|
38
|
+
|
|
39
|
+
For example:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
// routes.ts
|
|
43
|
+
import { type RouteConfig, route } from "@react-router/dev/routes";
|
|
44
|
+
|
|
45
|
+
export default [
|
|
46
|
+
route("parent/:p", "routes/parent.tsx", [
|
|
47
|
+
route("route/:r", "routes/route.tsx", [
|
|
48
|
+
route("child1/:c1a/:c1b", "routes/child1.tsx"),
|
|
49
|
+
route("child2/:c2a/:c2b", "routes/child2.tsx"),
|
|
50
|
+
]),
|
|
51
|
+
]),
|
|
52
|
+
] satisfies RouteConfig;
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Previously, `params` for `routes/route` were calculated as `{ p: string, r: string }`.
|
|
56
|
+
This incorrectly ignores params that could come from child routes.
|
|
57
|
+
If visiting `/parent/1/route/2/child1/3/4`, the actual params passed to `routes/route` will have a type of `{ p: string, r: string, c1a: string, c1b: string }`.
|
|
58
|
+
|
|
59
|
+
Now, `params` are aware of child routes and autocompletion will include child params as optionals:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
params.|
|
|
63
|
+
// ^ cursor is here and you ask for autocompletion
|
|
64
|
+
// p: string
|
|
65
|
+
// r: string
|
|
66
|
+
// c1a?: string
|
|
67
|
+
// c1b?: string
|
|
68
|
+
// c2a?: string
|
|
69
|
+
// c2b?: string
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
You can also narrow the types for `params` as it is implemented as a normalized union of params for each page that includes `routes/route`:
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
if (typeof params.c1a === 'string') {
|
|
76
|
+
params.|
|
|
77
|
+
// ^ cursor is here and you ask for autocompletion
|
|
78
|
+
// p: string
|
|
79
|
+
// r: string
|
|
80
|
+
// c1a: string
|
|
81
|
+
// c1b: string
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
***
|
|
86
|
+
|
|
87
|
+
UNSTABLE: renamed internal `react-router/route-module` export to `react-router/internal`
|
|
88
|
+
UNSTABLE: removed `Info` export from generated `+types/*` files
|
|
89
|
+
|
|
90
|
+
- [UNSTABLE] Normalize dirent entry path across node versions when generating SRI manifest ([#13591](https://github.com/remix-run/react-router/pull/13591))
|
|
91
|
+
- Don't clean assets from server build when `build.ssrEmitAssets` has been enabled in Vite config ([#13547](https://github.com/remix-run/react-router/pull/13547))
|
|
92
|
+
- Fix `href` for optional segments ([#13595](https://github.com/remix-run/react-router/pull/13595))
|
|
93
|
+
|
|
94
|
+
Type generation now expands paths with optionals into their corresponding non-optional paths.
|
|
95
|
+
For example, the path `/user/:id?` gets expanded into `/user` and `/user/:id` to more closely model visitable URLs.
|
|
96
|
+
`href` then uses these expanded (non-optional) paths to construct type-safe paths for your app:
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
// original: /user/:id?
|
|
100
|
+
// expanded: /user & /user/:id
|
|
101
|
+
href("/user"); // ✅
|
|
102
|
+
href("/user/:id", { id: 1 }); // ✅
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
This becomes even more important for static optional paths where there wasn't a good way to indicate whether the optional should be included in the resulting path:
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
// original: /products/:id/detail?
|
|
109
|
+
|
|
110
|
+
// before
|
|
111
|
+
href("/products/:id/detail?"); // ❌ How can we tell `href` to include or omit `detail?` segment with a complex API?
|
|
112
|
+
|
|
113
|
+
// now
|
|
114
|
+
// expanded: /products/:id & /products/:id/detail
|
|
115
|
+
href("/product/:id"); // ✅
|
|
116
|
+
href("/product/:id/detail"); // ✅
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
- Updated dependencies:
|
|
120
|
+
- `react-router@7.6.1-pre.0`
|
|
121
|
+
- `@react-router/node@7.6.1-pre.0`
|
|
122
|
+
- `@react-router/serve@7.6.1-pre.0`
|
|
123
|
+
|
|
3
124
|
## 7.6.0
|
|
4
125
|
|
|
5
126
|
### Minor Changes
|