@react-router/dev 0.0.0-experimental-d07149147 → 0.0.0-experimental-479e73b7b
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/bin.cjs +27 -0
- package/development-condition-enabled/false.d.mts +2 -0
- package/development-condition-enabled/false.mjs +2 -0
- package/development-condition-enabled/true.d.mts +2 -0
- package/development-condition-enabled/true.mjs +2 -0
- package/dist/build-BZ8ZGxs4.js +41 -0
- package/dist/cli/index.d.ts +2 -1
- package/dist/cli/index.js +462 -2651
- package/dist/config/default-rsc-entries/entry.rsc.tsx +3 -0
- package/dist/config/default-rsc-entries/entry.ssr.tsx +4 -0
- package/dist/config/defaults/entry.server.node.tsx +2 -4
- package/dist/config/defaults/entry.server.web.tsx +54 -0
- package/dist/config-t89niiFv.d.ts +280 -0
- package/dist/config.d.ts +2 -280
- package/dist/config.js +2 -19
- package/dist/dev-6WvjrRMD.js +53 -0
- package/dist/routes-D18xtDiC.js +194 -0
- package/dist/{routes-CZR-bKRt.d.ts → routes-Kx8VZRs3.d.ts} +63 -62
- package/dist/routes.d.ts +3 -2
- package/dist/routes.js +3 -190
- package/dist/typegen-DSDdbRfE.js +885 -0
- package/dist/vite.d.ts +7 -6
- package/dist/vite.js +3305 -6609
- package/module-sync-enabled/index.mjs +2 -2
- package/package.json +78 -61
- package/rsc-types.d.ts +10 -0
- package/bin.js +0 -15
- package/dist/vite/cloudflare.d.ts +0 -24
- package/dist/vite/cloudflare.js +0 -949
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
import routes from "virtual:react-router/unstable_rsc/routes";
|
|
16
16
|
import routeDiscovery from "virtual:react-router/unstable_rsc/route-discovery";
|
|
17
17
|
import basename from "virtual:react-router/unstable_rsc/basename";
|
|
18
|
+
import clientVersion from "virtual:react-router/unstable_rsc/client-version";
|
|
18
19
|
import unstable_reactRouterServeConfig from "virtual:react-router/unstable_rsc/react-router-serve-config";
|
|
19
20
|
|
|
20
21
|
export { unstable_reactRouterServeConfig };
|
|
@@ -31,6 +32,8 @@ export function fetchServer(
|
|
|
31
32
|
decodeFormState,
|
|
32
33
|
decodeReply,
|
|
33
34
|
loadServerAction,
|
|
35
|
+
// Detect stale clients after a new deployment.
|
|
36
|
+
clientVersion,
|
|
34
37
|
// The incoming request.
|
|
35
38
|
request,
|
|
36
39
|
requestContext,
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
unstable_routeRSCServerRequest as routeRSCServerRequest,
|
|
5
5
|
unstable_RSCStaticRouter as RSCStaticRouter,
|
|
6
6
|
} from "react-router";
|
|
7
|
+
import subResourceIntegrity from "virtual:react-router/unstable_rsc/subresource-integrity";
|
|
7
8
|
|
|
8
9
|
export async function generateHTML(
|
|
9
10
|
request: Request,
|
|
@@ -31,6 +32,9 @@ export async function generateHTML(
|
|
|
31
32
|
...options,
|
|
32
33
|
bootstrapScriptContent,
|
|
33
34
|
formState,
|
|
35
|
+
importMap: subResourceIntegrity
|
|
36
|
+
? { integrity: subResourceIntegrity }
|
|
37
|
+
: undefined,
|
|
34
38
|
signal: request.signal,
|
|
35
39
|
},
|
|
36
40
|
);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PassThrough } from "node:stream";
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { EntryContext, RouterContextProvider } from "react-router";
|
|
4
4
|
import { createReadableStreamFromReadable } from "@react-router/node";
|
|
5
5
|
import { ServerRouter } from "react-router";
|
|
6
6
|
import { isbot } from "isbot";
|
|
@@ -14,9 +14,7 @@ export default function handleRequest(
|
|
|
14
14
|
responseStatusCode: number,
|
|
15
15
|
responseHeaders: Headers,
|
|
16
16
|
routerContext: EntryContext,
|
|
17
|
-
loadContext:
|
|
18
|
-
// If you have middleware enabled:
|
|
19
|
-
// loadContext: RouterContextProvider
|
|
17
|
+
loadContext: RouterContextProvider,
|
|
20
18
|
) {
|
|
21
19
|
// https://httpwg.org/specs/rfc9110.html#HEAD
|
|
22
20
|
if (request.method.toUpperCase() === "HEAD") {
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { EntryContext, RouterContextProvider } from "react-router";
|
|
2
|
+
import { ServerRouter } from "react-router";
|
|
3
|
+
import { isbot } from "isbot";
|
|
4
|
+
import { renderToReadableStream } from "react-dom/server";
|
|
5
|
+
|
|
6
|
+
export const streamTimeout = 5_000;
|
|
7
|
+
|
|
8
|
+
export default async function handleRequest(
|
|
9
|
+
request: Request,
|
|
10
|
+
responseStatusCode: number,
|
|
11
|
+
responseHeaders: Headers,
|
|
12
|
+
routerContext: EntryContext,
|
|
13
|
+
_loadContext: RouterContextProvider,
|
|
14
|
+
) {
|
|
15
|
+
// https://httpwg.org/specs/rfc9110.html#HEAD
|
|
16
|
+
if (request.method.toUpperCase() === "HEAD") {
|
|
17
|
+
return new Response(null, {
|
|
18
|
+
status: responseStatusCode,
|
|
19
|
+
headers: responseHeaders,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let shellRendered = false;
|
|
24
|
+
let userAgent = request.headers.get("user-agent");
|
|
25
|
+
|
|
26
|
+
const body = await renderToReadableStream(
|
|
27
|
+
<ServerRouter context={routerContext} url={request.url} />,
|
|
28
|
+
{
|
|
29
|
+
signal: AbortSignal.timeout(streamTimeout + 1000),
|
|
30
|
+
onError(error: unknown) {
|
|
31
|
+
responseStatusCode = 500;
|
|
32
|
+
// Log streaming rendering errors from inside the shell. Don't log
|
|
33
|
+
// errors encountered during initial shell rendering since they'll
|
|
34
|
+
// reject and get logged in handleDocumentRequest.
|
|
35
|
+
if (shellRendered) {
|
|
36
|
+
console.error(error);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
);
|
|
41
|
+
shellRendered = true;
|
|
42
|
+
|
|
43
|
+
// Ensure requests from bots and SPA Mode renders wait for all content to load before responding
|
|
44
|
+
// https://react.dev/reference/react-dom/server/renderToPipeableStream#waiting-for-all-content-to-load-for-crawlers-and-static-generation
|
|
45
|
+
if ((userAgent && isbot(userAgent)) || routerContext.isSpaMode) {
|
|
46
|
+
await body.allReady;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
responseHeaders.set("Content-Type", "text/html");
|
|
50
|
+
return new Response(body, {
|
|
51
|
+
headers: responseHeaders,
|
|
52
|
+
status: responseStatusCode,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
|
|
2
|
+
import { i as RouteManifestEntry, n as RouteConfigEntry, r as RouteManifest } from "./routes-Kx8VZRs3.js";
|
|
3
|
+
import * as Vite from "vite";
|
|
4
|
+
|
|
5
|
+
//#region config/config.d.ts
|
|
6
|
+
declare const excludedConfigPresetKeys: readonly ["presets"];
|
|
7
|
+
type ExcludedConfigPresetKey = (typeof excludedConfigPresetKeys)[number];
|
|
8
|
+
type ConfigPreset = Omit<ReactRouterConfig, ExcludedConfigPresetKey>;
|
|
9
|
+
type Preset = {
|
|
10
|
+
name: string;
|
|
11
|
+
reactRouterConfig?: (args: {
|
|
12
|
+
reactRouterUserConfig: ReactRouterConfig;
|
|
13
|
+
}) => ConfigPreset | Promise<ConfigPreset>;
|
|
14
|
+
reactRouterConfigResolved?: (args: {
|
|
15
|
+
reactRouterConfig: ResolvedReactRouterConfig;
|
|
16
|
+
}) => void | Promise<void>;
|
|
17
|
+
};
|
|
18
|
+
declare const branchRouteProperties: readonly ["id", "path", "file", "index"];
|
|
19
|
+
type BranchRoute = Pick<RouteManifestEntry, (typeof branchRouteProperties)[number]>;
|
|
20
|
+
type ServerBundlesFunction = (args: {
|
|
21
|
+
branch: BranchRoute[];
|
|
22
|
+
}) => string | Promise<string>;
|
|
23
|
+
type BaseBuildManifest = {
|
|
24
|
+
routes: RouteManifest;
|
|
25
|
+
};
|
|
26
|
+
type DefaultBuildManifest = BaseBuildManifest & {
|
|
27
|
+
serverBundles?: never;
|
|
28
|
+
routeIdToServerBundleId?: never;
|
|
29
|
+
};
|
|
30
|
+
type ServerBundlesBuildManifest = BaseBuildManifest & {
|
|
31
|
+
serverBundles: {
|
|
32
|
+
[serverBundleId: string]: {
|
|
33
|
+
id: string;
|
|
34
|
+
file: string;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
routeIdToServerBundleId: Record<string, string>;
|
|
38
|
+
};
|
|
39
|
+
type ServerModuleFormat = "esm" | "cjs";
|
|
40
|
+
interface FutureConfig {
|
|
41
|
+
unstable_enableNodeReadableStream: boolean;
|
|
42
|
+
unstable_optimizeDeps: boolean;
|
|
43
|
+
}
|
|
44
|
+
type SplitRouteModulesOption = boolean | "enforce";
|
|
45
|
+
type BuildManifest = DefaultBuildManifest | ServerBundlesBuildManifest;
|
|
46
|
+
type BuildEndHook = (args: {
|
|
47
|
+
buildManifest: BuildManifest | undefined;
|
|
48
|
+
reactRouterConfig: ResolvedReactRouterConfig;
|
|
49
|
+
viteConfig: Vite.ResolvedConfig;
|
|
50
|
+
}) => void | Promise<void>;
|
|
51
|
+
type PrerenderPaths = boolean | Array<string> | ((args: {
|
|
52
|
+
getStaticPaths: () => string[];
|
|
53
|
+
}) => Array<string> | Promise<Array<string>>);
|
|
54
|
+
/**
|
|
55
|
+
* Config to be exported via the default export from `react-router.config.ts`.
|
|
56
|
+
*/
|
|
57
|
+
type ReactRouterConfig = {
|
|
58
|
+
/**
|
|
59
|
+
* The path to the `app` directory, relative to the root directory. Defaults
|
|
60
|
+
* to `"app"`.
|
|
61
|
+
*/
|
|
62
|
+
appDirectory?: string;
|
|
63
|
+
/**
|
|
64
|
+
* The output format of the server build. Defaults to "esm".
|
|
65
|
+
*/
|
|
66
|
+
serverModuleFormat?: ServerModuleFormat;
|
|
67
|
+
/**
|
|
68
|
+
* Enabled future flags
|
|
69
|
+
*/
|
|
70
|
+
future?: [keyof FutureConfig] extends [never] ? {
|
|
71
|
+
[key: string]: never;
|
|
72
|
+
} : Partial<FutureConfig>;
|
|
73
|
+
/**
|
|
74
|
+
* Automatically split route modules into multiple chunks when possible.
|
|
75
|
+
*
|
|
76
|
+
* This can be set to `false` to keep route modules in a single chunk, or
|
|
77
|
+
* `"enforce"` to require all routes to be splittable.
|
|
78
|
+
*
|
|
79
|
+
* Defaults to `true`.
|
|
80
|
+
*/
|
|
81
|
+
splitRouteModules?: SplitRouteModulesOption;
|
|
82
|
+
/**
|
|
83
|
+
* The React Router app basename. Defaults to `"/"`.
|
|
84
|
+
*/
|
|
85
|
+
basename?: string;
|
|
86
|
+
/**
|
|
87
|
+
* The path to the build directory, relative to the project. Defaults to
|
|
88
|
+
* `"build"`.
|
|
89
|
+
*/
|
|
90
|
+
buildDirectory?: string;
|
|
91
|
+
/**
|
|
92
|
+
* A function that is called after the full React Router build is complete.
|
|
93
|
+
*/
|
|
94
|
+
buildEnd?: BuildEndHook;
|
|
95
|
+
/**
|
|
96
|
+
* An array of URLs to prerender to HTML files at build time. Can also be a
|
|
97
|
+
* function returning an array to dynamically generate URLs.
|
|
98
|
+
*
|
|
99
|
+
* `concurrency` defaults to 1, which means "no concurrency" - fully serial execution.
|
|
100
|
+
* Setting it to a value more than 1 enables concurrent prerendering.
|
|
101
|
+
* Setting it to a value higher than one can increase the speed of the build,
|
|
102
|
+
* but may consume more resources, and send more concurrent requests to the
|
|
103
|
+
* server/CMS.
|
|
104
|
+
*/
|
|
105
|
+
prerender?: PrerenderPaths | {
|
|
106
|
+
paths: PrerenderPaths;
|
|
107
|
+
concurrency?: number;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* An array of React Router plugin config presets to ease integration with
|
|
111
|
+
* other platforms and tools.
|
|
112
|
+
*/
|
|
113
|
+
presets?: Array<Preset>;
|
|
114
|
+
/**
|
|
115
|
+
* Control the "Lazy Route Discovery" behavior
|
|
116
|
+
*
|
|
117
|
+
* - `routeDiscovery.mode`: By default, this resolves to `lazy` which will
|
|
118
|
+
* lazily discover routes as the user navigates around your application.
|
|
119
|
+
* You can set this to `initial` to opt-out of this behavior and load all
|
|
120
|
+
* routes with the initial HTML document load.
|
|
121
|
+
* - `routeDiscovery.manifestPath`: The path to serve the manifest file from.
|
|
122
|
+
* Only applies to `mode: "lazy"` and defaults to `/__manifest`.
|
|
123
|
+
*/
|
|
124
|
+
routeDiscovery?: {
|
|
125
|
+
mode: "lazy";
|
|
126
|
+
manifestPath?: string;
|
|
127
|
+
} | {
|
|
128
|
+
mode: "initial";
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* The file name of the server build output. This file
|
|
132
|
+
* should end in a `.js` extension and should be deployed to your server.
|
|
133
|
+
* Defaults to `"index.js"`.
|
|
134
|
+
*/
|
|
135
|
+
serverBuildFile?: string;
|
|
136
|
+
/**
|
|
137
|
+
* A function for assigning routes to different server bundles. This
|
|
138
|
+
* function should return a server bundle ID which will be used as the
|
|
139
|
+
* bundle's directory name within the server build directory.
|
|
140
|
+
*/
|
|
141
|
+
serverBundles?: ServerBundlesFunction;
|
|
142
|
+
/**
|
|
143
|
+
* Enable server-side rendering for your application. Disable to use "SPA
|
|
144
|
+
* Mode", which will request the `/` path at build-time and save it as an
|
|
145
|
+
* `index.html` file with your assets so your application can be deployed as a
|
|
146
|
+
* SPA without server-rendering. Default's to `true`.
|
|
147
|
+
*/
|
|
148
|
+
ssr?: boolean;
|
|
149
|
+
/**
|
|
150
|
+
* Enable subresource integrity hashes on asset script tags. Defaults to
|
|
151
|
+
* `false`.
|
|
152
|
+
*/
|
|
153
|
+
subResourceIntegrity?: boolean;
|
|
154
|
+
/**
|
|
155
|
+
* An array of allowed origin hosts for action submissions to UI routes (does not apply
|
|
156
|
+
* to resource routes). Supports micromatch glob patterns (`*` to match one segment,
|
|
157
|
+
* `**` to match multiple).
|
|
158
|
+
*
|
|
159
|
+
* ```tsx
|
|
160
|
+
* export default {
|
|
161
|
+
* allowedActionOrigins: [
|
|
162
|
+
* "example.com",
|
|
163
|
+
* "*.example.com", // sub.example.com
|
|
164
|
+
* "**.example.com", // sub.domain.example.com
|
|
165
|
+
* ],
|
|
166
|
+
* } satisfies Config;
|
|
167
|
+
* ```
|
|
168
|
+
*
|
|
169
|
+
* If you need to set this value at runtime, you can do in by setting the value
|
|
170
|
+
* on the server build in your custom server. For example, when using `express`:
|
|
171
|
+
*
|
|
172
|
+
* ```ts
|
|
173
|
+
* import express from "express";
|
|
174
|
+
* import { createRequestHandler } from "@react-router/express";
|
|
175
|
+
* import type { ServerBuild } from "react-router";
|
|
176
|
+
*
|
|
177
|
+
* export const app = express();
|
|
178
|
+
*
|
|
179
|
+
* async function getBuild() {
|
|
180
|
+
* let build: ServerBuild = await import(
|
|
181
|
+
* "virtual:react-router/server-build"
|
|
182
|
+
* );
|
|
183
|
+
* return {
|
|
184
|
+
* ...build,
|
|
185
|
+
* allowedActionOrigins:
|
|
186
|
+
* process.env.NODE_ENV === "development"
|
|
187
|
+
* ? undefined
|
|
188
|
+
* : ["staging.example.com", "www.example.com"],
|
|
189
|
+
* };
|
|
190
|
+
* }
|
|
191
|
+
*
|
|
192
|
+
* app.use(createRequestHandler({ build: getBuild }));
|
|
193
|
+
*/
|
|
194
|
+
allowedActionOrigins?: string[];
|
|
195
|
+
};
|
|
196
|
+
type ResolvedReactRouterConfig = Readonly<{
|
|
197
|
+
/**
|
|
198
|
+
* The absolute path to the application source directory.
|
|
199
|
+
*/
|
|
200
|
+
appDirectory: string;
|
|
201
|
+
/**
|
|
202
|
+
* The React Router app basename. Defaults to `"/"`.
|
|
203
|
+
*/
|
|
204
|
+
basename: string;
|
|
205
|
+
/**
|
|
206
|
+
* The absolute path to the build directory.
|
|
207
|
+
*/
|
|
208
|
+
buildDirectory: string;
|
|
209
|
+
/**
|
|
210
|
+
* A function that is called after the full React Router build is complete.
|
|
211
|
+
*/
|
|
212
|
+
buildEnd?: BuildEndHook;
|
|
213
|
+
/**
|
|
214
|
+
* Enabled future flags
|
|
215
|
+
*/
|
|
216
|
+
future: FutureConfig;
|
|
217
|
+
/**
|
|
218
|
+
* Whether to automatically split route modules into multiple chunks when
|
|
219
|
+
* possible.
|
|
220
|
+
*/
|
|
221
|
+
splitRouteModules: SplitRouteModulesOption;
|
|
222
|
+
/**
|
|
223
|
+
* An array of URLs to prerender to HTML files at build time. Can also be a
|
|
224
|
+
* function returning an array to dynamically generate URLs.
|
|
225
|
+
*/
|
|
226
|
+
prerender: ReactRouterConfig["prerender"];
|
|
227
|
+
/**
|
|
228
|
+
* Control the "Lazy Route Discovery" behavior
|
|
229
|
+
*
|
|
230
|
+
* - `routeDiscovery.mode`: By default, this resolves to `lazy` which will
|
|
231
|
+
* lazily discover routes as the user navigates around your application.
|
|
232
|
+
* You can set this to `initial` to opt-out of this behavior and load all
|
|
233
|
+
* routes with the initial HTML document load.
|
|
234
|
+
* - `routeDiscovery.manifestPath`: The path to serve the manifest file from.
|
|
235
|
+
* Only applies to `mode: "lazy"` and defaults to `/__manifest`.
|
|
236
|
+
*/
|
|
237
|
+
routeDiscovery: ReactRouterConfig["routeDiscovery"];
|
|
238
|
+
/**
|
|
239
|
+
* An object of all available routes, keyed by route id.
|
|
240
|
+
*/
|
|
241
|
+
routes: RouteManifest;
|
|
242
|
+
/**
|
|
243
|
+
* The file name of the server build output. This file
|
|
244
|
+
* should end in a `.js` extension and should be deployed to your server.
|
|
245
|
+
* Defaults to `"index.js"`.
|
|
246
|
+
*/
|
|
247
|
+
serverBuildFile: string;
|
|
248
|
+
/**
|
|
249
|
+
* A function for assigning routes to different server bundles. This
|
|
250
|
+
* function should return a server bundle ID which will be used as the
|
|
251
|
+
* bundle's directory name within the server build directory.
|
|
252
|
+
*/
|
|
253
|
+
serverBundles?: ServerBundlesFunction;
|
|
254
|
+
/**
|
|
255
|
+
* The output format of the server build. Defaults to "esm".
|
|
256
|
+
*/
|
|
257
|
+
serverModuleFormat: ServerModuleFormat;
|
|
258
|
+
/**
|
|
259
|
+
* Enable server-side rendering for your application. Disable to use "SPA
|
|
260
|
+
* Mode", which will request the `/` path at build-time and save it as an
|
|
261
|
+
* `index.html` file with your assets so your application can be deployed as a
|
|
262
|
+
* SPA without server-rendering. Default's to `true`.
|
|
263
|
+
*/
|
|
264
|
+
ssr: boolean;
|
|
265
|
+
/**
|
|
266
|
+
* Whether to generate subresource integrity hashes for asset script tags.
|
|
267
|
+
*/
|
|
268
|
+
subResourceIntegrity: boolean;
|
|
269
|
+
/**
|
|
270
|
+
* The allowed origins for actions / mutations. Does not apply to routes
|
|
271
|
+
* without a component. micromatch glob patterns are supported.
|
|
272
|
+
*/
|
|
273
|
+
allowedActionOrigins: string[] | false;
|
|
274
|
+
/**
|
|
275
|
+
* The resolved array of route config entries exported from `routes.ts`
|
|
276
|
+
*/
|
|
277
|
+
unstable_routeConfig: RouteConfigEntry[];
|
|
278
|
+
}>;
|
|
279
|
+
//#endregion
|
|
280
|
+
export { ServerBundlesFunction as i, Preset as n, ReactRouterConfig as r, BuildManifest as t };
|
package/dist/config.d.ts
CHANGED
|
@@ -1,281 +1,3 @@
|
|
|
1
|
-
import * as Vite from 'vite';
|
|
2
|
-
import { R as RouteManifest, a as RouteManifestEntry, b as RouteConfigEntry } from './routes-CZR-bKRt.js';
|
|
3
|
-
import 'valibot';
|
|
4
1
|
|
|
5
|
-
|
|
6
|
-
type
|
|
7
|
-
type ConfigPreset = Omit<ReactRouterConfig, ExcludedConfigPresetKey>;
|
|
8
|
-
type Preset = {
|
|
9
|
-
name: string;
|
|
10
|
-
reactRouterConfig?: (args: {
|
|
11
|
-
reactRouterUserConfig: ReactRouterConfig;
|
|
12
|
-
}) => ConfigPreset | Promise<ConfigPreset>;
|
|
13
|
-
reactRouterConfigResolved?: (args: {
|
|
14
|
-
reactRouterConfig: ResolvedReactRouterConfig;
|
|
15
|
-
}) => void | Promise<void>;
|
|
16
|
-
};
|
|
17
|
-
declare const branchRouteProperties: readonly ["id", "path", "file", "index"];
|
|
18
|
-
type BranchRoute = Pick<RouteManifestEntry, (typeof branchRouteProperties)[number]>;
|
|
19
|
-
type ServerBundlesFunction = (args: {
|
|
20
|
-
branch: BranchRoute[];
|
|
21
|
-
}) => string | Promise<string>;
|
|
22
|
-
type BaseBuildManifest = {
|
|
23
|
-
routes: RouteManifest;
|
|
24
|
-
};
|
|
25
|
-
type DefaultBuildManifest = BaseBuildManifest & {
|
|
26
|
-
serverBundles?: never;
|
|
27
|
-
routeIdToServerBundleId?: never;
|
|
28
|
-
};
|
|
29
|
-
type ServerBundlesBuildManifest = BaseBuildManifest & {
|
|
30
|
-
serverBundles: {
|
|
31
|
-
[serverBundleId: string]: {
|
|
32
|
-
id: string;
|
|
33
|
-
file: string;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
routeIdToServerBundleId: Record<string, string>;
|
|
37
|
-
};
|
|
38
|
-
type ServerModuleFormat = "esm" | "cjs";
|
|
39
|
-
interface FutureConfig {
|
|
40
|
-
unstable_optimizeDeps: boolean;
|
|
41
|
-
v8_passThroughRequests: boolean;
|
|
42
|
-
v8_trailingSlashAwareDataRequests: boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Prerender with Vite Preview server
|
|
45
|
-
*/
|
|
46
|
-
unstable_previewServerPrerendering?: boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Enable route middleware
|
|
49
|
-
*/
|
|
50
|
-
v8_middleware: boolean;
|
|
51
|
-
/**
|
|
52
|
-
* Automatically split route modules into multiple chunks when possible.
|
|
53
|
-
*/
|
|
54
|
-
v8_splitRouteModules: boolean | "enforce";
|
|
55
|
-
/**
|
|
56
|
-
* Use Vite Environment API
|
|
57
|
-
*/
|
|
58
|
-
v8_viteEnvironmentApi: boolean;
|
|
59
|
-
}
|
|
60
|
-
type BuildManifest = DefaultBuildManifest | ServerBundlesBuildManifest;
|
|
61
|
-
type BuildEndHook = (args: {
|
|
62
|
-
buildManifest: BuildManifest | undefined;
|
|
63
|
-
reactRouterConfig: ResolvedReactRouterConfig;
|
|
64
|
-
viteConfig: Vite.ResolvedConfig;
|
|
65
|
-
}) => void | Promise<void>;
|
|
66
|
-
type PrerenderPaths = boolean | Array<string> | ((args: {
|
|
67
|
-
getStaticPaths: () => string[];
|
|
68
|
-
}) => Array<string> | Promise<Array<string>>);
|
|
69
|
-
/**
|
|
70
|
-
* Config to be exported via the default export from `react-router.config.ts`.
|
|
71
|
-
*/
|
|
72
|
-
type ReactRouterConfig = {
|
|
73
|
-
/**
|
|
74
|
-
* The path to the `app` directory, relative to the root directory. Defaults
|
|
75
|
-
* to `"app"`.
|
|
76
|
-
*/
|
|
77
|
-
appDirectory?: string;
|
|
78
|
-
/**
|
|
79
|
-
* The output format of the server build. Defaults to "esm".
|
|
80
|
-
*/
|
|
81
|
-
serverModuleFormat?: ServerModuleFormat;
|
|
82
|
-
/**
|
|
83
|
-
* Enabled future flags
|
|
84
|
-
*/
|
|
85
|
-
future?: [keyof FutureConfig] extends [never] ? {
|
|
86
|
-
[key: string]: never;
|
|
87
|
-
} : Partial<FutureConfig>;
|
|
88
|
-
/**
|
|
89
|
-
* The React Router app basename. Defaults to `"/"`.
|
|
90
|
-
*/
|
|
91
|
-
basename?: string;
|
|
92
|
-
/**
|
|
93
|
-
* The path to the build directory, relative to the project. Defaults to
|
|
94
|
-
* `"build"`.
|
|
95
|
-
*/
|
|
96
|
-
buildDirectory?: string;
|
|
97
|
-
/**
|
|
98
|
-
* A function that is called after the full React Router build is complete.
|
|
99
|
-
*/
|
|
100
|
-
buildEnd?: BuildEndHook;
|
|
101
|
-
/**
|
|
102
|
-
* An array of URLs to prerender to HTML files at build time. Can also be a
|
|
103
|
-
* function returning an array to dynamically generate URLs.
|
|
104
|
-
*
|
|
105
|
-
* `concurrency` defaults to 1, which means "no concurrency" - fully serial execution.
|
|
106
|
-
* Setting it to a value more than 1 enables concurrent prerendering.
|
|
107
|
-
* Setting it to a value higher than one can increase the speed of the build,
|
|
108
|
-
* but may consume more resources, and send more concurrent requests to the
|
|
109
|
-
* server/CMS.
|
|
110
|
-
*/
|
|
111
|
-
prerender?: PrerenderPaths | {
|
|
112
|
-
paths: PrerenderPaths;
|
|
113
|
-
concurrency?: number;
|
|
114
|
-
};
|
|
115
|
-
/**
|
|
116
|
-
* An array of React Router plugin config presets to ease integration with
|
|
117
|
-
* other platforms and tools.
|
|
118
|
-
*/
|
|
119
|
-
presets?: Array<Preset>;
|
|
120
|
-
/**
|
|
121
|
-
* Control the "Lazy Route Discovery" behavior
|
|
122
|
-
*
|
|
123
|
-
* - `routeDiscovery.mode`: By default, this resolves to `lazy` which will
|
|
124
|
-
* lazily discover routes as the user navigates around your application.
|
|
125
|
-
* You can set this to `initial` to opt-out of this behavior and load all
|
|
126
|
-
* routes with the initial HTML document load.
|
|
127
|
-
* - `routeDiscovery.manifestPath`: The path to serve the manifest file from.
|
|
128
|
-
* Only applies to `mode: "lazy"` and defaults to `/__manifest`.
|
|
129
|
-
*/
|
|
130
|
-
routeDiscovery?: {
|
|
131
|
-
mode: "lazy";
|
|
132
|
-
manifestPath?: string;
|
|
133
|
-
} | {
|
|
134
|
-
mode: "initial";
|
|
135
|
-
};
|
|
136
|
-
/**
|
|
137
|
-
* The file name of the server build output. This file
|
|
138
|
-
* should end in a `.js` extension and should be deployed to your server.
|
|
139
|
-
* Defaults to `"index.js"`.
|
|
140
|
-
*/
|
|
141
|
-
serverBuildFile?: string;
|
|
142
|
-
/**
|
|
143
|
-
* A function for assigning routes to different server bundles. This
|
|
144
|
-
* function should return a server bundle ID which will be used as the
|
|
145
|
-
* bundle's directory name within the server build directory.
|
|
146
|
-
*/
|
|
147
|
-
serverBundles?: ServerBundlesFunction;
|
|
148
|
-
/**
|
|
149
|
-
* Enable server-side rendering for your application. Disable to use "SPA
|
|
150
|
-
* Mode", which will request the `/` path at build-time and save it as an
|
|
151
|
-
* `index.html` file with your assets so your application can be deployed as a
|
|
152
|
-
* SPA without server-rendering. Default's to `true`.
|
|
153
|
-
*/
|
|
154
|
-
ssr?: boolean;
|
|
155
|
-
/**
|
|
156
|
-
* Enable subresource integrity hashes on asset script tags. Defaults to
|
|
157
|
-
* `false`.
|
|
158
|
-
*/
|
|
159
|
-
subResourceIntegrity?: boolean;
|
|
160
|
-
/**
|
|
161
|
-
* An array of allowed origin hosts for action submissions to UI routes (does not apply
|
|
162
|
-
* to resource routes). Supports micromatch glob patterns (`*` to match one segment,
|
|
163
|
-
* `**` to match multiple).
|
|
164
|
-
*
|
|
165
|
-
* ```tsx
|
|
166
|
-
* export default {
|
|
167
|
-
* allowedActionOrigins: [
|
|
168
|
-
* "example.com",
|
|
169
|
-
* "*.example.com", // sub.example.com
|
|
170
|
-
* "**.example.com", // sub.domain.example.com
|
|
171
|
-
* ],
|
|
172
|
-
* } satisfies Config;
|
|
173
|
-
* ```
|
|
174
|
-
*
|
|
175
|
-
* If you need to set this value at runtime, you can do in by setting the value
|
|
176
|
-
* on the server build in your custom server. For example, when using `express`:
|
|
177
|
-
*
|
|
178
|
-
* ```ts
|
|
179
|
-
* import express from "express";
|
|
180
|
-
* import { createRequestHandler } from "@react-router/express";
|
|
181
|
-
* import type { ServerBuild } from "react-router";
|
|
182
|
-
*
|
|
183
|
-
* export const app = express();
|
|
184
|
-
*
|
|
185
|
-
* async function getBuild() {
|
|
186
|
-
* let build: ServerBuild = await import(
|
|
187
|
-
* "virtual:react-router/server-build"
|
|
188
|
-
* );
|
|
189
|
-
* return {
|
|
190
|
-
* ...build,
|
|
191
|
-
* allowedActionOrigins:
|
|
192
|
-
* process.env.NODE_ENV === "development"
|
|
193
|
-
* ? undefined
|
|
194
|
-
* : ["staging.example.com", "www.example.com"],
|
|
195
|
-
* };
|
|
196
|
-
* }
|
|
197
|
-
*
|
|
198
|
-
* app.use(createRequestHandler({ build: getBuild }));
|
|
199
|
-
*/
|
|
200
|
-
allowedActionOrigins?: string[];
|
|
201
|
-
};
|
|
202
|
-
type ResolvedReactRouterConfig = Readonly<{
|
|
203
|
-
/**
|
|
204
|
-
* The absolute path to the application source directory.
|
|
205
|
-
*/
|
|
206
|
-
appDirectory: string;
|
|
207
|
-
/**
|
|
208
|
-
* The React Router app basename. Defaults to `"/"`.
|
|
209
|
-
*/
|
|
210
|
-
basename: string;
|
|
211
|
-
/**
|
|
212
|
-
* The absolute path to the build directory.
|
|
213
|
-
*/
|
|
214
|
-
buildDirectory: string;
|
|
215
|
-
/**
|
|
216
|
-
* A function that is called after the full React Router build is complete.
|
|
217
|
-
*/
|
|
218
|
-
buildEnd?: BuildEndHook;
|
|
219
|
-
/**
|
|
220
|
-
* Enabled future flags
|
|
221
|
-
*/
|
|
222
|
-
future: FutureConfig;
|
|
223
|
-
/**
|
|
224
|
-
* An array of URLs to prerender to HTML files at build time. Can also be a
|
|
225
|
-
* function returning an array to dynamically generate URLs.
|
|
226
|
-
*/
|
|
227
|
-
prerender: ReactRouterConfig["prerender"];
|
|
228
|
-
/**
|
|
229
|
-
* Control the "Lazy Route Discovery" behavior
|
|
230
|
-
*
|
|
231
|
-
* - `routeDiscovery.mode`: By default, this resolves to `lazy` which will
|
|
232
|
-
* lazily discover routes as the user navigates around your application.
|
|
233
|
-
* You can set this to `initial` to opt-out of this behavior and load all
|
|
234
|
-
* routes with the initial HTML document load.
|
|
235
|
-
* - `routeDiscovery.manifestPath`: The path to serve the manifest file from.
|
|
236
|
-
* Only applies to `mode: "lazy"` and defaults to `/__manifest`.
|
|
237
|
-
*/
|
|
238
|
-
routeDiscovery: ReactRouterConfig["routeDiscovery"];
|
|
239
|
-
/**
|
|
240
|
-
* An object of all available routes, keyed by route id.
|
|
241
|
-
*/
|
|
242
|
-
routes: RouteManifest;
|
|
243
|
-
/**
|
|
244
|
-
* The file name of the server build output. This file
|
|
245
|
-
* should end in a `.js` extension and should be deployed to your server.
|
|
246
|
-
* Defaults to `"index.js"`.
|
|
247
|
-
*/
|
|
248
|
-
serverBuildFile: string;
|
|
249
|
-
/**
|
|
250
|
-
* A function for assigning routes to different server bundles. This
|
|
251
|
-
* function should return a server bundle ID which will be used as the
|
|
252
|
-
* bundle's directory name within the server build directory.
|
|
253
|
-
*/
|
|
254
|
-
serverBundles?: ServerBundlesFunction;
|
|
255
|
-
/**
|
|
256
|
-
* The output format of the server build. Defaults to "esm".
|
|
257
|
-
*/
|
|
258
|
-
serverModuleFormat: ServerModuleFormat;
|
|
259
|
-
/**
|
|
260
|
-
* Enable server-side rendering for your application. Disable to use "SPA
|
|
261
|
-
* Mode", which will request the `/` path at build-time and save it as an
|
|
262
|
-
* `index.html` file with your assets so your application can be deployed as a
|
|
263
|
-
* SPA without server-rendering. Default's to `true`.
|
|
264
|
-
*/
|
|
265
|
-
ssr: boolean;
|
|
266
|
-
/**
|
|
267
|
-
* Whether to generate subresource integrity hashes for asset script tags.
|
|
268
|
-
*/
|
|
269
|
-
subResourceIntegrity: boolean;
|
|
270
|
-
/**
|
|
271
|
-
* The allowed origins for actions / mutations. Does not apply to routes
|
|
272
|
-
* without a component. micromatch glob patterns are supported.
|
|
273
|
-
*/
|
|
274
|
-
allowedActionOrigins: string[] | false;
|
|
275
|
-
/**
|
|
276
|
-
* The resolved array of route config entries exported from `routes.ts`
|
|
277
|
-
*/
|
|
278
|
-
unstable_routeConfig: RouteConfigEntry[];
|
|
279
|
-
}>;
|
|
280
|
-
|
|
281
|
-
export type { BuildManifest, ReactRouterConfig as Config, Preset, ServerBundlesFunction };
|
|
2
|
+
import { i as ServerBundlesFunction, n as Preset, r as ReactRouterConfig, t as BuildManifest } from "./config-t89niiFv.js";
|
|
3
|
+
export type { BuildManifest, ReactRouterConfig as Config, Preset, ServerBundlesFunction };
|