@react-router/dev 7.7.1-pre.0 → 7.8.0-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 +14 -4
- package/dist/cli/index.js +28 -18
- package/dist/config/default-rsc-entries/entry.client.tsx +36 -0
- package/dist/config/default-rsc-entries/entry.rsc.tsx +34 -0
- package/dist/config/default-rsc-entries/entry.ssr.tsx +29 -0
- package/dist/config.d.ts +5 -1
- package/dist/config.js +1 -1
- package/dist/internal.d.ts +9 -0
- package/dist/internal.js +1636 -0
- package/dist/{routes-DHIOx0R9.d.ts → routes-CZR-bKRt.d.ts} +1 -1
- package/dist/routes.d.ts +1 -1
- package/dist/routes.js +1 -1
- package/dist/vite/cloudflare.d.ts +2 -2
- package/dist/vite/cloudflare.js +24 -16
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +53 -18
- package/package.json +12 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
# `@react-router/dev`
|
|
2
2
|
|
|
3
|
-
## 7.
|
|
3
|
+
## 7.8.0-pre.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix rename without mkdir in Vite plugin ([#14105](https://github.com/remix-run/react-router/pull/14105))
|
|
8
|
+
- Updated dependencies:
|
|
9
|
+
- `react-router@7.8.0-pre.0`
|
|
10
|
+
- `@react-router/node@7.8.0-pre.0`
|
|
11
|
+
- `@react-router/serve@7.8.0-pre.0`
|
|
12
|
+
|
|
13
|
+
## 7.7.1
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
6
16
|
|
|
7
17
|
- Update to Prettier v3 for formatting when running `react-router reveal --no-typescript` ([#14049](https://github.com/remix-run/react-router/pull/14049))
|
|
8
18
|
- Updated dependencies:
|
|
9
|
-
- `react-router@7.7.1
|
|
10
|
-
- `@react-router/node@7.7.1
|
|
11
|
-
- `@react-router/serve@7.7.1
|
|
19
|
+
- `react-router@7.7.1`
|
|
20
|
+
- `@react-router/node@7.7.1`
|
|
21
|
+
- `@react-router/serve@7.7.1`
|
|
12
22
|
|
|
13
23
|
## 7.7.0
|
|
14
24
|
|
package/dist/cli/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* @react-router/dev v7.
|
|
3
|
+
* @react-router/dev v7.8.0-pre.0
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) Remix Software Inc.
|
|
6
6
|
*
|
|
@@ -223,9 +223,12 @@ ${message}`
|
|
|
223
223
|
].flat().join("\n\n")
|
|
224
224
|
};
|
|
225
225
|
}
|
|
226
|
-
return {
|
|
226
|
+
return {
|
|
227
|
+
valid: true,
|
|
228
|
+
routeConfig
|
|
229
|
+
};
|
|
227
230
|
}
|
|
228
|
-
function configRoutesToRouteManifest(appDirectory, routes2
|
|
231
|
+
function configRoutesToRouteManifest(appDirectory, routes2) {
|
|
229
232
|
let routeManifest = {};
|
|
230
233
|
function walk(route, parentId) {
|
|
231
234
|
let id = route.id || createRouteId(route.file);
|
|
@@ -250,7 +253,7 @@ function configRoutesToRouteManifest(appDirectory, routes2, rootId = "root") {
|
|
|
250
253
|
}
|
|
251
254
|
}
|
|
252
255
|
for (let route of routes2) {
|
|
253
|
-
walk(route
|
|
256
|
+
walk(route);
|
|
254
257
|
}
|
|
255
258
|
return routeManifest;
|
|
256
259
|
}
|
|
@@ -424,11 +427,11 @@ async function resolveConfig({
|
|
|
424
427
|
`Could not find a root route module in the app directory as "${rootRouteDisplayPath}"`
|
|
425
428
|
);
|
|
426
429
|
}
|
|
427
|
-
let routes2
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
430
|
+
let routes2;
|
|
431
|
+
let routeConfig = [];
|
|
432
|
+
if (skipRoutes) {
|
|
433
|
+
routes2 = {};
|
|
434
|
+
} else {
|
|
432
435
|
let routeConfigFile = findEntry(appDirectory, "routes");
|
|
433
436
|
try {
|
|
434
437
|
if (!routeConfigFile) {
|
|
@@ -444,18 +447,22 @@ async function resolveConfig({
|
|
|
444
447
|
let routeConfigExport = (await viteNodeContext.runner.executeFile(
|
|
445
448
|
import_pathe3.default.join(appDirectory, routeConfigFile)
|
|
446
449
|
)).default;
|
|
447
|
-
let routeConfig = await routeConfigExport;
|
|
448
450
|
let result = validateRouteConfig({
|
|
449
451
|
routeConfigFile,
|
|
450
|
-
routeConfig
|
|
452
|
+
routeConfig: await routeConfigExport
|
|
451
453
|
});
|
|
452
454
|
if (!result.valid) {
|
|
453
455
|
return err(result.message);
|
|
454
456
|
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
457
|
+
routeConfig = [
|
|
458
|
+
{
|
|
459
|
+
id: "root",
|
|
460
|
+
path: "",
|
|
461
|
+
file: rootRouteFile,
|
|
462
|
+
children: result.routeConfig
|
|
463
|
+
}
|
|
464
|
+
];
|
|
465
|
+
routes2 = configRoutesToRouteManifest(appDirectory, routeConfig);
|
|
459
466
|
} catch (error) {
|
|
460
467
|
return err(
|
|
461
468
|
[
|
|
@@ -488,7 +495,8 @@ async function resolveConfig({
|
|
|
488
495
|
serverBuildFile,
|
|
489
496
|
serverBundles,
|
|
490
497
|
serverModuleFormat,
|
|
491
|
-
ssr
|
|
498
|
+
ssr,
|
|
499
|
+
unstable_routeConfig: routeConfig
|
|
492
500
|
});
|
|
493
501
|
for (let preset of reactRouterUserConfig.presets ?? []) {
|
|
494
502
|
await preset.reactRouterConfigResolved?.({ reactRouterConfig });
|
|
@@ -1816,7 +1824,7 @@ async function viteAppBuild(root, {
|
|
|
1816
1824
|
},
|
|
1817
1825
|
configResolved(config) {
|
|
1818
1826
|
let hasReactRouterPlugin = config.plugins.find(
|
|
1819
|
-
(plugin) => plugin.name === "react-router"
|
|
1827
|
+
(plugin) => plugin.name === "react-router" || plugin.name === "react-router/rsc/config"
|
|
1820
1828
|
);
|
|
1821
1829
|
if (!hasReactRouterPlugin) {
|
|
1822
1830
|
throw new Error(
|
|
@@ -1955,7 +1963,9 @@ async function dev(root, {
|
|
|
1955
1963
|
clearScreen,
|
|
1956
1964
|
logLevel
|
|
1957
1965
|
});
|
|
1958
|
-
if (!server.config.plugins.find(
|
|
1966
|
+
if (!server.config.plugins.find(
|
|
1967
|
+
(plugin) => plugin.name === "react-router" || plugin.name === "react-router/rsc/config"
|
|
1968
|
+
)) {
|
|
1959
1969
|
console.error(
|
|
1960
1970
|
import_picocolors6.default.red("React Router Vite plugin not found in Vite config")
|
|
1961
1971
|
);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { startTransition, StrictMode } from "react";
|
|
2
|
+
import { hydrateRoot } from "react-dom/client";
|
|
3
|
+
import {
|
|
4
|
+
createFromReadableStream,
|
|
5
|
+
createTemporaryReferenceSet,
|
|
6
|
+
encodeReply,
|
|
7
|
+
setServerCallback,
|
|
8
|
+
} from "@vitejs/plugin-rsc/browser";
|
|
9
|
+
import {
|
|
10
|
+
unstable_createCallServer as createCallServer,
|
|
11
|
+
unstable_getRSCStream as getRSCStream,
|
|
12
|
+
unstable_RSCHydratedRouter as RSCHydratedRouter,
|
|
13
|
+
} from "react-router";
|
|
14
|
+
import type { unstable_RSCPayload as RSCPayload } from "react-router";
|
|
15
|
+
|
|
16
|
+
setServerCallback(
|
|
17
|
+
createCallServer({
|
|
18
|
+
createFromReadableStream,
|
|
19
|
+
createTemporaryReferenceSet,
|
|
20
|
+
encodeReply,
|
|
21
|
+
}),
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
createFromReadableStream<RSCPayload>(getRSCStream()).then((payload) => {
|
|
25
|
+
startTransition(() => {
|
|
26
|
+
hydrateRoot(
|
|
27
|
+
document,
|
|
28
|
+
<StrictMode>
|
|
29
|
+
<RSCHydratedRouter
|
|
30
|
+
payload={payload}
|
|
31
|
+
createFromReadableStream={createFromReadableStream}
|
|
32
|
+
/>
|
|
33
|
+
</StrictMode>,
|
|
34
|
+
);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createTemporaryReferenceSet,
|
|
3
|
+
decodeAction,
|
|
4
|
+
decodeReply,
|
|
5
|
+
loadServerAction,
|
|
6
|
+
renderToReadableStream,
|
|
7
|
+
} from "@vitejs/plugin-rsc/rsc";
|
|
8
|
+
import { unstable_matchRSCServerRequest as matchRSCServerRequest } from "react-router";
|
|
9
|
+
|
|
10
|
+
import routes from "virtual:react-router/unstable_rsc/routes";
|
|
11
|
+
|
|
12
|
+
export async function fetchServer(request: Request) {
|
|
13
|
+
return await matchRSCServerRequest({
|
|
14
|
+
createTemporaryReferenceSet,
|
|
15
|
+
decodeReply,
|
|
16
|
+
decodeAction,
|
|
17
|
+
loadServerAction,
|
|
18
|
+
request,
|
|
19
|
+
routes,
|
|
20
|
+
generateResponse(match, options) {
|
|
21
|
+
return new Response(renderToReadableStream(match.payload, options), {
|
|
22
|
+
status: match.statusCode,
|
|
23
|
+
headers: match.headers,
|
|
24
|
+
});
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default async function handler(request: Request) {
|
|
30
|
+
const ssr = await import.meta.viteRsc.loadModule<
|
|
31
|
+
typeof import("./entry.ssr")
|
|
32
|
+
>("ssr", "index");
|
|
33
|
+
return ssr.default(request, fetchServer);
|
|
34
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createFromReadableStream } from "@vitejs/plugin-rsc/ssr";
|
|
2
|
+
// @ts-expect-error
|
|
3
|
+
import * as ReactDomServer from "react-dom/server.edge";
|
|
4
|
+
import {
|
|
5
|
+
unstable_RSCStaticRouter as RSCStaticRouter,
|
|
6
|
+
unstable_routeRSCServerRequest as routeRSCServerRequest,
|
|
7
|
+
} from "react-router";
|
|
8
|
+
|
|
9
|
+
export default async function handler(
|
|
10
|
+
request: Request,
|
|
11
|
+
fetchServer: (request: Request) => Promise<Response>,
|
|
12
|
+
) {
|
|
13
|
+
const bootstrapScriptContent =
|
|
14
|
+
await import.meta.viteRsc.loadBootstrapScriptContent("index");
|
|
15
|
+
return routeRSCServerRequest({
|
|
16
|
+
request,
|
|
17
|
+
fetchServer,
|
|
18
|
+
createFromReadableStream,
|
|
19
|
+
renderHTML(getPayload) {
|
|
20
|
+
return ReactDomServer.renderToReadableStream(
|
|
21
|
+
<RSCStaticRouter getPayload={getPayload} />,
|
|
22
|
+
{
|
|
23
|
+
bootstrapScriptContent,
|
|
24
|
+
signal: request.signal,
|
|
25
|
+
},
|
|
26
|
+
);
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as Vite from 'vite';
|
|
2
|
-
import { R as RouteManifest, a as RouteManifestEntry } from './routes-
|
|
2
|
+
import { R as RouteManifest, a as RouteManifestEntry, b as RouteConfigEntry } from './routes-CZR-bKRt.js';
|
|
3
3
|
import 'valibot';
|
|
4
4
|
|
|
5
5
|
declare const excludedConfigPresetKeys: readonly ["presets"];
|
|
@@ -202,6 +202,10 @@ type ResolvedReactRouterConfig = Readonly<{
|
|
|
202
202
|
* SPA without server-rendering. Default's to `true`.
|
|
203
203
|
*/
|
|
204
204
|
ssr: boolean;
|
|
205
|
+
/**
|
|
206
|
+
* The resolved array of route config entries exported from `routes.ts`
|
|
207
|
+
*/
|
|
208
|
+
unstable_routeConfig: RouteConfigEntry[];
|
|
205
209
|
}>;
|
|
206
210
|
|
|
207
211
|
export type { BuildManifest, ReactRouterConfig as Config, Preset, ServerBundlesFunction };
|
package/dist/config.js
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as Vite from 'vite';
|
|
2
|
+
|
|
3
|
+
declare function reactRouterRSCVitePlugin(): Vite.PluginOption[];
|
|
4
|
+
|
|
5
|
+
declare const __INTERNAL_DO_NOT_USE_OR_YOU_WILL_GET_A_STRONGLY_WORDED_LETTER__: {
|
|
6
|
+
unstable_reactRouterRSC: typeof reactRouterRSCVitePlugin;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { __INTERNAL_DO_NOT_USE_OR_YOU_WILL_GET_A_STRONGLY_WORDED_LETTER__ };
|