@c0va23/react-router-dev 7.8.3-alpha.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 +2512 -0
- package/LICENSE.md +23 -0
- package/README.md +5 -0
- package/bin.js +15 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +2521 -0
- package/dist/config/default-rsc-entries/entry.client.tsx +46 -0
- package/dist/config/default-rsc-entries/entry.rsc.tsx +42 -0
- package/dist/config/default-rsc-entries/entry.ssr.tsx +35 -0
- package/dist/config/defaults/entry.client.tsx +12 -0
- package/dist/config/defaults/entry.server.node.tsx +80 -0
- package/dist/config.d.ts +211 -0
- package/dist/config.js +28 -0
- package/dist/internal.d.ts +9 -0
- package/dist/internal.js +2216 -0
- package/dist/routes-CZR-bKRt.d.ts +123 -0
- package/dist/routes.d.ts +2 -0
- package/dist/routes.js +199 -0
- package/dist/static/refresh-utils.mjs +170 -0
- package/dist/static/rsc-refresh-utils.mjs +126 -0
- package/dist/vite/cloudflare.d.ts +24 -0
- package/dist/vite/cloudflare.js +900 -0
- package/dist/vite.d.ts +11 -0
- package/dist/vite.js +4914 -0
- package/module-sync-enabled/false.cjs +1 -0
- package/module-sync-enabled/index.d.mts +2 -0
- package/module-sync-enabled/index.mjs +4 -0
- package/module-sync-enabled/true.mjs +2 -0
- package/package.json +157 -0
|
@@ -0,0 +1,900 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @c0va23/react-router-dev v7.8.3-alpha.1
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) Remix Software Inc.
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
+
*
|
|
9
|
+
* @license MIT
|
|
10
|
+
*/
|
|
11
|
+
"use strict";
|
|
12
|
+
var __create = Object.create;
|
|
13
|
+
var __defProp = Object.defineProperty;
|
|
14
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
15
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
16
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
17
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
18
|
+
var __export = (target, all) => {
|
|
19
|
+
for (var name in all)
|
|
20
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
21
|
+
};
|
|
22
|
+
var __copyProps = (to, from, except, desc) => {
|
|
23
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
24
|
+
for (let key of __getOwnPropNames(from))
|
|
25
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
26
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
27
|
+
}
|
|
28
|
+
return to;
|
|
29
|
+
};
|
|
30
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
31
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
32
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
33
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
34
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
35
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
36
|
+
mod
|
|
37
|
+
));
|
|
38
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
39
|
+
|
|
40
|
+
// vite/cloudflare.ts
|
|
41
|
+
var cloudflare_exports = {};
|
|
42
|
+
__export(cloudflare_exports, {
|
|
43
|
+
cloudflareDevProxy: () => cloudflareDevProxyVitePlugin
|
|
44
|
+
});
|
|
45
|
+
module.exports = __toCommonJS(cloudflare_exports);
|
|
46
|
+
|
|
47
|
+
// vite/cloudflare-dev-proxy.ts
|
|
48
|
+
var import_react_router = require("react-router");
|
|
49
|
+
|
|
50
|
+
// vite/node-adapter.ts
|
|
51
|
+
var import_node_events = require("events");
|
|
52
|
+
var import_node_tls = require("tls");
|
|
53
|
+
var import_node_stream = require("stream");
|
|
54
|
+
var import_set_cookie_parser = require("set-cookie-parser");
|
|
55
|
+
var import_node = require("@react-router/node");
|
|
56
|
+
|
|
57
|
+
// invariant.ts
|
|
58
|
+
function invariant(value, message) {
|
|
59
|
+
if (value === false || value === null || typeof value === "undefined") {
|
|
60
|
+
console.error(
|
|
61
|
+
"The following error is a bug in React Router; please open an issue! https://github.com/remix-run/react-router/issues/new/choose"
|
|
62
|
+
);
|
|
63
|
+
throw new Error(message);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// vite/node-adapter.ts
|
|
68
|
+
function fromNodeHeaders(nodeReq) {
|
|
69
|
+
let nodeHeaders = nodeReq.headers;
|
|
70
|
+
if (nodeReq.httpVersionMajor >= 2) {
|
|
71
|
+
nodeHeaders = { ...nodeHeaders };
|
|
72
|
+
if (nodeHeaders[":authority"]) {
|
|
73
|
+
nodeHeaders.host = nodeHeaders[":authority"];
|
|
74
|
+
}
|
|
75
|
+
delete nodeHeaders[":authority"];
|
|
76
|
+
delete nodeHeaders[":method"];
|
|
77
|
+
delete nodeHeaders[":path"];
|
|
78
|
+
delete nodeHeaders[":scheme"];
|
|
79
|
+
}
|
|
80
|
+
let headers = new Headers();
|
|
81
|
+
for (let [key, values] of Object.entries(nodeHeaders)) {
|
|
82
|
+
if (values) {
|
|
83
|
+
if (Array.isArray(values)) {
|
|
84
|
+
for (let value of values) {
|
|
85
|
+
headers.append(key, value);
|
|
86
|
+
}
|
|
87
|
+
} else {
|
|
88
|
+
headers.set(key, values);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return headers;
|
|
93
|
+
}
|
|
94
|
+
function fromNodeRequest(nodeReq, nodeRes) {
|
|
95
|
+
let protocol = nodeReq.socket instanceof import_node_tls.TLSSocket && nodeReq.socket.encrypted ? "https" : "http";
|
|
96
|
+
let origin = nodeReq.headers.origin && "null" !== nodeReq.headers.origin ? nodeReq.headers.origin : `${protocol}://${nodeReq.headers.host}`;
|
|
97
|
+
invariant(
|
|
98
|
+
nodeReq.originalUrl,
|
|
99
|
+
"Expected `nodeReq.originalUrl` to be defined"
|
|
100
|
+
);
|
|
101
|
+
let url = new URL(nodeReq.originalUrl, origin);
|
|
102
|
+
let controller = new AbortController();
|
|
103
|
+
let init = {
|
|
104
|
+
method: nodeReq.method,
|
|
105
|
+
headers: fromNodeHeaders(nodeReq),
|
|
106
|
+
signal: controller.signal
|
|
107
|
+
};
|
|
108
|
+
nodeRes.on("finish", () => controller = null);
|
|
109
|
+
nodeRes.on("close", () => controller?.abort());
|
|
110
|
+
if (nodeReq.method !== "GET" && nodeReq.method !== "HEAD") {
|
|
111
|
+
init.body = (0, import_node.createReadableStreamFromReadable)(nodeReq);
|
|
112
|
+
init.duplex = "half";
|
|
113
|
+
}
|
|
114
|
+
return new Request(url.href, init);
|
|
115
|
+
}
|
|
116
|
+
async function toNodeRequest(res, nodeRes) {
|
|
117
|
+
nodeRes.statusCode = res.status;
|
|
118
|
+
if (!nodeRes.req || nodeRes.req.httpVersionMajor < 2) {
|
|
119
|
+
nodeRes.statusMessage = res.statusText;
|
|
120
|
+
}
|
|
121
|
+
let cookiesStrings = [];
|
|
122
|
+
for (let [name, value] of res.headers) {
|
|
123
|
+
if (name === "set-cookie") {
|
|
124
|
+
cookiesStrings.push(...(0, import_set_cookie_parser.splitCookiesString)(value));
|
|
125
|
+
} else nodeRes.setHeader(name, value);
|
|
126
|
+
}
|
|
127
|
+
if (cookiesStrings.length) {
|
|
128
|
+
nodeRes.setHeader("set-cookie", cookiesStrings);
|
|
129
|
+
}
|
|
130
|
+
if (res.body) {
|
|
131
|
+
let responseBody = res.body;
|
|
132
|
+
let readable = import_node_stream.Readable.from(responseBody);
|
|
133
|
+
readable.pipe(nodeRes);
|
|
134
|
+
await (0, import_node_events.once)(readable, "end");
|
|
135
|
+
} else {
|
|
136
|
+
nodeRes.end();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// vite/vite.ts
|
|
141
|
+
var import_pathe2 = __toESM(require("pathe"));
|
|
142
|
+
|
|
143
|
+
// config/is-react-router-repo.ts
|
|
144
|
+
var import_pathe = __toESM(require("pathe"));
|
|
145
|
+
function isReactRouterRepo() {
|
|
146
|
+
let serverRuntimePath = import_pathe.default.dirname(
|
|
147
|
+
require.resolve("@react-router/node/package.json")
|
|
148
|
+
);
|
|
149
|
+
let serverRuntimeParentDir = import_pathe.default.basename(
|
|
150
|
+
import_pathe.default.resolve(serverRuntimePath, "..")
|
|
151
|
+
);
|
|
152
|
+
return serverRuntimeParentDir === "packages";
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// vite/vite.ts
|
|
156
|
+
var vite;
|
|
157
|
+
var viteImportSpecifier = isReactRouterRepo() ? (
|
|
158
|
+
// Support testing against different versions of Vite by ensuring that Vite
|
|
159
|
+
// is resolved from the current working directory when running within this
|
|
160
|
+
// repo. If we don't do this, Vite will always be imported relative to this
|
|
161
|
+
// file, which means that it will always resolve to Vite 6.
|
|
162
|
+
`file:///${import_pathe2.default.normalize(
|
|
163
|
+
require.resolve("vite/package.json", { paths: [process.cwd()] })
|
|
164
|
+
).replace("package.json", "dist/node/index.js")}`
|
|
165
|
+
) : "vite";
|
|
166
|
+
async function preloadVite() {
|
|
167
|
+
vite = await import(viteImportSpecifier);
|
|
168
|
+
}
|
|
169
|
+
function getVite() {
|
|
170
|
+
invariant(vite, "getVite() called before preloadVite()");
|
|
171
|
+
return vite;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// config/config.ts
|
|
175
|
+
var import_node_fs = __toESM(require("fs"));
|
|
176
|
+
var import_node_child_process = require("child_process");
|
|
177
|
+
var import_package_json = __toESM(require("@npmcli/package-json"));
|
|
178
|
+
|
|
179
|
+
// vite/ssr-externals.ts
|
|
180
|
+
var ssrExternals = isReactRouterRepo() ? [
|
|
181
|
+
// This is only needed within this repo because these packages
|
|
182
|
+
// are linked to a directory outside of node_modules so Vite
|
|
183
|
+
// treats them as internal code by default.
|
|
184
|
+
"react-router",
|
|
185
|
+
"react-router-dom",
|
|
186
|
+
"@react-router/architect",
|
|
187
|
+
"@react-router/cloudflare",
|
|
188
|
+
"@react-router/dev",
|
|
189
|
+
"@react-router/express",
|
|
190
|
+
"@react-router/node",
|
|
191
|
+
"@react-router/serve"
|
|
192
|
+
] : void 0;
|
|
193
|
+
|
|
194
|
+
// vite/vite-node.ts
|
|
195
|
+
async function createContext({
|
|
196
|
+
root,
|
|
197
|
+
mode,
|
|
198
|
+
customLogger
|
|
199
|
+
}) {
|
|
200
|
+
await preloadVite();
|
|
201
|
+
const vite2 = getVite();
|
|
202
|
+
const [{ ViteNodeServer }, { ViteNodeRunner }, { installSourcemapsSupport }] = await Promise.all([
|
|
203
|
+
import("vite-node/server"),
|
|
204
|
+
import("vite-node/client"),
|
|
205
|
+
import("vite-node/source-map")
|
|
206
|
+
]);
|
|
207
|
+
const devServer = await vite2.createServer({
|
|
208
|
+
root,
|
|
209
|
+
mode,
|
|
210
|
+
customLogger,
|
|
211
|
+
server: {
|
|
212
|
+
preTransformRequests: false,
|
|
213
|
+
hmr: false,
|
|
214
|
+
watch: null
|
|
215
|
+
},
|
|
216
|
+
ssr: {
|
|
217
|
+
external: ssrExternals
|
|
218
|
+
},
|
|
219
|
+
optimizeDeps: {
|
|
220
|
+
noDiscovery: true
|
|
221
|
+
},
|
|
222
|
+
css: {
|
|
223
|
+
// This empty PostCSS config object prevents the PostCSS config file from
|
|
224
|
+
// being loaded. We don't need it in a React Router config context, and
|
|
225
|
+
// there's also an issue in Vite 5 when using a .ts PostCSS config file in
|
|
226
|
+
// an ESM project: https://github.com/vitejs/vite/issues/15869. Consumers
|
|
227
|
+
// can work around this in their own Vite config file, but they can't
|
|
228
|
+
// configure this internal usage of vite-node.
|
|
229
|
+
postcss: {}
|
|
230
|
+
},
|
|
231
|
+
configFile: false,
|
|
232
|
+
envFile: false,
|
|
233
|
+
plugins: []
|
|
234
|
+
});
|
|
235
|
+
await devServer.pluginContainer.buildStart({});
|
|
236
|
+
const server = new ViteNodeServer(devServer);
|
|
237
|
+
installSourcemapsSupport({
|
|
238
|
+
getSourceMap: (source) => server.getSourceMap(source)
|
|
239
|
+
});
|
|
240
|
+
const runner = new ViteNodeRunner({
|
|
241
|
+
root: devServer.config.root,
|
|
242
|
+
base: devServer.config.base,
|
|
243
|
+
fetchModule(id) {
|
|
244
|
+
return server.fetchModule(id);
|
|
245
|
+
},
|
|
246
|
+
resolveId(id, importer) {
|
|
247
|
+
return server.resolveId(id, importer);
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
return { devServer, server, runner };
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// config/config.ts
|
|
254
|
+
var import_pathe3 = __toESM(require("pathe"));
|
|
255
|
+
var import_chokidar = __toESM(require("chokidar"));
|
|
256
|
+
var import_picocolors = __toESM(require("picocolors"));
|
|
257
|
+
var import_pick2 = __toESM(require("lodash/pick"));
|
|
258
|
+
var import_omit = __toESM(require("lodash/omit"));
|
|
259
|
+
var import_cloneDeep = __toESM(require("lodash/cloneDeep"));
|
|
260
|
+
var import_isEqual = __toESM(require("lodash/isEqual"));
|
|
261
|
+
|
|
262
|
+
// config/routes.ts
|
|
263
|
+
var Path = __toESM(require("pathe"));
|
|
264
|
+
var v = __toESM(require("valibot"));
|
|
265
|
+
var import_pick = __toESM(require("lodash/pick"));
|
|
266
|
+
function setAppDirectory(directory) {
|
|
267
|
+
globalThis.__reactRouterAppDirectory = directory;
|
|
268
|
+
}
|
|
269
|
+
var routeConfigEntrySchema = v.pipe(
|
|
270
|
+
v.custom((value) => {
|
|
271
|
+
return !(typeof value === "object" && value !== null && "then" in value && "catch" in value);
|
|
272
|
+
}, "Invalid type: Expected object but received a promise. Did you forget to await?"),
|
|
273
|
+
v.object({
|
|
274
|
+
id: v.optional(
|
|
275
|
+
v.pipe(
|
|
276
|
+
v.string(),
|
|
277
|
+
v.notValue("root", "A route cannot use the reserved id 'root'.")
|
|
278
|
+
)
|
|
279
|
+
),
|
|
280
|
+
path: v.optional(v.string()),
|
|
281
|
+
index: v.optional(v.boolean()),
|
|
282
|
+
caseSensitive: v.optional(v.boolean()),
|
|
283
|
+
file: v.string(),
|
|
284
|
+
children: v.optional(v.array(v.lazy(() => routeConfigEntrySchema)))
|
|
285
|
+
})
|
|
286
|
+
);
|
|
287
|
+
var resolvedRouteConfigSchema = v.array(routeConfigEntrySchema);
|
|
288
|
+
function validateRouteConfig({
|
|
289
|
+
routeConfigFile,
|
|
290
|
+
routeConfig
|
|
291
|
+
}) {
|
|
292
|
+
if (!routeConfig) {
|
|
293
|
+
return {
|
|
294
|
+
valid: false,
|
|
295
|
+
message: `Route config must be the default export in "${routeConfigFile}".`
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
if (!Array.isArray(routeConfig)) {
|
|
299
|
+
return {
|
|
300
|
+
valid: false,
|
|
301
|
+
message: `Route config in "${routeConfigFile}" must be an array.`
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
let { issues } = v.safeParse(resolvedRouteConfigSchema, routeConfig);
|
|
305
|
+
if (issues?.length) {
|
|
306
|
+
let { root, nested } = v.flatten(issues);
|
|
307
|
+
return {
|
|
308
|
+
valid: false,
|
|
309
|
+
message: [
|
|
310
|
+
`Route config in "${routeConfigFile}" is invalid.`,
|
|
311
|
+
root ? `${root}` : [],
|
|
312
|
+
nested ? Object.entries(nested).map(
|
|
313
|
+
([path3, message]) => `Path: routes.${path3}
|
|
314
|
+
${message}`
|
|
315
|
+
) : []
|
|
316
|
+
].flat().join("\n\n")
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
return {
|
|
320
|
+
valid: true,
|
|
321
|
+
routeConfig
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
function configRoutesToRouteManifest(appDirectory, routes) {
|
|
325
|
+
let routeManifest = {};
|
|
326
|
+
function walk(route, parentId) {
|
|
327
|
+
let id = route.id || createRouteId(route.file);
|
|
328
|
+
let manifestItem = {
|
|
329
|
+
id,
|
|
330
|
+
parentId,
|
|
331
|
+
file: Path.isAbsolute(route.file) ? Path.relative(appDirectory, route.file) : route.file,
|
|
332
|
+
path: route.path,
|
|
333
|
+
index: route.index,
|
|
334
|
+
caseSensitive: route.caseSensitive
|
|
335
|
+
};
|
|
336
|
+
if (routeManifest.hasOwnProperty(id)) {
|
|
337
|
+
throw new Error(
|
|
338
|
+
`Unable to define routes with duplicate route id: "${id}"`
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
routeManifest[id] = manifestItem;
|
|
342
|
+
if (route.children) {
|
|
343
|
+
for (let child of route.children) {
|
|
344
|
+
walk(child, id);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
for (let route of routes) {
|
|
349
|
+
walk(route);
|
|
350
|
+
}
|
|
351
|
+
return routeManifest;
|
|
352
|
+
}
|
|
353
|
+
function createRouteId(file) {
|
|
354
|
+
return Path.normalize(stripFileExtension(file));
|
|
355
|
+
}
|
|
356
|
+
function stripFileExtension(file) {
|
|
357
|
+
return file.replace(/\.[a-z0-9]+$/i, "");
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// config/config.ts
|
|
361
|
+
var excludedConfigPresetKeys = ["presets"];
|
|
362
|
+
var mergeReactRouterConfig = (...configs) => {
|
|
363
|
+
let reducer = (configA, configB) => {
|
|
364
|
+
let mergeRequired = (key) => configA[key] !== void 0 && configB[key] !== void 0;
|
|
365
|
+
return {
|
|
366
|
+
...configA,
|
|
367
|
+
...configB,
|
|
368
|
+
...mergeRequired("buildEnd") ? {
|
|
369
|
+
buildEnd: async (...args) => {
|
|
370
|
+
await Promise.all([
|
|
371
|
+
configA.buildEnd?.(...args),
|
|
372
|
+
configB.buildEnd?.(...args)
|
|
373
|
+
]);
|
|
374
|
+
}
|
|
375
|
+
} : {},
|
|
376
|
+
...mergeRequired("future") ? {
|
|
377
|
+
future: {
|
|
378
|
+
...configA.future,
|
|
379
|
+
...configB.future
|
|
380
|
+
}
|
|
381
|
+
} : {},
|
|
382
|
+
...mergeRequired("presets") ? {
|
|
383
|
+
presets: [...configA.presets ?? [], ...configB.presets ?? []]
|
|
384
|
+
} : {}
|
|
385
|
+
};
|
|
386
|
+
};
|
|
387
|
+
return configs.reduce(reducer, {});
|
|
388
|
+
};
|
|
389
|
+
var deepFreeze = (o) => {
|
|
390
|
+
Object.freeze(o);
|
|
391
|
+
let oIsFunction = typeof o === "function";
|
|
392
|
+
let hasOwnProp = Object.prototype.hasOwnProperty;
|
|
393
|
+
Object.getOwnPropertyNames(o).forEach(function(prop) {
|
|
394
|
+
if (hasOwnProp.call(o, prop) && (oIsFunction ? prop !== "caller" && prop !== "callee" && prop !== "arguments" : true) && o[prop] !== null && (typeof o[prop] === "object" || typeof o[prop] === "function") && !Object.isFrozen(o[prop])) {
|
|
395
|
+
deepFreeze(o[prop]);
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
return o;
|
|
399
|
+
};
|
|
400
|
+
function ok(value) {
|
|
401
|
+
return { ok: true, value };
|
|
402
|
+
}
|
|
403
|
+
function err(error) {
|
|
404
|
+
return { ok: false, error };
|
|
405
|
+
}
|
|
406
|
+
async function resolveConfig({
|
|
407
|
+
root,
|
|
408
|
+
viteNodeContext,
|
|
409
|
+
reactRouterConfigFile,
|
|
410
|
+
skipRoutes,
|
|
411
|
+
validateConfig
|
|
412
|
+
}) {
|
|
413
|
+
let reactRouterUserConfig = {};
|
|
414
|
+
if (reactRouterConfigFile) {
|
|
415
|
+
try {
|
|
416
|
+
if (!import_node_fs.default.existsSync(reactRouterConfigFile)) {
|
|
417
|
+
return err(`${reactRouterConfigFile} no longer exists`);
|
|
418
|
+
}
|
|
419
|
+
let configModule = await viteNodeContext.runner.executeFile(
|
|
420
|
+
reactRouterConfigFile
|
|
421
|
+
);
|
|
422
|
+
if (configModule.default === void 0) {
|
|
423
|
+
return err(`${reactRouterConfigFile} must provide a default export`);
|
|
424
|
+
}
|
|
425
|
+
if (typeof configModule.default !== "object") {
|
|
426
|
+
return err(`${reactRouterConfigFile} must export a config`);
|
|
427
|
+
}
|
|
428
|
+
reactRouterUserConfig = configModule.default;
|
|
429
|
+
if (validateConfig) {
|
|
430
|
+
const error = validateConfig(reactRouterUserConfig);
|
|
431
|
+
if (error) {
|
|
432
|
+
return err(error);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
} catch (error) {
|
|
436
|
+
return err(`Error loading ${reactRouterConfigFile}: ${error}`);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
reactRouterUserConfig = deepFreeze((0, import_cloneDeep.default)(reactRouterUserConfig));
|
|
440
|
+
let presets = (await Promise.all(
|
|
441
|
+
(reactRouterUserConfig.presets ?? []).map(async (preset) => {
|
|
442
|
+
if (!preset.name) {
|
|
443
|
+
throw new Error(
|
|
444
|
+
"React Router presets must have a `name` property defined."
|
|
445
|
+
);
|
|
446
|
+
}
|
|
447
|
+
if (!preset.reactRouterConfig) {
|
|
448
|
+
return null;
|
|
449
|
+
}
|
|
450
|
+
let configPreset = (0, import_omit.default)(
|
|
451
|
+
await preset.reactRouterConfig({ reactRouterUserConfig }),
|
|
452
|
+
excludedConfigPresetKeys
|
|
453
|
+
);
|
|
454
|
+
return configPreset;
|
|
455
|
+
})
|
|
456
|
+
)).filter(function isNotNull(value) {
|
|
457
|
+
return value !== null;
|
|
458
|
+
});
|
|
459
|
+
let defaults = {
|
|
460
|
+
basename: "/",
|
|
461
|
+
buildDirectory: "build",
|
|
462
|
+
serverBuildFile: "index.js",
|
|
463
|
+
serverModuleFormat: "esm",
|
|
464
|
+
ssr: true
|
|
465
|
+
};
|
|
466
|
+
let userAndPresetConfigs = mergeReactRouterConfig(
|
|
467
|
+
...presets,
|
|
468
|
+
reactRouterUserConfig
|
|
469
|
+
);
|
|
470
|
+
let {
|
|
471
|
+
appDirectory: userAppDirectory,
|
|
472
|
+
basename,
|
|
473
|
+
buildDirectory: userBuildDirectory,
|
|
474
|
+
buildEnd,
|
|
475
|
+
prerender,
|
|
476
|
+
routeDiscovery: userRouteDiscovery,
|
|
477
|
+
serverBuildFile,
|
|
478
|
+
serverBundles,
|
|
479
|
+
serverModuleFormat,
|
|
480
|
+
ssr
|
|
481
|
+
} = {
|
|
482
|
+
...defaults,
|
|
483
|
+
// Default values should be completely overridden by user/preset config, not merged
|
|
484
|
+
...userAndPresetConfigs
|
|
485
|
+
};
|
|
486
|
+
if (!ssr && serverBundles) {
|
|
487
|
+
serverBundles = void 0;
|
|
488
|
+
}
|
|
489
|
+
let isValidPrerenderConfig = prerender == null || typeof prerender === "boolean" || Array.isArray(prerender) || typeof prerender === "function";
|
|
490
|
+
if (!isValidPrerenderConfig) {
|
|
491
|
+
return err(
|
|
492
|
+
"The `prerender` config must be a boolean, an array of string paths, or a function returning a boolean or array of string paths"
|
|
493
|
+
);
|
|
494
|
+
}
|
|
495
|
+
let routeDiscovery;
|
|
496
|
+
if (userRouteDiscovery == null) {
|
|
497
|
+
if (ssr) {
|
|
498
|
+
routeDiscovery = {
|
|
499
|
+
mode: "lazy",
|
|
500
|
+
manifestPath: "/__manifest"
|
|
501
|
+
};
|
|
502
|
+
} else {
|
|
503
|
+
routeDiscovery = { mode: "initial" };
|
|
504
|
+
}
|
|
505
|
+
} else if (userRouteDiscovery.mode === "initial") {
|
|
506
|
+
routeDiscovery = userRouteDiscovery;
|
|
507
|
+
} else if (userRouteDiscovery.mode === "lazy") {
|
|
508
|
+
if (!ssr) {
|
|
509
|
+
return err(
|
|
510
|
+
'The `routeDiscovery.mode` config cannot be set to "lazy" when setting `ssr:false`'
|
|
511
|
+
);
|
|
512
|
+
}
|
|
513
|
+
let { manifestPath } = userRouteDiscovery;
|
|
514
|
+
if (manifestPath != null && !manifestPath.startsWith("/")) {
|
|
515
|
+
return err(
|
|
516
|
+
'The `routeDiscovery.manifestPath` config must be a root-relative pathname beginning with a slash (i.e., "/__manifest")'
|
|
517
|
+
);
|
|
518
|
+
}
|
|
519
|
+
routeDiscovery = userRouteDiscovery;
|
|
520
|
+
}
|
|
521
|
+
let appDirectory = import_pathe3.default.resolve(root, userAppDirectory || "app");
|
|
522
|
+
let buildDirectory = import_pathe3.default.resolve(root, userBuildDirectory);
|
|
523
|
+
let rootRouteFile = findEntry(appDirectory, "root");
|
|
524
|
+
if (!rootRouteFile) {
|
|
525
|
+
let rootRouteDisplayPath = import_pathe3.default.relative(
|
|
526
|
+
root,
|
|
527
|
+
import_pathe3.default.join(appDirectory, "root.tsx")
|
|
528
|
+
);
|
|
529
|
+
return err(
|
|
530
|
+
`Could not find a root route module in the app directory as "${rootRouteDisplayPath}"`
|
|
531
|
+
);
|
|
532
|
+
}
|
|
533
|
+
let routes;
|
|
534
|
+
let routeConfig = [];
|
|
535
|
+
if (skipRoutes) {
|
|
536
|
+
routes = {};
|
|
537
|
+
} else {
|
|
538
|
+
let routeConfigFile = findEntry(appDirectory, "routes");
|
|
539
|
+
try {
|
|
540
|
+
if (!routeConfigFile) {
|
|
541
|
+
let routeConfigDisplayPath = import_pathe3.default.relative(
|
|
542
|
+
root,
|
|
543
|
+
import_pathe3.default.join(appDirectory, "routes.ts")
|
|
544
|
+
);
|
|
545
|
+
return err(
|
|
546
|
+
`Route config file not found at "${routeConfigDisplayPath}".`
|
|
547
|
+
);
|
|
548
|
+
}
|
|
549
|
+
setAppDirectory(appDirectory);
|
|
550
|
+
let routeConfigExport = (await viteNodeContext.runner.executeFile(
|
|
551
|
+
import_pathe3.default.join(appDirectory, routeConfigFile)
|
|
552
|
+
)).default;
|
|
553
|
+
let result = validateRouteConfig({
|
|
554
|
+
routeConfigFile,
|
|
555
|
+
routeConfig: await routeConfigExport
|
|
556
|
+
});
|
|
557
|
+
if (!result.valid) {
|
|
558
|
+
return err(result.message);
|
|
559
|
+
}
|
|
560
|
+
routeConfig = [
|
|
561
|
+
{
|
|
562
|
+
id: "root",
|
|
563
|
+
path: "",
|
|
564
|
+
file: rootRouteFile,
|
|
565
|
+
children: result.routeConfig
|
|
566
|
+
}
|
|
567
|
+
];
|
|
568
|
+
routes = configRoutesToRouteManifest(appDirectory, routeConfig);
|
|
569
|
+
} catch (error) {
|
|
570
|
+
return err(
|
|
571
|
+
[
|
|
572
|
+
import_picocolors.default.red(`Route config in "${routeConfigFile}" is invalid.`),
|
|
573
|
+
"",
|
|
574
|
+
error.loc?.file && error.loc?.column && error.frame ? [
|
|
575
|
+
import_pathe3.default.relative(appDirectory, error.loc.file) + ":" + error.loc.line + ":" + error.loc.column,
|
|
576
|
+
error.frame.trim?.()
|
|
577
|
+
] : error.stack
|
|
578
|
+
].flat().join("\n")
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
let future = {
|
|
583
|
+
v8_middleware: reactRouterUserConfig.future?.v8_middleware ?? false,
|
|
584
|
+
unstable_optimizeDeps: reactRouterUserConfig.future?.unstable_optimizeDeps ?? false,
|
|
585
|
+
unstable_splitRouteModules: reactRouterUserConfig.future?.unstable_splitRouteModules ?? false,
|
|
586
|
+
unstable_subResourceIntegrity: reactRouterUserConfig.future?.unstable_subResourceIntegrity ?? false,
|
|
587
|
+
unstable_viteEnvironmentApi: reactRouterUserConfig.future?.unstable_viteEnvironmentApi ?? false
|
|
588
|
+
};
|
|
589
|
+
let reactRouterConfig = deepFreeze({
|
|
590
|
+
appDirectory,
|
|
591
|
+
basename,
|
|
592
|
+
buildDirectory,
|
|
593
|
+
buildEnd,
|
|
594
|
+
future,
|
|
595
|
+
prerender,
|
|
596
|
+
routes,
|
|
597
|
+
routeDiscovery,
|
|
598
|
+
serverBuildFile,
|
|
599
|
+
serverBundles,
|
|
600
|
+
serverModuleFormat,
|
|
601
|
+
ssr,
|
|
602
|
+
unstable_routeConfig: routeConfig
|
|
603
|
+
});
|
|
604
|
+
for (let preset of reactRouterUserConfig.presets ?? []) {
|
|
605
|
+
await preset.reactRouterConfigResolved?.({ reactRouterConfig });
|
|
606
|
+
}
|
|
607
|
+
return ok(reactRouterConfig);
|
|
608
|
+
}
|
|
609
|
+
async function createConfigLoader({
|
|
610
|
+
rootDirectory: root,
|
|
611
|
+
watch,
|
|
612
|
+
mode,
|
|
613
|
+
skipRoutes,
|
|
614
|
+
validateConfig
|
|
615
|
+
}) {
|
|
616
|
+
root = import_pathe3.default.normalize(root ?? process.env.REACT_ROUTER_ROOT ?? process.cwd());
|
|
617
|
+
let vite2 = await import("vite");
|
|
618
|
+
let viteNodeContext = await createContext({
|
|
619
|
+
root,
|
|
620
|
+
mode,
|
|
621
|
+
// Filter out any info level logs from vite-node
|
|
622
|
+
customLogger: vite2.createLogger("warn", {
|
|
623
|
+
prefix: "[react-router]"
|
|
624
|
+
})
|
|
625
|
+
});
|
|
626
|
+
let reactRouterConfigFile;
|
|
627
|
+
let updateReactRouterConfigFile = () => {
|
|
628
|
+
reactRouterConfigFile = findEntry(root, "react-router.config", {
|
|
629
|
+
absolute: true
|
|
630
|
+
});
|
|
631
|
+
};
|
|
632
|
+
updateReactRouterConfigFile();
|
|
633
|
+
let getConfig = () => resolveConfig({
|
|
634
|
+
root,
|
|
635
|
+
viteNodeContext,
|
|
636
|
+
reactRouterConfigFile,
|
|
637
|
+
skipRoutes,
|
|
638
|
+
validateConfig
|
|
639
|
+
});
|
|
640
|
+
let appDirectory;
|
|
641
|
+
let initialConfigResult = await getConfig();
|
|
642
|
+
if (!initialConfigResult.ok) {
|
|
643
|
+
throw new Error(initialConfigResult.error);
|
|
644
|
+
}
|
|
645
|
+
appDirectory = import_pathe3.default.normalize(initialConfigResult.value.appDirectory);
|
|
646
|
+
let currentConfig = initialConfigResult.value;
|
|
647
|
+
let fsWatcher;
|
|
648
|
+
let changeHandlers = [];
|
|
649
|
+
return {
|
|
650
|
+
getConfig,
|
|
651
|
+
onChange: (handler) => {
|
|
652
|
+
if (!watch) {
|
|
653
|
+
throw new Error(
|
|
654
|
+
"onChange is not supported when watch mode is disabled"
|
|
655
|
+
);
|
|
656
|
+
}
|
|
657
|
+
changeHandlers.push(handler);
|
|
658
|
+
if (!fsWatcher) {
|
|
659
|
+
fsWatcher = import_chokidar.default.watch([root, appDirectory], {
|
|
660
|
+
ignoreInitial: true,
|
|
661
|
+
ignored: (path3) => {
|
|
662
|
+
let dirname = import_pathe3.default.dirname(path3);
|
|
663
|
+
return !dirname.startsWith(appDirectory) && // Ensure we're only watching files outside of the app directory
|
|
664
|
+
// that are at the root level, not nested in subdirectories
|
|
665
|
+
path3 !== root && // Watch the root directory itself
|
|
666
|
+
dirname !== root;
|
|
667
|
+
}
|
|
668
|
+
});
|
|
669
|
+
fsWatcher.on("all", async (...args) => {
|
|
670
|
+
let [event, rawFilepath] = args;
|
|
671
|
+
let filepath = import_pathe3.default.normalize(rawFilepath);
|
|
672
|
+
let fileAddedOrRemoved = event === "add" || event === "unlink";
|
|
673
|
+
let appFileAddedOrRemoved = fileAddedOrRemoved && filepath.startsWith(import_pathe3.default.normalize(appDirectory));
|
|
674
|
+
let rootRelativeFilepath = import_pathe3.default.relative(root, filepath);
|
|
675
|
+
let configFileAddedOrRemoved = fileAddedOrRemoved && isEntryFile("react-router.config", rootRelativeFilepath);
|
|
676
|
+
if (configFileAddedOrRemoved) {
|
|
677
|
+
updateReactRouterConfigFile();
|
|
678
|
+
}
|
|
679
|
+
let moduleGraphChanged = configFileAddedOrRemoved || Boolean(
|
|
680
|
+
viteNodeContext.devServer?.moduleGraph.getModuleById(filepath)
|
|
681
|
+
);
|
|
682
|
+
if (!moduleGraphChanged && !appFileAddedOrRemoved) {
|
|
683
|
+
return;
|
|
684
|
+
}
|
|
685
|
+
viteNodeContext.devServer?.moduleGraph.invalidateAll();
|
|
686
|
+
viteNodeContext.runner?.moduleCache.clear();
|
|
687
|
+
let result = await getConfig();
|
|
688
|
+
let prevAppDirectory = appDirectory;
|
|
689
|
+
appDirectory = import_pathe3.default.normalize(
|
|
690
|
+
(result.value ?? currentConfig).appDirectory
|
|
691
|
+
);
|
|
692
|
+
if (appDirectory !== prevAppDirectory) {
|
|
693
|
+
fsWatcher.unwatch(prevAppDirectory);
|
|
694
|
+
fsWatcher.add(appDirectory);
|
|
695
|
+
}
|
|
696
|
+
let configCodeChanged = configFileAddedOrRemoved || reactRouterConfigFile !== void 0 && isEntryFileDependency(
|
|
697
|
+
viteNodeContext.devServer.moduleGraph,
|
|
698
|
+
reactRouterConfigFile,
|
|
699
|
+
filepath
|
|
700
|
+
);
|
|
701
|
+
let routeConfigFile = !skipRoutes ? findEntry(appDirectory, "routes", {
|
|
702
|
+
absolute: true
|
|
703
|
+
}) : void 0;
|
|
704
|
+
let routeConfigCodeChanged = routeConfigFile !== void 0 && isEntryFileDependency(
|
|
705
|
+
viteNodeContext.devServer.moduleGraph,
|
|
706
|
+
routeConfigFile,
|
|
707
|
+
filepath
|
|
708
|
+
);
|
|
709
|
+
let configChanged = result.ok && !(0, import_isEqual.default)(omitRoutes(currentConfig), omitRoutes(result.value));
|
|
710
|
+
let routeConfigChanged = result.ok && !(0, import_isEqual.default)(currentConfig?.routes, result.value.routes);
|
|
711
|
+
for (let handler2 of changeHandlers) {
|
|
712
|
+
handler2({
|
|
713
|
+
result,
|
|
714
|
+
configCodeChanged,
|
|
715
|
+
routeConfigCodeChanged,
|
|
716
|
+
configChanged,
|
|
717
|
+
routeConfigChanged,
|
|
718
|
+
path: filepath,
|
|
719
|
+
event
|
|
720
|
+
});
|
|
721
|
+
}
|
|
722
|
+
if (result.ok) {
|
|
723
|
+
currentConfig = result.value;
|
|
724
|
+
}
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
return () => {
|
|
728
|
+
changeHandlers = changeHandlers.filter(
|
|
729
|
+
(changeHandler) => changeHandler !== handler
|
|
730
|
+
);
|
|
731
|
+
};
|
|
732
|
+
},
|
|
733
|
+
close: async () => {
|
|
734
|
+
changeHandlers = [];
|
|
735
|
+
await viteNodeContext.devServer.close();
|
|
736
|
+
await fsWatcher?.close();
|
|
737
|
+
}
|
|
738
|
+
};
|
|
739
|
+
}
|
|
740
|
+
async function loadConfig({
|
|
741
|
+
rootDirectory,
|
|
742
|
+
mode,
|
|
743
|
+
skipRoutes
|
|
744
|
+
}) {
|
|
745
|
+
let configLoader = await createConfigLoader({
|
|
746
|
+
rootDirectory,
|
|
747
|
+
mode,
|
|
748
|
+
skipRoutes,
|
|
749
|
+
watch: false
|
|
750
|
+
});
|
|
751
|
+
let config = await configLoader.getConfig();
|
|
752
|
+
await configLoader.close();
|
|
753
|
+
return config;
|
|
754
|
+
}
|
|
755
|
+
function omitRoutes(config) {
|
|
756
|
+
return {
|
|
757
|
+
...config,
|
|
758
|
+
routes: {}
|
|
759
|
+
};
|
|
760
|
+
}
|
|
761
|
+
var entryExts = [".js", ".jsx", ".ts", ".tsx", ".mjs", ".mts"];
|
|
762
|
+
function isEntryFile(entryBasename, filename) {
|
|
763
|
+
return entryExts.some((ext) => filename === `${entryBasename}${ext}`);
|
|
764
|
+
}
|
|
765
|
+
function findEntry(dir, basename, options) {
|
|
766
|
+
let currentDir = import_pathe3.default.resolve(dir);
|
|
767
|
+
let { root } = import_pathe3.default.parse(currentDir);
|
|
768
|
+
while (true) {
|
|
769
|
+
for (let ext of options?.extensions ?? entryExts) {
|
|
770
|
+
let file = import_pathe3.default.resolve(currentDir, basename + ext);
|
|
771
|
+
if (import_node_fs.default.existsSync(file)) {
|
|
772
|
+
return options?.absolute ?? false ? file : import_pathe3.default.relative(dir, file);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
if (!options?.walkParents) {
|
|
776
|
+
return void 0;
|
|
777
|
+
}
|
|
778
|
+
let parentDir = import_pathe3.default.dirname(currentDir);
|
|
779
|
+
if (currentDir === root || parentDir === currentDir) {
|
|
780
|
+
return void 0;
|
|
781
|
+
}
|
|
782
|
+
currentDir = parentDir;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
function isEntryFileDependency(moduleGraph, entryFilepath, filepath, visited = /* @__PURE__ */ new Set()) {
|
|
786
|
+
entryFilepath = import_pathe3.default.normalize(entryFilepath);
|
|
787
|
+
filepath = import_pathe3.default.normalize(filepath);
|
|
788
|
+
if (visited.has(filepath)) {
|
|
789
|
+
return false;
|
|
790
|
+
}
|
|
791
|
+
visited.add(filepath);
|
|
792
|
+
if (filepath === entryFilepath) {
|
|
793
|
+
return true;
|
|
794
|
+
}
|
|
795
|
+
let mod = moduleGraph.getModuleById(filepath);
|
|
796
|
+
if (!mod) {
|
|
797
|
+
return false;
|
|
798
|
+
}
|
|
799
|
+
for (let importer of mod.importers) {
|
|
800
|
+
if (!importer.id) {
|
|
801
|
+
continue;
|
|
802
|
+
}
|
|
803
|
+
if (importer.id === entryFilepath || isEntryFileDependency(moduleGraph, entryFilepath, importer.id, visited)) {
|
|
804
|
+
return true;
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
return false;
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
// vite/cloudflare-dev-proxy.ts
|
|
811
|
+
var serverBuildId = "virtual:react-router/server-build";
|
|
812
|
+
function importWrangler() {
|
|
813
|
+
try {
|
|
814
|
+
return import("wrangler");
|
|
815
|
+
} catch (_) {
|
|
816
|
+
throw Error("Could not import `wrangler`. Do you have it installed?");
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
var PLUGIN_NAME = "react-router-cloudflare-vite-dev-proxy";
|
|
820
|
+
var cloudflareDevProxyVitePlugin = (options = {}) => {
|
|
821
|
+
let { getLoadContext, ...restOptions } = options;
|
|
822
|
+
const workerdConditions = ["workerd", "worker"];
|
|
823
|
+
let future;
|
|
824
|
+
return {
|
|
825
|
+
name: PLUGIN_NAME,
|
|
826
|
+
config: async (config, configEnv) => {
|
|
827
|
+
await preloadVite();
|
|
828
|
+
const externalConditions = ["node"];
|
|
829
|
+
let configResult = await loadConfig({
|
|
830
|
+
rootDirectory: config.root ?? process.cwd(),
|
|
831
|
+
mode: configEnv.mode
|
|
832
|
+
});
|
|
833
|
+
if (!configResult.ok) {
|
|
834
|
+
throw new Error(configResult.error);
|
|
835
|
+
}
|
|
836
|
+
future = configResult.value.future;
|
|
837
|
+
return {
|
|
838
|
+
ssr: {
|
|
839
|
+
resolve: {
|
|
840
|
+
externalConditions: [...workerdConditions, ...externalConditions]
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
},
|
|
845
|
+
configEnvironment: async (name, options2) => {
|
|
846
|
+
if (!future.unstable_viteEnvironmentApi) {
|
|
847
|
+
return;
|
|
848
|
+
}
|
|
849
|
+
if (name !== "client") {
|
|
850
|
+
options2.resolve = options2.resolve ?? {};
|
|
851
|
+
options2.resolve.externalConditions = [
|
|
852
|
+
...workerdConditions,
|
|
853
|
+
...options2.resolve?.externalConditions ?? []
|
|
854
|
+
];
|
|
855
|
+
}
|
|
856
|
+
},
|
|
857
|
+
configResolved: (viteConfig) => {
|
|
858
|
+
let pluginIndex = (name) => viteConfig.plugins.findIndex((plugin) => plugin.name === name);
|
|
859
|
+
let reactRouterPluginIndex = pluginIndex("react-router");
|
|
860
|
+
if (reactRouterPluginIndex >= 0 && reactRouterPluginIndex < pluginIndex(PLUGIN_NAME)) {
|
|
861
|
+
throw new Error(
|
|
862
|
+
`The "${PLUGIN_NAME}" plugin should be placed before the React Router plugin in your Vite config file`
|
|
863
|
+
);
|
|
864
|
+
}
|
|
865
|
+
},
|
|
866
|
+
configureServer: async (viteDevServer) => {
|
|
867
|
+
let context;
|
|
868
|
+
let getContext = async () => {
|
|
869
|
+
let { getPlatformProxy } = await importWrangler();
|
|
870
|
+
let { dispose, ...cloudflare } = await getPlatformProxy(
|
|
871
|
+
restOptions
|
|
872
|
+
);
|
|
873
|
+
return { cloudflare };
|
|
874
|
+
};
|
|
875
|
+
return () => {
|
|
876
|
+
if (!viteDevServer.config.server.middlewareMode) {
|
|
877
|
+
viteDevServer.middlewares.use(async (nodeReq, nodeRes, next) => {
|
|
878
|
+
try {
|
|
879
|
+
let build = await viteDevServer.ssrLoadModule(
|
|
880
|
+
serverBuildId
|
|
881
|
+
);
|
|
882
|
+
let handler = (0, import_react_router.createRequestHandler)(build, "development");
|
|
883
|
+
let req = fromNodeRequest(nodeReq, nodeRes);
|
|
884
|
+
context ??= await getContext();
|
|
885
|
+
let loadContext = getLoadContext ? await getLoadContext({ request: req, context }) : context;
|
|
886
|
+
let res = await handler(req, loadContext);
|
|
887
|
+
await toNodeRequest(res, nodeRes);
|
|
888
|
+
} catch (error) {
|
|
889
|
+
next(error);
|
|
890
|
+
}
|
|
891
|
+
});
|
|
892
|
+
}
|
|
893
|
+
};
|
|
894
|
+
}
|
|
895
|
+
};
|
|
896
|
+
};
|
|
897
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
898
|
+
0 && (module.exports = {
|
|
899
|
+
cloudflareDevProxy
|
|
900
|
+
});
|