@react-router/dev 0.0.0-experimental-f2b42587c → 0.0.0-experimental-9398cceaa
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 +62 -0
- package/dist/cli/index.js +30 -26
- package/dist/config.js +1 -1
- package/dist/routes.js +1 -1
- package/dist/vite/cloudflare.d.ts +1 -1
- package/dist/vite/cloudflare.js +1 -1
- package/dist/vite.js +36 -25
- package/package.json +8 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,67 @@
|
|
|
1
1
|
# `@react-router/dev`
|
|
2
2
|
|
|
3
|
+
## 7.6.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Avoid additional `with-props` chunk in Framework Mode by moving route module component prop logic from the Vite plugin to `react-router` ([#13650](https://github.com/remix-run/react-router/pull/13650))
|
|
8
|
+
|
|
9
|
+
- When `future.unstable_viteEnvironmentApi` is enabled and an absolute Vite `base` has been configured, ensure critical CSS is handled correctly during development ([#13598](https://github.com/remix-run/react-router/pull/13598))
|
|
10
|
+
|
|
11
|
+
- Update `vite-node` ([#13673](https://github.com/remix-run/react-router/pull/13673))
|
|
12
|
+
|
|
13
|
+
- Fix typegen for non-{.js,.jsx,.ts,.tsx} routes like .mdx ([#12453](https://github.com/remix-run/react-router/pull/12453))
|
|
14
|
+
|
|
15
|
+
- Fix href types for optional dynamic params ([#13725](https://github.com/remix-run/react-router/pull/13725))
|
|
16
|
+
|
|
17
|
+
7.6.1 introduced fixes for `href` when using optional static segments,
|
|
18
|
+
but those fixes caused regressions with how optional dynamic params worked in 7.6.0:
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
// 7.6.0
|
|
22
|
+
href("/users/:id?"); // ✅
|
|
23
|
+
href("/users/:id?", { id: 1 }); // ✅
|
|
24
|
+
|
|
25
|
+
// 7.6.1
|
|
26
|
+
href("/users/:id?"); // ❌
|
|
27
|
+
href("/users/:id?", { id: 1 }); // ❌
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Now, optional static segments are expanded into different paths for `href`, but optional dynamic params are not.
|
|
31
|
+
This way `href` can unambiguously refer to an exact URL path, all while keeping the number of path options to a minimum.
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
// 7.6.2
|
|
35
|
+
|
|
36
|
+
// path: /users/:id?/edit?
|
|
37
|
+
href("
|
|
38
|
+
// ^ suggestions when cursor is here:
|
|
39
|
+
//
|
|
40
|
+
// /users/:id?
|
|
41
|
+
// /users/:id?/edit
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Additionally, you can pass `params` from component props without needing to narrow them manually:
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
declare const params: { id?: number };
|
|
48
|
+
|
|
49
|
+
// 7.6.0
|
|
50
|
+
href("/users/:id?", params);
|
|
51
|
+
|
|
52
|
+
// 7.6.1
|
|
53
|
+
href("/users/:id?", params); // ❌
|
|
54
|
+
"id" in params ? href("/users/:id", params) : href("/users"); // works... but is annoying
|
|
55
|
+
|
|
56
|
+
// 7.6.2
|
|
57
|
+
href("/users/:id?", params); // restores behavior of 7.6.0
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
- Updated dependencies:
|
|
61
|
+
- `react-router@7.6.2`
|
|
62
|
+
- `@react-router/node@7.6.2`
|
|
63
|
+
- `@react-router/serve@7.6.2`
|
|
64
|
+
|
|
3
65
|
## 7.6.1
|
|
4
66
|
|
|
5
67
|
### Patch Changes
|
package/dist/cli/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* @react-router/dev v0.0.0-experimental-
|
|
3
|
+
* @react-router/dev v0.0.0-experimental-9398cceaa
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) Remix Software Inc.
|
|
6
6
|
*
|
|
@@ -928,7 +928,7 @@ function generateRoutes(ctx) {
|
|
|
928
928
|
lineages.set(route.id, lineage2);
|
|
929
929
|
const fullpath2 = fullpath(lineage2);
|
|
930
930
|
if (!fullpath2) continue;
|
|
931
|
-
const pages =
|
|
931
|
+
const pages = expand(fullpath2);
|
|
932
932
|
pages.forEach((page) => allPages.add(page));
|
|
933
933
|
lineage2.forEach(({ id }) => {
|
|
934
934
|
let routePages = routeToPages.get(id);
|
|
@@ -1136,9 +1136,13 @@ function getRouteAnnotations({
|
|
|
1136
1136
|
}
|
|
1137
1137
|
function relativeImportSource(from, to) {
|
|
1138
1138
|
let path8 = Path3.relative(Path3.dirname(from), to);
|
|
1139
|
+
let extension = Path3.extname(path8);
|
|
1139
1140
|
path8 = Path3.join(Path3.dirname(path8), Pathe.filename(path8));
|
|
1140
1141
|
if (!path8.startsWith("../")) path8 = "./" + path8;
|
|
1141
|
-
|
|
1142
|
+
if (!extension || /\.(js|ts)x?$/.test(extension)) {
|
|
1143
|
+
extension = ".js";
|
|
1144
|
+
}
|
|
1145
|
+
return path8 + extension;
|
|
1142
1146
|
}
|
|
1143
1147
|
function rootDirsPath(ctx, typesPath) {
|
|
1144
1148
|
const rel = Path3.relative(typesDirectory(ctx), typesPath);
|
|
@@ -1157,28 +1161,27 @@ function paramsType(path8) {
|
|
|
1157
1161
|
})
|
|
1158
1162
|
);
|
|
1159
1163
|
}
|
|
1160
|
-
function
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
...
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
);
|
|
1176
|
-
|
|
1177
|
-
result.
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
);
|
|
1164
|
+
function expand(fullpath2) {
|
|
1165
|
+
function recurse(segments2, index) {
|
|
1166
|
+
if (index === segments2.length) return [""];
|
|
1167
|
+
const segment = segments2[index];
|
|
1168
|
+
const isOptional = segment.endsWith("?");
|
|
1169
|
+
const isDynamic = segment.startsWith(":");
|
|
1170
|
+
const required = segment.replace(/\?$/, "");
|
|
1171
|
+
const keep = !isOptional || isDynamic;
|
|
1172
|
+
const kept = isDynamic ? segment : required;
|
|
1173
|
+
const withoutSegment = recurse(segments2, index + 1);
|
|
1174
|
+
const withSegment = withoutSegment.map((rest) => [kept, rest].join("/"));
|
|
1175
|
+
if (keep) return withSegment;
|
|
1176
|
+
return [...withoutSegment, ...withSegment];
|
|
1177
|
+
}
|
|
1178
|
+
const segments = fullpath2.split("/");
|
|
1179
|
+
const expanded = /* @__PURE__ */ new Set();
|
|
1180
|
+
for (let result of recurse(segments, 0)) {
|
|
1181
|
+
if (result !== "/") result = result.replace(/\/$/, "");
|
|
1182
|
+
expanded.add(result);
|
|
1183
|
+
}
|
|
1184
|
+
return expanded;
|
|
1182
1185
|
}
|
|
1183
1186
|
var import_dedent, Path3, Pathe, t2;
|
|
1184
1187
|
var init_generate = __esm({
|
|
@@ -1631,7 +1634,7 @@ function resolveEnvironmentsOptions(environmentResolvers, resolverOptions) {
|
|
|
1631
1634
|
function isNonNullable(x) {
|
|
1632
1635
|
return x != null;
|
|
1633
1636
|
}
|
|
1634
|
-
var import_node_crypto, fs4, path6, url, fse, babel2, import_react_router2, import_es_module_lexer, import_pick3, import_jsesc, import_picocolors4, import_kebabCase, CLIENT_NON_COMPONENT_EXPORTS, CLIENT_ROUTE_EXPORTS, BUILD_CLIENT_ROUTE_QUERY_STRING, SSR_BUNDLE_PREFIX, virtualHmrRuntime, virtualInjectHmrRuntime, virtual, getServerBuildDirectory, getClientBuildDirectory, defaultEntriesDir, defaultEntries, REACT_REFRESH_HEADER;
|
|
1637
|
+
var import_node_crypto, fs4, path6, url, fse, babel2, import_react_router2, import_es_module_lexer, import_tinyglobby, import_pick3, import_jsesc, import_picocolors4, import_kebabCase, CLIENT_NON_COMPONENT_EXPORTS, CLIENT_ROUTE_EXPORTS, BUILD_CLIENT_ROUTE_QUERY_STRING, SSR_BUNDLE_PREFIX, virtualHmrRuntime, virtualInjectHmrRuntime, virtual, getServerBuildDirectory, getClientBuildDirectory, defaultEntriesDir, defaultEntries, REACT_REFRESH_HEADER;
|
|
1635
1638
|
var init_plugin = __esm({
|
|
1636
1639
|
"vite/plugin.ts"() {
|
|
1637
1640
|
"use strict";
|
|
@@ -1643,6 +1646,7 @@ var init_plugin = __esm({
|
|
|
1643
1646
|
babel2 = __toESM(require("@babel/core"));
|
|
1644
1647
|
import_react_router2 = require("react-router");
|
|
1645
1648
|
import_es_module_lexer = require("es-module-lexer");
|
|
1649
|
+
import_tinyglobby = require("tinyglobby");
|
|
1646
1650
|
import_pick3 = __toESM(require("lodash/pick"));
|
|
1647
1651
|
import_jsesc = __toESM(require("jsesc"));
|
|
1648
1652
|
import_picocolors4 = __toESM(require("picocolors"));
|
package/dist/config.js
CHANGED
package/dist/routes.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UNSAFE_MiddlewareEnabled, unstable_InitialContext, AppLoadContext } from 'react-router';
|
|
2
2
|
import { Plugin } from 'vite';
|
|
3
|
-
import {
|
|
3
|
+
import { GetPlatformProxyOptions, PlatformProxy } from 'wrangler';
|
|
4
4
|
|
|
5
5
|
type MaybePromise<T> = T | Promise<T>;
|
|
6
6
|
type CfProperties = Record<string, unknown>;
|
package/dist/vite/cloudflare.js
CHANGED
package/dist/vite.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-9398cceaa
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -53,6 +53,7 @@ var fse = __toESM(require("fs-extra"));
|
|
|
53
53
|
var babel = __toESM(require("@babel/core"));
|
|
54
54
|
var import_react_router2 = require("react-router");
|
|
55
55
|
var import_es_module_lexer = require("es-module-lexer");
|
|
56
|
+
var import_tinyglobby = require("tinyglobby");
|
|
56
57
|
var import_pick3 = __toESM(require("lodash/pick"));
|
|
57
58
|
var import_jsesc = __toESM(require("jsesc"));
|
|
58
59
|
var import_picocolors3 = __toESM(require("picocolors"));
|
|
@@ -915,7 +916,7 @@ function generateRoutes(ctx) {
|
|
|
915
916
|
lineages.set(route.id, lineage2);
|
|
916
917
|
const fullpath2 = fullpath(lineage2);
|
|
917
918
|
if (!fullpath2) continue;
|
|
918
|
-
const pages =
|
|
919
|
+
const pages = expand(fullpath2);
|
|
919
920
|
pages.forEach((page) => allPages.add(page));
|
|
920
921
|
lineage2.forEach(({ id }) => {
|
|
921
922
|
let routePages = routeToPages.get(id);
|
|
@@ -1123,9 +1124,13 @@ function getRouteAnnotations({
|
|
|
1123
1124
|
}
|
|
1124
1125
|
function relativeImportSource(from, to) {
|
|
1125
1126
|
let path6 = Path3.relative(Path3.dirname(from), to);
|
|
1127
|
+
let extension = Path3.extname(path6);
|
|
1126
1128
|
path6 = Path3.join(Path3.dirname(path6), Pathe.filename(path6));
|
|
1127
1129
|
if (!path6.startsWith("../")) path6 = "./" + path6;
|
|
1128
|
-
|
|
1130
|
+
if (!extension || /\.(js|ts)x?$/.test(extension)) {
|
|
1131
|
+
extension = ".js";
|
|
1132
|
+
}
|
|
1133
|
+
return path6 + extension;
|
|
1129
1134
|
}
|
|
1130
1135
|
function rootDirsPath(ctx, typesPath) {
|
|
1131
1136
|
const rel = Path3.relative(typesDirectory(ctx), typesPath);
|
|
@@ -1144,28 +1149,27 @@ function paramsType(path6) {
|
|
|
1144
1149
|
})
|
|
1145
1150
|
);
|
|
1146
1151
|
}
|
|
1147
|
-
function
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1152
|
+
function expand(fullpath2) {
|
|
1153
|
+
function recurse(segments2, index) {
|
|
1154
|
+
if (index === segments2.length) return [""];
|
|
1155
|
+
const segment = segments2[index];
|
|
1156
|
+
const isOptional = segment.endsWith("?");
|
|
1157
|
+
const isDynamic = segment.startsWith(":");
|
|
1158
|
+
const required = segment.replace(/\?$/, "");
|
|
1159
|
+
const keep = !isOptional || isDynamic;
|
|
1160
|
+
const kept = isDynamic ? segment : required;
|
|
1161
|
+
const withoutSegment = recurse(segments2, index + 1);
|
|
1162
|
+
const withSegment = withoutSegment.map((rest) => [kept, rest].join("/"));
|
|
1163
|
+
if (keep) return withSegment;
|
|
1164
|
+
return [...withoutSegment, ...withSegment];
|
|
1155
1165
|
}
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
result
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
)
|
|
1162
|
-
);
|
|
1163
|
-
if (isOptional) {
|
|
1164
|
-
result.push(...restExploded);
|
|
1166
|
+
const segments = fullpath2.split("/");
|
|
1167
|
+
const expanded = /* @__PURE__ */ new Set();
|
|
1168
|
+
for (let result of recurse(segments, 0)) {
|
|
1169
|
+
if (result !== "/") result = result.replace(/\/$/, "");
|
|
1170
|
+
expanded.add(result);
|
|
1165
1171
|
}
|
|
1166
|
-
return
|
|
1167
|
-
(exploded) => path6.startsWith("/") && exploded === "" ? "/" : exploded
|
|
1168
|
-
);
|
|
1172
|
+
return expanded;
|
|
1169
1173
|
}
|
|
1170
1174
|
|
|
1171
1175
|
// typegen/index.ts
|
|
@@ -2966,6 +2970,7 @@ var reactRouterVitePlugin = () => {
|
|
|
2966
2970
|
config: async (_viteUserConfig, _viteConfigEnv) => {
|
|
2967
2971
|
await preloadVite();
|
|
2968
2972
|
let vite2 = getVite();
|
|
2973
|
+
let viteMajorVersion = parseInt(vite2.version.split(".")[0], 10);
|
|
2969
2974
|
viteUserConfig = _viteUserConfig;
|
|
2970
2975
|
viteConfigEnv = _viteConfigEnv;
|
|
2971
2976
|
viteCommand = viteConfigEnv.command;
|
|
@@ -3024,7 +3029,13 @@ var reactRouterVitePlugin = () => {
|
|
|
3024
3029
|
...Object.values(ctx.reactRouterConfig.routes).map(
|
|
3025
3030
|
(route) => resolveRelativeRouteFilePath(route, ctx.reactRouterConfig)
|
|
3026
3031
|
)
|
|
3027
|
-
]
|
|
3032
|
+
].map(
|
|
3033
|
+
(entry) => (
|
|
3034
|
+
// In Vite 7, the `optimizeDeps.entries` option only accepts glob patterns.
|
|
3035
|
+
// In prior versions, absolute file paths were treated differently.
|
|
3036
|
+
viteMajorVersion >= 7 ? (0, import_tinyglobby.escapePath)(entry) : entry
|
|
3037
|
+
)
|
|
3038
|
+
) : [],
|
|
3028
3039
|
include: [
|
|
3029
3040
|
// Pre-bundle React dependencies to avoid React duplicates,
|
|
3030
3041
|
// even if React dependencies are not direct dependencies.
|
|
@@ -3271,7 +3282,7 @@ var reactRouterVitePlugin = () => {
|
|
|
3271
3282
|
if (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi) {
|
|
3272
3283
|
viteDevServer.middlewares.use(async (req, res, next) => {
|
|
3273
3284
|
let [reqPathname, reqSearch] = (req.url ?? "").split("?");
|
|
3274
|
-
if (reqPathname
|
|
3285
|
+
if (reqPathname.endsWith("/@react-router/critical.css")) {
|
|
3275
3286
|
let pathname = new URLSearchParams(reqSearch).get("pathname");
|
|
3276
3287
|
if (!pathname) {
|
|
3277
3288
|
return next("No pathname provided");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-router/dev",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-9398cceaa",
|
|
4
4
|
"description": "Dev tools and CLI for React Router",
|
|
5
5
|
"homepage": "https://reactrouter.com",
|
|
6
6
|
"bugs": {
|
|
@@ -84,9 +84,10 @@
|
|
|
84
84
|
"react-refresh": "^0.14.0",
|
|
85
85
|
"semver": "^7.3.7",
|
|
86
86
|
"set-cookie-parser": "^2.6.0",
|
|
87
|
+
"tinyglobby": "^0.2.14",
|
|
87
88
|
"valibot": "^0.41.0",
|
|
88
89
|
"vite-node": "^3.1.4",
|
|
89
|
-
"@react-router/node": "0.0.0-experimental-
|
|
90
|
+
"@react-router/node": "0.0.0-experimental-9398cceaa"
|
|
90
91
|
},
|
|
91
92
|
"devDependencies": {
|
|
92
93
|
"@types/babel__core": "^7.20.5",
|
|
@@ -110,15 +111,15 @@
|
|
|
110
111
|
"vite": "^6.1.0",
|
|
111
112
|
"wireit": "0.14.9",
|
|
112
113
|
"wrangler": "^4.2.0",
|
|
113
|
-
"
|
|
114
|
-
"react-router": "
|
|
114
|
+
"react-router": "^0.0.0-experimental-9398cceaa",
|
|
115
|
+
"@react-router/serve": "0.0.0-experimental-9398cceaa"
|
|
115
116
|
},
|
|
116
117
|
"peerDependencies": {
|
|
117
118
|
"typescript": "^5.1.0",
|
|
118
|
-
"vite": "^5.1.0 || ^6.0.0",
|
|
119
|
+
"vite": "^5.1.0 || ^6.0.0 || ^7.0.0",
|
|
119
120
|
"wrangler": "^3.28.2 || ^4.0.0",
|
|
120
|
-
"react-router": "^0.0.0-experimental-
|
|
121
|
-
"
|
|
121
|
+
"@react-router/serve": "^0.0.0-experimental-9398cceaa",
|
|
122
|
+
"react-router": "^0.0.0-experimental-9398cceaa"
|
|
122
123
|
},
|
|
123
124
|
"peerDependenciesMeta": {
|
|
124
125
|
"@react-router/serve": {
|