@react-router/dev 7.6.0-pre.0 → 7.6.1-pre.0
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 +125 -4
- 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,6 +1,118 @@
|
|
|
1
1
|
# `@react-router/dev`
|
|
2
2
|
|
|
3
|
-
## 7.6.
|
|
3
|
+
## 7.6.1-pre.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Prevent typegen with route files are outside the app directory ([#12996](https://github.com/remix-run/react-router/pull/12996))
|
|
8
|
+
- Fix typegen when same route is used at multiple paths ([#13574](https://github.com/remix-run/react-router/pull/13574))
|
|
9
|
+
|
|
10
|
+
For example, `routes/route.tsx` is used at 4 different paths here:
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { type RouteConfig, route } from "@react-router/dev/routes";
|
|
14
|
+
export default [
|
|
15
|
+
route("base/:base", "routes/base.tsx", [
|
|
16
|
+
route("home/:home", "routes/route.tsx", { id: "home" }),
|
|
17
|
+
route("changelog/:changelog", "routes/route.tsx", { id: "changelog" }),
|
|
18
|
+
route("splat/*", "routes/route.tsx", { id: "splat" }),
|
|
19
|
+
]),
|
|
20
|
+
route("other/:other", "routes/route.tsx", { id: "other" }),
|
|
21
|
+
] satisfies RouteConfig;
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Previously, typegen would arbitrarily pick one of these paths to be the "winner" and generate types for the route module based on that path.
|
|
25
|
+
Now, typegen creates unions as necessary for alternate paths for the same route file.
|
|
26
|
+
|
|
27
|
+
- Add additional logging to `build` command output when cleaning assets from server build ([#13547](https://github.com/remix-run/react-router/pull/13547))
|
|
28
|
+
- Better types for `params` ([#13543](https://github.com/remix-run/react-router/pull/13543))
|
|
29
|
+
|
|
30
|
+
For example:
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
// routes.ts
|
|
34
|
+
import { type RouteConfig, route } from "@react-router/dev/routes";
|
|
35
|
+
|
|
36
|
+
export default [
|
|
37
|
+
route("parent/:p", "routes/parent.tsx", [
|
|
38
|
+
route("route/:r", "routes/route.tsx", [
|
|
39
|
+
route("child1/:c1a/:c1b", "routes/child1.tsx"),
|
|
40
|
+
route("child2/:c2a/:c2b", "routes/child2.tsx"),
|
|
41
|
+
]),
|
|
42
|
+
]),
|
|
43
|
+
] satisfies RouteConfig;
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Previously, `params` for `routes/route` were calculated as `{ p: string, r: string }`.
|
|
47
|
+
This incorrectly ignores params that could come from child routes.
|
|
48
|
+
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 }`.
|
|
49
|
+
|
|
50
|
+
Now, `params` are aware of child routes and autocompletion will include child params as optionals:
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
params.|
|
|
54
|
+
// ^ cursor is here and you ask for autocompletion
|
|
55
|
+
// p: string
|
|
56
|
+
// r: string
|
|
57
|
+
// c1a?: string
|
|
58
|
+
// c1b?: string
|
|
59
|
+
// c2a?: string
|
|
60
|
+
// c2b?: string
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
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`:
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
if (typeof params.c1a === 'string') {
|
|
67
|
+
params.|
|
|
68
|
+
// ^ cursor is here and you ask for autocompletion
|
|
69
|
+
// p: string
|
|
70
|
+
// r: string
|
|
71
|
+
// c1a: string
|
|
72
|
+
// c1b: string
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
***
|
|
77
|
+
|
|
78
|
+
UNSTABLE: renamed internal `react-router/route-module` export to `react-router/internal`
|
|
79
|
+
UNSTABLE: removed `Info` export from generated `+types/*` files
|
|
80
|
+
|
|
81
|
+
- [UNSTABLE] Normalize dirent entry path across node versions when generating SRI manifest ([#13591](https://github.com/remix-run/react-router/pull/13591))
|
|
82
|
+
- 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))
|
|
83
|
+
- Fix `href` for optional segments ([#13595](https://github.com/remix-run/react-router/pull/13595))
|
|
84
|
+
|
|
85
|
+
Type generation now expands paths with optionals into their corresponding non-optional paths.
|
|
86
|
+
For example, the path `/user/:id?` gets expanded into `/user` and `/user/:id` to more closely model visitable URLs.
|
|
87
|
+
`href` then uses these expanded (non-optional) paths to construct type-safe paths for your app:
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
// original: /user/:id?
|
|
91
|
+
// expanded: /user & /user/:id
|
|
92
|
+
href("/user"); // ✅
|
|
93
|
+
href("/user/:id", { id: 1 }); // ✅
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
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:
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
// original: /products/:id/detail?
|
|
100
|
+
|
|
101
|
+
// before
|
|
102
|
+
href("/products/:id/detail?"); // ❌ How can we tell `href` to include or omit `detail?` segment with a complex API?
|
|
103
|
+
|
|
104
|
+
// now
|
|
105
|
+
// expanded: /products/:id & /products/:id/detail
|
|
106
|
+
href("/product/:id"); // ✅
|
|
107
|
+
href("/product/:id/detail"); // ✅
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
- Updated dependencies:
|
|
111
|
+
- `react-router@7.6.1-pre.0`
|
|
112
|
+
- `@react-router/node@7.6.1-pre.0`
|
|
113
|
+
- `@react-router/serve@7.6.1-pre.0`
|
|
114
|
+
|
|
115
|
+
## 7.6.0
|
|
4
116
|
|
|
5
117
|
### Minor Changes
|
|
6
118
|
|
|
@@ -63,26 +175,35 @@
|
|
|
63
175
|
### Patch Changes
|
|
64
176
|
|
|
65
177
|
- Support project root directories without a `package.json` if it exists in a parent directory ([#13472](https://github.com/remix-run/react-router/pull/13472))
|
|
178
|
+
|
|
66
179
|
- When providing a custom Vite config path via the CLI `--config`/`-c` flag, default the project root directory to the directory containing the Vite config when not explicitly provided ([#13472](https://github.com/remix-run/react-router/pull/13472))
|
|
180
|
+
|
|
67
181
|
- In a `routes.ts` context, ensure the `--mode` flag is respected for `import.meta.env.MODE` ([#13485](https://github.com/remix-run/react-router/pull/13485))
|
|
68
182
|
|
|
69
183
|
Previously, `import.meta.env.MODE` within a `routes.ts` context was always `"development"` for the `dev` and `typegen --watch` commands, but otherwise resolved to `"production"`. These defaults are still in place, but if a `--mode` flag is provided, this will now take precedence.
|
|
70
184
|
|
|
71
185
|
- Ensure consistent project root directory resolution logic in CLI commands ([#13472](https://github.com/remix-run/react-router/pull/13472))
|
|
186
|
+
|
|
72
187
|
- When executing `react-router.config.ts` and `routes.ts` with `vite-node`, ensure that PostCSS config files are ignored ([#13489](https://github.com/remix-run/react-router/pull/13489))
|
|
188
|
+
|
|
73
189
|
- When extracting critical CSS during development, ensure it's loaded from the client environment to avoid issues with plugins that handle the SSR environment differently ([#13503](https://github.com/remix-run/react-router/pull/13503))
|
|
190
|
+
|
|
74
191
|
- When `future.unstable_viteEnvironmentApi` is enabled, ensure that `build.assetsDir` in Vite config is respected when `environments.client.build.assetsDir` is not configured ([#13491](https://github.com/remix-run/react-router/pull/13491))
|
|
192
|
+
|
|
75
193
|
- Fix "Status message is not supported by HTTP/2" error during dev when using HTTPS ([#13460](https://github.com/remix-run/react-router/pull/13460))
|
|
194
|
+
|
|
76
195
|
- Update config when `react-router.config.ts` is created or deleted during development. ([#12319](https://github.com/remix-run/react-router/pull/12319))
|
|
196
|
+
|
|
77
197
|
- Skip unnecessary `routes.ts` evaluation before Vite build is started ([#13513](https://github.com/remix-run/react-router/pull/13513))
|
|
198
|
+
|
|
78
199
|
- Fix `TS2300: Duplicate identifier` errors caused by generated types ([#13499](https://github.com/remix-run/react-router/pull/13499))
|
|
79
200
|
|
|
80
201
|
Previously, routes that had the same full path would cause duplicate entries in the generated types for `href` (`.react-router/types/+register.ts`), causing type checking errors.
|
|
81
202
|
|
|
82
203
|
- Updated dependencies:
|
|
83
|
-
- `react-router@7.6.0
|
|
84
|
-
- `@react-router/node@7.6.0
|
|
85
|
-
- `@react-router/serve@7.6.0
|
|
204
|
+
- `react-router@7.6.0`
|
|
205
|
+
- `@react-router/node@7.6.0`
|
|
206
|
+
- `@react-router/serve@7.6.0`
|
|
86
207
|
|
|
87
208
|
## 7.5.3
|
|
88
209
|
|