@c0va23/react-router-dev 7.8.3-alpha.1 → 7.9.4-patch.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 +173 -0
- package/dist/cli/index.js +102 -52
- package/dist/config/default-rsc-entries/entry.rsc.tsx +3 -0
- package/dist/config/default-rsc-entries/entry.ssr.tsx +2 -4
- package/dist/config.js +1 -1
- package/dist/routes.js +1 -1
- package/dist/vite/cloudflare.js +13 -79
- package/dist/vite.d.ts +3 -1
- package/dist/vite.js +1140 -235
- package/package.json +19 -24
- package/LICENSE.md +0 -23
- package/dist/internal.d.ts +0 -9
- package/dist/internal.js +0 -2216
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,178 @@
|
|
|
1
1
|
# `@react-router/dev`
|
|
2
2
|
|
|
3
|
+
### Patch Changes
|
|
4
|
+
- Copy `server.watch` config options from `vite.config.(ts|js)` file to child vite server in development mode.
|
|
5
|
+
|
|
6
|
+
## 7.9.4
|
|
7
|
+
|
|
8
|
+
### Patch Changes
|
|
9
|
+
|
|
10
|
+
- Update `valibot` dependency to `^1.1.0` ([#14379](https://github.com/remix-run/react-router/pull/14379))
|
|
11
|
+
|
|
12
|
+
- New (unstable) `useRoute` hook for accessing data from specific routes ([#14407](https://github.com/remix-run/react-router/pull/14407))
|
|
13
|
+
|
|
14
|
+
For example, let's say you have an `admin` route somewhere in your app and you want any child routes of `admin` to all have access to the `loaderData` and `actionData` from `admin.`
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
// app/routes/admin.tsx
|
|
18
|
+
import { Outlet } from "react-router";
|
|
19
|
+
|
|
20
|
+
export const loader = () => ({ message: "Hello, loader!" });
|
|
21
|
+
|
|
22
|
+
export const action = () => ({ count: 1 });
|
|
23
|
+
|
|
24
|
+
export default function Component() {
|
|
25
|
+
return (
|
|
26
|
+
<div>
|
|
27
|
+
{/* ... */}
|
|
28
|
+
<Outlet />
|
|
29
|
+
{/* ... */}
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
You might even want to create a reusable widget that all of the routes nested under `admin` could use:
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
import { unstable_useRoute as useRoute } from "react-router";
|
|
39
|
+
|
|
40
|
+
export function AdminWidget() {
|
|
41
|
+
// How to get `message` and `count` from `admin` route?
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
In framework mode, `useRoute` knows all your app's routes and gives you TS errors when invalid route IDs are passed in:
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
export function AdminWidget() {
|
|
49
|
+
const admin = useRoute("routes/dmin");
|
|
50
|
+
// ^^^^^^^^^^^
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`useRoute` returns `undefined` if the route is not part of the current page:
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
export function AdminWidget() {
|
|
58
|
+
const admin = useRoute("routes/admin");
|
|
59
|
+
if (!admin) {
|
|
60
|
+
throw new Error(`AdminWidget used outside of "routes/admin"`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Note: the `root` route is the exception since it is guaranteed to be part of the current page.
|
|
66
|
+
As a result, `useRoute` never returns `undefined` for `root`.
|
|
67
|
+
|
|
68
|
+
`loaderData` and `actionData` are marked as optional since they could be accessed before the `action` is triggered or after the `loader` threw an error:
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
export function AdminWidget() {
|
|
72
|
+
const admin = useRoute("routes/admin");
|
|
73
|
+
if (!admin) {
|
|
74
|
+
throw new Error(`AdminWidget used outside of "routes/admin"`);
|
|
75
|
+
}
|
|
76
|
+
const { loaderData, actionData } = admin;
|
|
77
|
+
console.log(loaderData);
|
|
78
|
+
// ^? { message: string } | undefined
|
|
79
|
+
console.log(actionData);
|
|
80
|
+
// ^? { count: number } | undefined
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
If instead of a specific route, you wanted access to the _current_ route's `loaderData` and `actionData`, you can call `useRoute` without arguments:
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
export function AdminWidget() {
|
|
88
|
+
const currentRoute = useRoute();
|
|
89
|
+
currentRoute.loaderData;
|
|
90
|
+
currentRoute.actionData;
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
This usage is equivalent to calling `useLoaderData` and `useActionData`, but consolidates all route data access into one hook: `useRoute`.
|
|
95
|
+
|
|
96
|
+
Note: when calling `useRoute()` (without a route ID), TS has no way to know which route is the current route.
|
|
97
|
+
As a result, `loaderData` and `actionData` are typed as `unknown`.
|
|
98
|
+
If you want more type-safety, you can either narrow the type yourself with something like `zod` or you can refactor your app to pass down typed props to your `AdminWidget`:
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
export function AdminWidget({
|
|
102
|
+
message,
|
|
103
|
+
count,
|
|
104
|
+
}: {
|
|
105
|
+
message: string;
|
|
106
|
+
count: number;
|
|
107
|
+
}) {
|
|
108
|
+
/* ... */
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
- Updated dependencies:
|
|
113
|
+
- `react-router@7.9.4`
|
|
114
|
+
- `@react-router/node@7.9.4`
|
|
115
|
+
- `@react-router/serve@7.9.4`
|
|
116
|
+
|
|
117
|
+
## 7.9.3
|
|
118
|
+
|
|
119
|
+
### Patch Changes
|
|
120
|
+
|
|
121
|
+
- Updated dependencies:
|
|
122
|
+
- `react-router@7.9.3`
|
|
123
|
+
- `@react-router/node@7.9.3`
|
|
124
|
+
- `@react-router/serve@7.9.3`
|
|
125
|
+
|
|
126
|
+
## 7.9.2
|
|
127
|
+
|
|
128
|
+
### Patch Changes
|
|
129
|
+
|
|
130
|
+
- Fix preset future flags being ignored during config resolution ([#14369](https://github.com/remix-run/react-router/pull/14369))
|
|
131
|
+
|
|
132
|
+
Fixes a bug where future flags defined by presets were completely ignored. The config resolution was incorrectly reading from `reactRouterUserConfig.future` instead of the merged `userAndPresetConfigs.future`, causing all preset-defined future flags to be lost.
|
|
133
|
+
|
|
134
|
+
This fix ensures presets can properly enable experimental features as intended by the preset system design.
|
|
135
|
+
|
|
136
|
+
- Add unstable support for RSC Framework Mode ([#14336](https://github.com/remix-run/react-router/pull/14336))
|
|
137
|
+
|
|
138
|
+
- Switch internal vite plugin Response logic to use `@remix-run/node-fetch-server` ([#13927](https://github.com/remix-run/react-router/pull/13927))
|
|
139
|
+
|
|
140
|
+
- Updated dependencies:
|
|
141
|
+
- `react-router@7.9.2`
|
|
142
|
+
- `@react-router/serve@7.9.2`
|
|
143
|
+
- `@react-router/node@7.9.2`
|
|
144
|
+
|
|
145
|
+
## 7.9.1
|
|
146
|
+
|
|
147
|
+
### Patch Changes
|
|
148
|
+
|
|
149
|
+
- Fix internal `Future` interface naming from `middleware` -> `v8_middleware` ([#14327](https://github.com/remix-run/react-router/pull/14327))
|
|
150
|
+
- Updated dependencies:
|
|
151
|
+
- `react-router@7.9.1`
|
|
152
|
+
- `@react-router/node@7.9.1`
|
|
153
|
+
- `@react-router/serve@7.9.1`
|
|
154
|
+
|
|
155
|
+
## 7.9.0
|
|
156
|
+
|
|
157
|
+
### Minor Changes
|
|
158
|
+
|
|
159
|
+
- Stabilize middleware and context APIs. ([#14215](https://github.com/remix-run/react-router/pull/14215))
|
|
160
|
+
|
|
161
|
+
We have removed the `unstable_` prefix from the following APIs and they are now considered stable and ready for production use:
|
|
162
|
+
- [`RouterContextProvider`](https://reactrouter.com/api/utils/RouterContextProvider)
|
|
163
|
+
- [`createContext`](https://reactrouter.com/api/utils/createContext)
|
|
164
|
+
- `createBrowserRouter` [`getContext`](https://reactrouter.com/api/data-routers/createBrowserRouter#optsgetcontext) option
|
|
165
|
+
- `<HydratedRouter>` [`getContext`](https://reactrouter.com/api/framework-routers/HydratedRouter#getcontext) prop
|
|
166
|
+
|
|
167
|
+
Please see the [Middleware Docs](https://reactrouter.com/how-to/middleware), the [Middleware RFC](https://github.com/remix-run/remix/discussions/7642), and the [Client-side Context RFC](https://github.com/remix-run/react-router/discussions/9856) for more information.
|
|
168
|
+
|
|
169
|
+
### Patch Changes
|
|
170
|
+
|
|
171
|
+
- Updated dependencies:
|
|
172
|
+
- `react-router@7.9.0`
|
|
173
|
+
- `@react-router/node@7.9.0`
|
|
174
|
+
- `@react-router/serve@7.9.0`
|
|
175
|
+
|
|
3
176
|
## 7.8.2
|
|
4
177
|
|
|
5
178
|
### Patch Changes
|
package/dist/cli/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* @c0va23/react-router-dev v7.
|
|
3
|
+
* @c0va23/react-router-dev v7.9.4-patch.1
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) Remix Software Inc.
|
|
6
6
|
*
|
|
@@ -424,7 +424,7 @@ async function resolveConfig({
|
|
|
424
424
|
}
|
|
425
425
|
let appDirectory = import_pathe3.default.resolve(root, userAppDirectory || "app");
|
|
426
426
|
let buildDirectory = import_pathe3.default.resolve(root, userBuildDirectory);
|
|
427
|
-
let rootRouteFile = findEntry(appDirectory, "root");
|
|
427
|
+
let rootRouteFile = findEntry(appDirectory, "root", { absolute: true });
|
|
428
428
|
if (!rootRouteFile) {
|
|
429
429
|
let rootRouteDisplayPath = import_pathe3.default.relative(
|
|
430
430
|
root,
|
|
@@ -465,7 +465,7 @@ async function resolveConfig({
|
|
|
465
465
|
{
|
|
466
466
|
id: "root",
|
|
467
467
|
path: "",
|
|
468
|
-
file: rootRouteFile,
|
|
468
|
+
file: import_pathe3.default.relative(appDirectory, rootRouteFile),
|
|
469
469
|
children: result.routeConfig
|
|
470
470
|
}
|
|
471
471
|
];
|
|
@@ -484,11 +484,11 @@ async function resolveConfig({
|
|
|
484
484
|
}
|
|
485
485
|
}
|
|
486
486
|
let future = {
|
|
487
|
-
v8_middleware:
|
|
488
|
-
unstable_optimizeDeps:
|
|
489
|
-
unstable_splitRouteModules:
|
|
490
|
-
unstable_subResourceIntegrity:
|
|
491
|
-
unstable_viteEnvironmentApi:
|
|
487
|
+
v8_middleware: userAndPresetConfigs.future?.v8_middleware ?? false,
|
|
488
|
+
unstable_optimizeDeps: userAndPresetConfigs.future?.unstable_optimizeDeps ?? false,
|
|
489
|
+
unstable_splitRouteModules: userAndPresetConfigs.future?.unstable_splitRouteModules ?? false,
|
|
490
|
+
unstable_subResourceIntegrity: userAndPresetConfigs.future?.unstable_subResourceIntegrity ?? false,
|
|
491
|
+
unstable_viteEnvironmentApi: userAndPresetConfigs.future?.unstable_viteEnvironmentApi ?? false
|
|
492
492
|
};
|
|
493
493
|
let reactRouterConfig = deepFreeze({
|
|
494
494
|
appDirectory,
|
|
@@ -812,7 +812,8 @@ var init_profiler = __esm({
|
|
|
812
812
|
async function createContext2({
|
|
813
813
|
rootDirectory,
|
|
814
814
|
watch: watch2,
|
|
815
|
-
mode
|
|
815
|
+
mode,
|
|
816
|
+
rsc
|
|
816
817
|
}) {
|
|
817
818
|
const configLoader = await createConfigLoader({ rootDirectory, mode, watch: watch2 });
|
|
818
819
|
const configResult = await configLoader.getConfig();
|
|
@@ -823,7 +824,8 @@ async function createContext2({
|
|
|
823
824
|
return {
|
|
824
825
|
configLoader,
|
|
825
826
|
rootDirectory,
|
|
826
|
-
config
|
|
827
|
+
config,
|
|
828
|
+
rsc
|
|
827
829
|
};
|
|
828
830
|
}
|
|
829
831
|
var init_context = __esm({
|
|
@@ -911,7 +913,7 @@ function generateFuture(ctx) {
|
|
|
911
913
|
|
|
912
914
|
declare module "react-router" {
|
|
913
915
|
interface Future {
|
|
914
|
-
|
|
916
|
+
v8_middleware: ${ctx.config.future.v8_middleware}
|
|
915
917
|
}
|
|
916
918
|
}
|
|
917
919
|
`;
|
|
@@ -978,9 +980,10 @@ function generateRoutes(ctx) {
|
|
|
978
980
|
interface Register {
|
|
979
981
|
pages: Pages
|
|
980
982
|
routeFiles: RouteFiles
|
|
983
|
+
routeModules: RouteModules
|
|
981
984
|
}
|
|
982
985
|
}
|
|
983
|
-
` + "\n\n" + generate(pagesType(allPages)).code + "\n\n" + generate(routeFilesType({ fileToRoutes, routeToPages })).code
|
|
986
|
+
` + "\n\n" + generate(pagesType(allPages)).code + "\n\n" + generate(routeFilesType({ fileToRoutes, routeToPages })).code + "\n\n" + generate(routeModulesType(ctx)).code
|
|
984
987
|
};
|
|
985
988
|
const allAnnotations = Array.from(fileToRoutes.entries()).filter(([file]) => isInAppDirectory(ctx, file)).map(
|
|
986
989
|
([file, routeIds]) => getRouteAnnotations({ ctx, file, routeIds, lineages })
|
|
@@ -1049,6 +1052,28 @@ function routeFilesType({
|
|
|
1049
1052
|
)
|
|
1050
1053
|
);
|
|
1051
1054
|
}
|
|
1055
|
+
function routeModulesType(ctx) {
|
|
1056
|
+
return t2.tsTypeAliasDeclaration(
|
|
1057
|
+
t2.identifier("RouteModules"),
|
|
1058
|
+
null,
|
|
1059
|
+
t2.tsTypeLiteral(
|
|
1060
|
+
Object.values(ctx.config.routes).map(
|
|
1061
|
+
(route) => t2.tsPropertySignature(
|
|
1062
|
+
t2.stringLiteral(route.id),
|
|
1063
|
+
t2.tsTypeAnnotation(
|
|
1064
|
+
t2.tsTypeQuery(
|
|
1065
|
+
t2.tsImportType(
|
|
1066
|
+
t2.stringLiteral(
|
|
1067
|
+
`./${Path3.relative(ctx.rootDirectory, ctx.config.appDirectory)}/${route.file}`
|
|
1068
|
+
)
|
|
1069
|
+
)
|
|
1070
|
+
)
|
|
1071
|
+
)
|
|
1072
|
+
)
|
|
1073
|
+
)
|
|
1074
|
+
)
|
|
1075
|
+
);
|
|
1076
|
+
}
|
|
1052
1077
|
function isInAppDirectory(ctx, routeFile) {
|
|
1053
1078
|
const path9 = Path3.resolve(ctx.config.appDirectory, routeFile);
|
|
1054
1079
|
return path9.startsWith(ctx.config.appDirectory);
|
|
@@ -1116,7 +1141,7 @@ function getRouteAnnotations({
|
|
|
1116
1141
|
module: Module
|
|
1117
1142
|
}>
|
|
1118
1143
|
` + "\n\n" + generate(matchesType).code + "\n\n" + import_dedent.default`
|
|
1119
|
-
type Annotations = GetAnnotations<Info & { module: Module, matches: Matches }>;
|
|
1144
|
+
type Annotations = GetAnnotations<Info & { module: Module, matches: Matches }, ${ctx.rsc}>;
|
|
1120
1145
|
|
|
1121
1146
|
export namespace Route {
|
|
1122
1147
|
// links
|
|
@@ -1240,8 +1265,8 @@ async function write(...files) {
|
|
|
1240
1265
|
})
|
|
1241
1266
|
);
|
|
1242
1267
|
}
|
|
1243
|
-
async function run(rootDirectory, { mode }) {
|
|
1244
|
-
const ctx = await createContext2({ rootDirectory, mode, watch: false });
|
|
1268
|
+
async function run(rootDirectory, { mode, rsc }) {
|
|
1269
|
+
const ctx = await createContext2({ rootDirectory, mode, rsc, watch: false });
|
|
1245
1270
|
await import_promises.default.rm(typesDirectory(ctx), { recursive: true, force: true });
|
|
1246
1271
|
await write(
|
|
1247
1272
|
generateFuture(ctx),
|
|
@@ -1249,8 +1274,8 @@ async function run(rootDirectory, { mode }) {
|
|
|
1249
1274
|
...generateRoutes(ctx)
|
|
1250
1275
|
);
|
|
1251
1276
|
}
|
|
1252
|
-
async function watch(rootDirectory, { mode, logger }) {
|
|
1253
|
-
const ctx = await createContext2({ rootDirectory, mode, watch: true });
|
|
1277
|
+
async function watch(rootDirectory, { mode, logger, rsc }) {
|
|
1278
|
+
const ctx = await createContext2({ rootDirectory, mode, rsc, watch: true });
|
|
1254
1279
|
await import_promises.default.rm(typesDirectory(ctx), { recursive: true, force: true });
|
|
1255
1280
|
await write(
|
|
1256
1281
|
generateFuture(ctx),
|
|
@@ -1329,15 +1354,11 @@ var init_has_rsc_plugin = __esm({
|
|
|
1329
1354
|
});
|
|
1330
1355
|
|
|
1331
1356
|
// vite/node-adapter.ts
|
|
1332
|
-
var
|
|
1357
|
+
var import_node_fetch_server;
|
|
1333
1358
|
var init_node_adapter = __esm({
|
|
1334
1359
|
"vite/node-adapter.ts"() {
|
|
1335
1360
|
"use strict";
|
|
1336
|
-
|
|
1337
|
-
import_node_tls = require("tls");
|
|
1338
|
-
import_node_stream = require("stream");
|
|
1339
|
-
import_set_cookie_parser = require("set-cookie-parser");
|
|
1340
|
-
import_node = require("@react-router/node");
|
|
1361
|
+
import_node_fetch_server = require("@remix-run/node-fetch-server");
|
|
1341
1362
|
init_invariant();
|
|
1342
1363
|
}
|
|
1343
1364
|
});
|
|
@@ -1489,6 +1510,13 @@ var init_with_props = __esm({
|
|
|
1489
1510
|
}
|
|
1490
1511
|
});
|
|
1491
1512
|
|
|
1513
|
+
// vite/load-dotenv.ts
|
|
1514
|
+
var init_load_dotenv = __esm({
|
|
1515
|
+
"vite/load-dotenv.ts"() {
|
|
1516
|
+
"use strict";
|
|
1517
|
+
}
|
|
1518
|
+
});
|
|
1519
|
+
|
|
1492
1520
|
// vite/plugins/validate-plugin-order.ts
|
|
1493
1521
|
var init_validate_plugin_order = __esm({
|
|
1494
1522
|
"vite/plugins/validate-plugin-order.ts"() {
|
|
@@ -1496,6 +1524,16 @@ var init_validate_plugin_order = __esm({
|
|
|
1496
1524
|
}
|
|
1497
1525
|
});
|
|
1498
1526
|
|
|
1527
|
+
// vite/plugins/warn-on-client-source-maps.ts
|
|
1528
|
+
var import_picocolors4;
|
|
1529
|
+
var init_warn_on_client_source_maps = __esm({
|
|
1530
|
+
"vite/plugins/warn-on-client-source-maps.ts"() {
|
|
1531
|
+
"use strict";
|
|
1532
|
+
import_picocolors4 = __toESM(require("picocolors"));
|
|
1533
|
+
init_invariant();
|
|
1534
|
+
}
|
|
1535
|
+
});
|
|
1536
|
+
|
|
1499
1537
|
// vite/plugin.ts
|
|
1500
1538
|
async function resolveViteConfig({
|
|
1501
1539
|
configFile,
|
|
@@ -1733,7 +1771,7 @@ function resolveEnvironmentsOptions(environmentResolvers, resolverOptions) {
|
|
|
1733
1771
|
function isNonNullable(x) {
|
|
1734
1772
|
return x != null;
|
|
1735
1773
|
}
|
|
1736
|
-
var import_node_crypto, import_node_fs3, import_promises2, path7, url, babel2, import_react_router2, import_es_module_lexer, import_pick3, import_jsesc,
|
|
1774
|
+
var import_node_crypto, import_node_fs3, import_promises2, path7, url, babel2, import_node_fetch_server2, import_react_router2, import_es_module_lexer, import_pick3, import_jsesc, import_picocolors5, 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;
|
|
1737
1775
|
var init_plugin = __esm({
|
|
1738
1776
|
"vite/plugin.ts"() {
|
|
1739
1777
|
"use strict";
|
|
@@ -1743,11 +1781,12 @@ var init_plugin = __esm({
|
|
|
1743
1781
|
path7 = __toESM(require("path"));
|
|
1744
1782
|
url = __toESM(require("url"));
|
|
1745
1783
|
babel2 = __toESM(require("@babel/core"));
|
|
1784
|
+
import_node_fetch_server2 = require("@remix-run/node-fetch-server");
|
|
1746
1785
|
import_react_router2 = require("react-router");
|
|
1747
1786
|
import_es_module_lexer = require("es-module-lexer");
|
|
1748
1787
|
import_pick3 = __toESM(require("lodash/pick"));
|
|
1749
1788
|
import_jsesc = __toESM(require("jsesc"));
|
|
1750
|
-
|
|
1789
|
+
import_picocolors5 = __toESM(require("picocolors"));
|
|
1751
1790
|
import_kebabCase = __toESM(require("lodash/kebabCase"));
|
|
1752
1791
|
init_typegen();
|
|
1753
1792
|
init_invariant();
|
|
@@ -1766,7 +1805,9 @@ var init_plugin = __esm({
|
|
|
1766
1805
|
init_config();
|
|
1767
1806
|
init_optimize_deps_entries();
|
|
1768
1807
|
init_with_props();
|
|
1808
|
+
init_load_dotenv();
|
|
1769
1809
|
init_validate_plugin_order();
|
|
1810
|
+
init_warn_on_client_source_maps();
|
|
1770
1811
|
CLIENT_NON_COMPONENT_EXPORTS = [
|
|
1771
1812
|
"clientAction",
|
|
1772
1813
|
"clientLoader",
|
|
@@ -1948,7 +1989,7 @@ async function viteBuild(root, {
|
|
|
1948
1989
|
let ctx = extractPluginContext(viteConfig);
|
|
1949
1990
|
if (!ctx) {
|
|
1950
1991
|
console.error(
|
|
1951
|
-
|
|
1992
|
+
import_picocolors6.default.red("React Router Vite plugin not found in Vite config")
|
|
1952
1993
|
);
|
|
1953
1994
|
process.exit(1);
|
|
1954
1995
|
}
|
|
@@ -2005,11 +2046,11 @@ async function viteBuild(root, {
|
|
|
2005
2046
|
viteConfig
|
|
2006
2047
|
});
|
|
2007
2048
|
}
|
|
2008
|
-
var
|
|
2049
|
+
var import_picocolors6;
|
|
2009
2050
|
var init_build = __esm({
|
|
2010
2051
|
"vite/build.ts"() {
|
|
2011
2052
|
"use strict";
|
|
2012
|
-
|
|
2053
|
+
import_picocolors6 = __toESM(require("picocolors"));
|
|
2013
2054
|
init_config();
|
|
2014
2055
|
init_plugin();
|
|
2015
2056
|
init_invariant();
|
|
@@ -2050,7 +2091,7 @@ async function dev(root, {
|
|
|
2050
2091
|
(plugin) => plugin.name === "react-router" || plugin.name === "react-router/rsc"
|
|
2051
2092
|
)) {
|
|
2052
2093
|
console.error(
|
|
2053
|
-
|
|
2094
|
+
import_picocolors7.default.red("React Router Vite plugin not found in Vite config")
|
|
2054
2095
|
);
|
|
2055
2096
|
process.exit(1);
|
|
2056
2097
|
}
|
|
@@ -2073,11 +2114,11 @@ async function dev(root, {
|
|
|
2073
2114
|
];
|
|
2074
2115
|
server.bindCLIShortcuts({ print: true, customShortcuts });
|
|
2075
2116
|
}
|
|
2076
|
-
var
|
|
2117
|
+
var import_picocolors7;
|
|
2077
2118
|
var init_dev = __esm({
|
|
2078
2119
|
"vite/dev.ts"() {
|
|
2079
2120
|
"use strict";
|
|
2080
|
-
|
|
2121
|
+
import_picocolors7 = __toESM(require("picocolors"));
|
|
2081
2122
|
init_vite();
|
|
2082
2123
|
init_profiler();
|
|
2083
2124
|
}
|
|
@@ -2086,7 +2127,7 @@ var init_dev = __esm({
|
|
|
2086
2127
|
// cli/run.ts
|
|
2087
2128
|
var import_arg = __toESM(require("arg"));
|
|
2088
2129
|
var import_semver = __toESM(require("semver"));
|
|
2089
|
-
var
|
|
2130
|
+
var import_picocolors9 = __toESM(require("picocolors"));
|
|
2090
2131
|
|
|
2091
2132
|
// cli/commands.ts
|
|
2092
2133
|
var import_node_fs4 = require("fs");
|
|
@@ -2094,7 +2135,7 @@ var import_promises3 = require("fs/promises");
|
|
|
2094
2135
|
var path8 = __toESM(require("path"));
|
|
2095
2136
|
var import_package_json2 = __toESM(require("@npmcli/package-json"));
|
|
2096
2137
|
var import_exit_hook = __toESM(require("exit-hook"));
|
|
2097
|
-
var
|
|
2138
|
+
var import_picocolors8 = __toESM(require("picocolors"));
|
|
2098
2139
|
var import_react_router3 = require("react-router");
|
|
2099
2140
|
init_config();
|
|
2100
2141
|
|
|
@@ -2184,7 +2225,7 @@ async function routes(rootDirectory, flags = {}) {
|
|
|
2184
2225
|
mode: flags.mode ?? "production"
|
|
2185
2226
|
});
|
|
2186
2227
|
if (!configResult.ok) {
|
|
2187
|
-
console.error(
|
|
2228
|
+
console.error(import_picocolors8.default.red(configResult.error));
|
|
2188
2229
|
process.exit(1);
|
|
2189
2230
|
}
|
|
2190
2231
|
let format = flags.json ? "json" : "jsx";
|
|
@@ -2230,7 +2271,7 @@ async function generateEntry(entry, rootDirectory, flags = {}) {
|
|
|
2230
2271
|
}
|
|
2231
2272
|
})) {
|
|
2232
2273
|
console.error(
|
|
2233
|
-
|
|
2274
|
+
import_picocolors8.default.red(
|
|
2234
2275
|
`The reveal command is currently not supported in RSC Framework Mode.`
|
|
2235
2276
|
)
|
|
2236
2277
|
);
|
|
@@ -2246,7 +2287,7 @@ async function generateEntry(entry, rootDirectory, flags = {}) {
|
|
|
2246
2287
|
mode: flags.mode ?? "production"
|
|
2247
2288
|
});
|
|
2248
2289
|
if (!configResult.ok) {
|
|
2249
|
-
console.error(
|
|
2290
|
+
console.error(import_picocolors8.default.red(configResult.error));
|
|
2250
2291
|
return;
|
|
2251
2292
|
}
|
|
2252
2293
|
let appDirectory = configResult.value.appDirectory;
|
|
@@ -2254,14 +2295,14 @@ async function generateEntry(entry, rootDirectory, flags = {}) {
|
|
|
2254
2295
|
let entriesArray = Array.from(entries);
|
|
2255
2296
|
let list = conjunctionListFormat.format(entriesArray);
|
|
2256
2297
|
console.error(
|
|
2257
|
-
|
|
2298
|
+
import_picocolors8.default.red(`Invalid entry file. Valid entry files are ${list}`)
|
|
2258
2299
|
);
|
|
2259
2300
|
return;
|
|
2260
2301
|
}
|
|
2261
2302
|
let pkgJson = await import_package_json2.default.load(rootDirectory);
|
|
2262
2303
|
let deps = pkgJson.content.dependencies ?? {};
|
|
2263
2304
|
if (!deps["@react-router/node"]) {
|
|
2264
|
-
console.error(
|
|
2305
|
+
console.error(import_picocolors8.default.red(`No default server entry detected.`));
|
|
2265
2306
|
return;
|
|
2266
2307
|
}
|
|
2267
2308
|
let defaultsDirectory = path8.resolve(
|
|
@@ -2291,7 +2332,7 @@ async function generateEntry(entry, rootDirectory, flags = {}) {
|
|
|
2291
2332
|
await (0, import_promises3.writeFile)(outputFile, contents, "utf-8");
|
|
2292
2333
|
}
|
|
2293
2334
|
console.log(
|
|
2294
|
-
|
|
2335
|
+
import_picocolors8.default.blue(
|
|
2295
2336
|
`Entry file ${entry} created at ${path8.relative(
|
|
2296
2337
|
rootDirectory,
|
|
2297
2338
|
outputFile
|
|
@@ -2311,7 +2352,7 @@ async function checkForEntry(rootDirectory, appDirectory, entries2) {
|
|
|
2311
2352
|
let exists = (0, import_node_fs4.existsSync)(entryPath);
|
|
2312
2353
|
if (exists) {
|
|
2313
2354
|
let relative7 = path8.relative(rootDirectory, entryPath);
|
|
2314
|
-
console.error(
|
|
2355
|
+
console.error(import_picocolors8.default.red(`Entry file ${relative7} already exists.`));
|
|
2315
2356
|
return process.exit(1);
|
|
2316
2357
|
}
|
|
2317
2358
|
}
|
|
@@ -2328,12 +2369,20 @@ async function createClientEntry(rootDirectory, appDirectory, inputFile) {
|
|
|
2328
2369
|
}
|
|
2329
2370
|
async function typegen(root, flags) {
|
|
2330
2371
|
root = resolveRootDirectory(root, flags);
|
|
2372
|
+
const rsc = await hasReactRouterRscPlugin({
|
|
2373
|
+
root,
|
|
2374
|
+
viteBuildOptions: {
|
|
2375
|
+
config: flags.config,
|
|
2376
|
+
mode: flags.mode
|
|
2377
|
+
}
|
|
2378
|
+
});
|
|
2331
2379
|
if (flags.watch) {
|
|
2332
2380
|
await preloadVite();
|
|
2333
2381
|
const vite2 = getVite();
|
|
2334
2382
|
const logger = vite2.createLogger("info", { prefix: "[react-router]" });
|
|
2335
2383
|
await watch(root, {
|
|
2336
2384
|
mode: flags.mode ?? "development",
|
|
2385
|
+
rsc,
|
|
2337
2386
|
logger
|
|
2338
2387
|
});
|
|
2339
2388
|
await new Promise(() => {
|
|
@@ -2341,20 +2390,21 @@ async function typegen(root, flags) {
|
|
|
2341
2390
|
return;
|
|
2342
2391
|
}
|
|
2343
2392
|
await run(root, {
|
|
2344
|
-
mode: flags.mode ?? "production"
|
|
2393
|
+
mode: flags.mode ?? "production",
|
|
2394
|
+
rsc
|
|
2345
2395
|
});
|
|
2346
2396
|
}
|
|
2347
2397
|
|
|
2348
2398
|
// cli/run.ts
|
|
2349
2399
|
var helpText = `
|
|
2350
|
-
${
|
|
2400
|
+
${import_picocolors9.default.blueBright("react-router")}
|
|
2351
2401
|
|
|
2352
|
-
${
|
|
2353
|
-
$ react-router build [${
|
|
2354
|
-
$ react-router dev [${
|
|
2355
|
-
$ react-router routes [${
|
|
2402
|
+
${import_picocolors9.default.underline("Usage")}:
|
|
2403
|
+
$ react-router build [${import_picocolors9.default.yellowBright("projectDir")}]
|
|
2404
|
+
$ react-router dev [${import_picocolors9.default.yellowBright("projectDir")}]
|
|
2405
|
+
$ react-router routes [${import_picocolors9.default.yellowBright("projectDir")}]
|
|
2356
2406
|
|
|
2357
|
-
${
|
|
2407
|
+
${import_picocolors9.default.underline("Options")}:
|
|
2358
2408
|
--help, -h Print this help message and exit
|
|
2359
2409
|
--version, -v Print the CLI version and exit
|
|
2360
2410
|
--no-color Disable ANSI colors in console output
|
|
@@ -2390,22 +2440,22 @@ ${import_picocolors8.default.blueBright("react-router")}
|
|
|
2390
2440
|
\`typegen\` Options:
|
|
2391
2441
|
--watch Automatically regenerate types whenever route config (\`routes.ts\`) or route modules change
|
|
2392
2442
|
|
|
2393
|
-
${
|
|
2443
|
+
${import_picocolors9.default.underline("Build your project")}:
|
|
2394
2444
|
|
|
2395
2445
|
$ react-router build
|
|
2396
2446
|
|
|
2397
|
-
${
|
|
2447
|
+
${import_picocolors9.default.underline("Run your project locally in development")}:
|
|
2398
2448
|
|
|
2399
2449
|
$ react-router dev
|
|
2400
2450
|
|
|
2401
|
-
${
|
|
2451
|
+
${import_picocolors9.default.underline("Show all routes in your app")}:
|
|
2402
2452
|
|
|
2403
2453
|
$ react-router routes
|
|
2404
2454
|
$ react-router routes my-app
|
|
2405
2455
|
$ react-router routes --json
|
|
2406
2456
|
$ react-router routes --config vite.react-router.config.ts
|
|
2407
2457
|
|
|
2408
|
-
${
|
|
2458
|
+
${import_picocolors9.default.underline("Reveal the used entry point")}:
|
|
2409
2459
|
|
|
2410
2460
|
$ react-router reveal entry.client
|
|
2411
2461
|
$ react-router reveal entry.server
|
|
@@ -2413,7 +2463,7 @@ ${import_picocolors8.default.blueBright("react-router")}
|
|
|
2413
2463
|
$ react-router reveal entry.server --no-typescript
|
|
2414
2464
|
$ react-router reveal entry.server --config vite.react-router.config.ts
|
|
2415
2465
|
|
|
2416
|
-
${
|
|
2466
|
+
${import_picocolors9.default.underline("Generate types for route modules")}:
|
|
2417
2467
|
|
|
2418
2468
|
$ react-router typegen
|
|
2419
2469
|
$ react-router typegen --watch
|
|
@@ -10,6 +10,7 @@ import { unstable_matchRSCServerRequest as matchRSCServerRequest } from "react-r
|
|
|
10
10
|
|
|
11
11
|
import routes from "virtual:react-router/unstable_rsc/routes";
|
|
12
12
|
import basename from "virtual:react-router/unstable_rsc/basename";
|
|
13
|
+
import unstable_reactRouterServeConfig from "virtual:react-router/unstable_rsc/react-router-serve-config";
|
|
13
14
|
|
|
14
15
|
export async function fetchServer(request: Request) {
|
|
15
16
|
return await matchRSCServerRequest({
|
|
@@ -30,6 +31,8 @@ export async function fetchServer(request: Request) {
|
|
|
30
31
|
});
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
export { unstable_reactRouterServeConfig };
|
|
35
|
+
|
|
33
36
|
export default async function handler(request: Request) {
|
|
34
37
|
const ssr = await import.meta.viteRsc.loadModule<
|
|
35
38
|
typeof import("./entry.ssr")
|
|
@@ -18,16 +18,14 @@ export default async function handler(
|
|
|
18
18
|
fetchServer,
|
|
19
19
|
createFromReadableStream,
|
|
20
20
|
async renderHTML(getPayload) {
|
|
21
|
-
const payload =
|
|
22
|
-
const formState =
|
|
23
|
-
payload.type === "render" ? await payload.formState : undefined;
|
|
21
|
+
const payload = getPayload();
|
|
24
22
|
|
|
25
23
|
return ReactDomServer.renderToReadableStream(
|
|
26
24
|
<RSCStaticRouter getPayload={getPayload} />,
|
|
27
25
|
{
|
|
28
26
|
bootstrapScriptContent,
|
|
29
27
|
signal: request.signal,
|
|
30
|
-
formState,
|
|
28
|
+
formState: await payload.formState,
|
|
31
29
|
},
|
|
32
30
|
);
|
|
33
31
|
},
|
package/dist/config.js
CHANGED
package/dist/routes.js
CHANGED