@react-router/dev 0.0.0-experimental-56b72276e → 0.0.0-experimental-58b44aa83
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 +60 -0
- package/dist/cli/index.js +100 -45
- package/dist/config/default-rsc-entries/entry.client.tsx +1 -3
- package/dist/config/default-rsc-entries/entry.rsc.tsx +3 -0
- package/dist/config/default-rsc-entries/entry.ssr.tsx +0 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.js +1 -1
- package/dist/routes.js +1 -1
- package/dist/vite/cloudflare.js +27 -9
- package/dist/vite.js +943 -628
- package/package.json +9 -9
- package/rsc-types.d.ts +17 -0
package/dist/vite.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-58b44aa83
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -111,6 +111,14 @@ function getVite() {
|
|
|
111
111
|
invariant(vite, "getVite() called before preloadVite()");
|
|
112
112
|
return vite;
|
|
113
113
|
}
|
|
114
|
+
function defineCompilerOptions(options) {
|
|
115
|
+
let vite2 = getVite();
|
|
116
|
+
return parseInt(vite2.version.split(".")[0], 10) >= 8 ? { oxc: options.oxc } : { esbuild: options.esbuild };
|
|
117
|
+
}
|
|
118
|
+
function defineOptimizeDepsCompilerOptions(options) {
|
|
119
|
+
let vite2 = getVite();
|
|
120
|
+
return parseInt(vite2.version.split(".")[0], 10) >= 8 ? { rolldownOptions: options.rolldown } : { esbuildOptions: options.esbuild };
|
|
121
|
+
}
|
|
114
122
|
|
|
115
123
|
// vite/ssr-externals.ts
|
|
116
124
|
var ssrExternals = isReactRouterRepo() ? [
|
|
@@ -560,12 +568,13 @@ async function resolveConfig({
|
|
|
560
568
|
}
|
|
561
569
|
let future = {
|
|
562
570
|
unstable_optimizeDeps: userAndPresetConfigs.future?.unstable_optimizeDeps ?? false,
|
|
571
|
+
unstable_passThroughRequests: userAndPresetConfigs.future?.unstable_passThroughRequests ?? false,
|
|
563
572
|
unstable_subResourceIntegrity: userAndPresetConfigs.future?.unstable_subResourceIntegrity ?? false,
|
|
564
573
|
unstable_trailingSlashAwareDataRequests: userAndPresetConfigs.future?.unstable_trailingSlashAwareDataRequests ?? false,
|
|
565
574
|
unstable_previewServerPrerendering: userAndPresetConfigs.future?.unstable_previewServerPrerendering ?? false,
|
|
566
575
|
v8_middleware: userAndPresetConfigs.future?.v8_middleware ?? false,
|
|
567
576
|
v8_splitRouteModules: userAndPresetConfigs.future?.v8_splitRouteModules ?? false,
|
|
568
|
-
v8_viteEnvironmentApi: userAndPresetConfigs.future?.v8_viteEnvironmentApi ?? false
|
|
577
|
+
v8_viteEnvironmentApi: (userAndPresetConfigs.future?.v8_viteEnvironmentApi || userAndPresetConfigs.future?.unstable_previewServerPrerendering) ?? false
|
|
569
578
|
};
|
|
570
579
|
let allowedActionOrigins = userAndPresetConfigs.allowedActionOrigins ?? false;
|
|
571
580
|
let reactRouterConfig = deepFreeze({
|
|
@@ -641,13 +650,11 @@ async function createConfigLoader({
|
|
|
641
650
|
if (!fsWatcher) {
|
|
642
651
|
fsWatcher = import_chokidar.default.watch([root, appDirectory], {
|
|
643
652
|
ignoreInitial: true,
|
|
644
|
-
ignored: (path10) => {
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
dirname4 !== root;
|
|
650
|
-
}
|
|
653
|
+
ignored: (path10) => isIgnoredByWatcher(path10, { root, appDirectory })
|
|
654
|
+
});
|
|
655
|
+
fsWatcher.on("error", (error) => {
|
|
656
|
+
let message = error instanceof Error ? error.message : String(error);
|
|
657
|
+
console.warn(import_picocolors.default.yellow(`File watcher error: ${message}`));
|
|
651
658
|
});
|
|
652
659
|
fsWatcher.on("all", async (...args) => {
|
|
653
660
|
let [event, rawFilepath] = args;
|
|
@@ -856,6 +863,25 @@ function isEntryFileDependency(moduleGraph, entryFilepath, filepath, visited = /
|
|
|
856
863
|
}
|
|
857
864
|
return false;
|
|
858
865
|
}
|
|
866
|
+
function isIgnoredByWatcher(path10, { root, appDirectory }) {
|
|
867
|
+
let dirname4 = import_pathe3.default.dirname(path10);
|
|
868
|
+
let ignoredByPath = !dirname4.startsWith(appDirectory) && // Ensure we're only watching files outside of the app directory
|
|
869
|
+
// that are at the root level, not nested in subdirectories
|
|
870
|
+
path10 !== root && // Watch the root directory itself
|
|
871
|
+
dirname4 !== root;
|
|
872
|
+
if (ignoredByPath) {
|
|
873
|
+
return true;
|
|
874
|
+
}
|
|
875
|
+
try {
|
|
876
|
+
let stat = import_node_fs.default.statSync(path10, { throwIfNoEntry: false });
|
|
877
|
+
if (stat && !stat.isFile() && !stat.isDirectory()) {
|
|
878
|
+
return true;
|
|
879
|
+
}
|
|
880
|
+
} catch {
|
|
881
|
+
return true;
|
|
882
|
+
}
|
|
883
|
+
return false;
|
|
884
|
+
}
|
|
859
885
|
|
|
860
886
|
// typegen/context.ts
|
|
861
887
|
async function createContext2({
|
|
@@ -1175,7 +1201,7 @@ function getRouteAnnotations({
|
|
|
1175
1201
|
module: Module
|
|
1176
1202
|
}>
|
|
1177
1203
|
` + "\n\n" + generate(matchesType).code + "\n\n" + import_dedent.default`
|
|
1178
|
-
type Annotations = GetAnnotations<Info & { module: Module, matches: Matches }
|
|
1204
|
+
type Annotations = GetAnnotations<Info & { module: Module, matches: Matches }>;
|
|
1179
1205
|
|
|
1180
1206
|
export namespace Route {
|
|
1181
1207
|
// links
|
|
@@ -1212,11 +1238,20 @@ function getRouteAnnotations({
|
|
|
1212
1238
|
// HydrateFallback
|
|
1213
1239
|
export type HydrateFallbackProps = Annotations["HydrateFallbackProps"];
|
|
1214
1240
|
|
|
1241
|
+
// ServerHydrateFallback
|
|
1242
|
+
export type ServerHydrateFallbackProps = Annotations["ServerHydrateFallbackProps"];
|
|
1243
|
+
|
|
1215
1244
|
// Component
|
|
1216
1245
|
export type ComponentProps = Annotations["ComponentProps"];
|
|
1217
1246
|
|
|
1247
|
+
// ServerComponent
|
|
1248
|
+
export type ServerComponentProps = Annotations["ServerComponentProps"];
|
|
1249
|
+
|
|
1218
1250
|
// ErrorBoundary
|
|
1219
1251
|
export type ErrorBoundaryProps = Annotations["ErrorBoundaryProps"];
|
|
1252
|
+
|
|
1253
|
+
// ServerErrorBoundary
|
|
1254
|
+
export type ServerErrorBoundaryProps = Annotations["ServerErrorBoundaryProps"];
|
|
1220
1255
|
}
|
|
1221
1256
|
`;
|
|
1222
1257
|
return { filename: filename2, content };
|
|
@@ -2508,140 +2543,144 @@ function prerender(options) {
|
|
|
2508
2543
|
let viteConfig;
|
|
2509
2544
|
return {
|
|
2510
2545
|
name: "prerender",
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
const request = new Request(input);
|
|
2538
|
-
const url2 = new URL(request.url);
|
|
2539
|
-
if (url2.origin !== baseUrl.origin) {
|
|
2540
|
-
url2.hostname = baseUrl.hostname;
|
|
2541
|
-
url2.protocol = baseUrl.protocol;
|
|
2542
|
-
url2.port = baseUrl.port;
|
|
2543
|
-
}
|
|
2544
|
-
async function attempt(url3) {
|
|
2546
|
+
sharedDuringBuild: true,
|
|
2547
|
+
config: {
|
|
2548
|
+
order: "post",
|
|
2549
|
+
handler({ builder: { buildApp } = {} }) {
|
|
2550
|
+
return {
|
|
2551
|
+
builder: {
|
|
2552
|
+
async buildApp(builder) {
|
|
2553
|
+
await buildApp?.(builder);
|
|
2554
|
+
const rawRequests = typeof requests === "function" ? await requests() : requests;
|
|
2555
|
+
const prerenderRequests = rawRequests.map(
|
|
2556
|
+
normalizePrerenderRequest
|
|
2557
|
+
);
|
|
2558
|
+
if (prerenderRequests.length === 0) {
|
|
2559
|
+
return;
|
|
2560
|
+
}
|
|
2561
|
+
const prerenderConfig = typeof config === "function" ? await config() : config;
|
|
2562
|
+
const {
|
|
2563
|
+
buildDirectory = viteConfig.environments.client.build.outDir,
|
|
2564
|
+
concurrency = 1,
|
|
2565
|
+
retryCount = 0,
|
|
2566
|
+
retryDelay = 500,
|
|
2567
|
+
maxRedirects = 0,
|
|
2568
|
+
timeout = 1e4
|
|
2569
|
+
} = prerenderConfig ?? {};
|
|
2570
|
+
let ogIsBuildRequest = process.env.IS_RR_BUILD_REQUEST;
|
|
2571
|
+
process.env.IS_RR_BUILD_REQUEST = "yes";
|
|
2545
2572
|
try {
|
|
2546
|
-
const
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2573
|
+
const previewServer = await startPreviewServer(viteConfig);
|
|
2574
|
+
try {
|
|
2575
|
+
const baseUrl = getResolvedUrl(previewServer);
|
|
2576
|
+
async function prerenderRequest(input, metadata) {
|
|
2577
|
+
let attemptCount = 0;
|
|
2578
|
+
let redirectCount = 0;
|
|
2579
|
+
const request = new Request(input);
|
|
2580
|
+
const url2 = new URL(request.url);
|
|
2581
|
+
if (url2.origin !== baseUrl.origin) {
|
|
2582
|
+
url2.hostname = baseUrl.hostname;
|
|
2583
|
+
url2.protocol = baseUrl.protocol;
|
|
2584
|
+
url2.port = baseUrl.port;
|
|
2585
|
+
}
|
|
2586
|
+
async function attempt(url3) {
|
|
2587
|
+
try {
|
|
2588
|
+
const signal = AbortSignal.timeout(timeout);
|
|
2589
|
+
const prerenderReq = new Request(url3, request);
|
|
2590
|
+
const response = await fetch(prerenderReq, {
|
|
2591
|
+
redirect: "manual",
|
|
2592
|
+
signal
|
|
2593
|
+
});
|
|
2594
|
+
if (response.status >= 300 && response.status < 400 && response.headers.has("location") && ++redirectCount <= maxRedirects) {
|
|
2595
|
+
const location = response.headers.get("location");
|
|
2596
|
+
const responseURL = new URL(response.url);
|
|
2597
|
+
const locationUrl = new URL(location, response.url);
|
|
2598
|
+
if (responseURL.origin !== locationUrl.origin) {
|
|
2599
|
+
return await postProcess(
|
|
2600
|
+
request,
|
|
2601
|
+
response,
|
|
2602
|
+
metadata
|
|
2603
|
+
);
|
|
2604
|
+
}
|
|
2605
|
+
const redirectUrl = new URL(location, url3);
|
|
2606
|
+
return await attempt(redirectUrl);
|
|
2607
|
+
}
|
|
2608
|
+
if (response.status >= 500 && ++attemptCount <= retryCount) {
|
|
2609
|
+
await new Promise(
|
|
2610
|
+
(resolve6) => setTimeout(resolve6, retryDelay)
|
|
2611
|
+
);
|
|
2612
|
+
return attempt(url3);
|
|
2613
|
+
}
|
|
2614
|
+
return await postProcess(request, response, metadata);
|
|
2615
|
+
} catch (error) {
|
|
2616
|
+
if (++attemptCount <= retryCount) {
|
|
2617
|
+
await new Promise(
|
|
2618
|
+
(resolve6) => setTimeout(resolve6, retryDelay)
|
|
2619
|
+
);
|
|
2620
|
+
return attempt(url3);
|
|
2621
|
+
}
|
|
2622
|
+
handleError(
|
|
2623
|
+
request,
|
|
2624
|
+
error instanceof Error ? error : new Error(error?.toString() ?? "Unknown error"),
|
|
2625
|
+
metadata
|
|
2626
|
+
);
|
|
2627
|
+
return [];
|
|
2628
|
+
}
|
|
2629
|
+
}
|
|
2630
|
+
return attempt(url2);
|
|
2631
|
+
}
|
|
2632
|
+
async function prerender2(input, metadata) {
|
|
2633
|
+
const result = await prerenderRequest(input, metadata);
|
|
2634
|
+
const { files, requests: requests2 } = normalizePostProcessResult(result);
|
|
2635
|
+
for (const file of files) {
|
|
2636
|
+
await writePrerenderFile(file, metadata);
|
|
2637
|
+
}
|
|
2638
|
+
for (const followUp of requests2) {
|
|
2639
|
+
const normalized = normalizePrerenderRequest(followUp);
|
|
2640
|
+
await prerender2(normalized.request, normalized.metadata);
|
|
2641
|
+
}
|
|
2642
|
+
}
|
|
2643
|
+
async function writePrerenderFile(file, metadata) {
|
|
2644
|
+
const normalizedPath = file.path.startsWith("/") ? file.path.slice(1) : file.path;
|
|
2645
|
+
const outputPath = import_node_path.default.join(
|
|
2646
|
+
buildDirectory,
|
|
2647
|
+
...normalizedPath.split("/")
|
|
2562
2648
|
);
|
|
2649
|
+
await (0, import_promises2.mkdir)(import_node_path.default.dirname(outputPath), { recursive: true });
|
|
2650
|
+
await (0, import_promises2.writeFile)(outputPath, file.contents);
|
|
2651
|
+
const relativePath = import_node_path.default.relative(
|
|
2652
|
+
viteConfig.root,
|
|
2653
|
+
outputPath
|
|
2654
|
+
);
|
|
2655
|
+
if (logFile) {
|
|
2656
|
+
logFile(relativePath, metadata);
|
|
2657
|
+
}
|
|
2658
|
+
return relativePath;
|
|
2563
2659
|
}
|
|
2564
|
-
const
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
return attempt(url3);
|
|
2572
|
-
}
|
|
2573
|
-
return await postProcess.call(
|
|
2574
|
-
pluginContext,
|
|
2575
|
-
request,
|
|
2576
|
-
response,
|
|
2577
|
-
metadata
|
|
2578
|
-
);
|
|
2579
|
-
} catch (error) {
|
|
2580
|
-
if (++attemptCount <= retryCount) {
|
|
2581
|
-
await new Promise(
|
|
2582
|
-
(resolve6) => setTimeout(resolve6, retryDelay)
|
|
2660
|
+
const pMap = await import("p-map");
|
|
2661
|
+
await pMap.default(
|
|
2662
|
+
prerenderRequests,
|
|
2663
|
+
async ({ request, metadata }) => {
|
|
2664
|
+
await prerender2(request, metadata);
|
|
2665
|
+
},
|
|
2666
|
+
{ concurrency }
|
|
2583
2667
|
);
|
|
2584
|
-
|
|
2668
|
+
if (finalize) {
|
|
2669
|
+
await finalize(buildDirectory);
|
|
2670
|
+
}
|
|
2671
|
+
} finally {
|
|
2672
|
+
await previewServer.close();
|
|
2585
2673
|
}
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
request,
|
|
2589
|
-
error instanceof Error ? error : new Error(error?.toString() ?? "Unknown error"),
|
|
2590
|
-
metadata
|
|
2591
|
-
);
|
|
2592
|
-
return [];
|
|
2674
|
+
} finally {
|
|
2675
|
+
process.env.IS_RR_BUILD_REQUEST = ogIsBuildRequest;
|
|
2593
2676
|
}
|
|
2594
2677
|
}
|
|
2595
|
-
return attempt(url2);
|
|
2596
2678
|
}
|
|
2597
|
-
|
|
2598
|
-
const result = await prerenderRequest(input, metadata);
|
|
2599
|
-
const { files, requests: requests2 } = normalizePostProcessResult(result);
|
|
2600
|
-
for (const file of files) {
|
|
2601
|
-
await writePrerenderFile(file, metadata);
|
|
2602
|
-
}
|
|
2603
|
-
for (const followUp of requests2) {
|
|
2604
|
-
const normalized = normalizePrerenderRequest(followUp);
|
|
2605
|
-
await prerender2(normalized.request, normalized.metadata);
|
|
2606
|
-
}
|
|
2607
|
-
}
|
|
2608
|
-
async function writePrerenderFile(file, metadata) {
|
|
2609
|
-
const normalizedPath = file.path.startsWith("/") ? file.path.slice(1) : file.path;
|
|
2610
|
-
const outputPath = import_node_path.default.join(
|
|
2611
|
-
buildDirectory,
|
|
2612
|
-
...normalizedPath.split("/")
|
|
2613
|
-
);
|
|
2614
|
-
await (0, import_promises2.mkdir)(import_node_path.default.dirname(outputPath), { recursive: true });
|
|
2615
|
-
await (0, import_promises2.writeFile)(outputPath, file.contents);
|
|
2616
|
-
const relativePath = import_node_path.default.relative(viteConfig.root, outputPath);
|
|
2617
|
-
if (logFile) {
|
|
2618
|
-
logFile.call(pluginContext, relativePath, metadata);
|
|
2619
|
-
}
|
|
2620
|
-
return relativePath;
|
|
2621
|
-
}
|
|
2622
|
-
const pMap = await import("p-map");
|
|
2623
|
-
await pMap.default(
|
|
2624
|
-
prerenderRequests,
|
|
2625
|
-
async ({ request, metadata }) => {
|
|
2626
|
-
await prerender2(request, metadata);
|
|
2627
|
-
},
|
|
2628
|
-
{ concurrency }
|
|
2629
|
-
);
|
|
2630
|
-
if (finalize) {
|
|
2631
|
-
await finalize.call(pluginContext, buildDirectory);
|
|
2632
|
-
}
|
|
2633
|
-
} finally {
|
|
2634
|
-
await new Promise((resolve6, reject) => {
|
|
2635
|
-
previewServer.httpServer.close((err2) => {
|
|
2636
|
-
if (err2) {
|
|
2637
|
-
reject(err2);
|
|
2638
|
-
} else {
|
|
2639
|
-
resolve6();
|
|
2640
|
-
}
|
|
2641
|
-
});
|
|
2642
|
-
});
|
|
2643
|
-
}
|
|
2679
|
+
};
|
|
2644
2680
|
}
|
|
2681
|
+
},
|
|
2682
|
+
configResolved(resolvedConfig) {
|
|
2683
|
+
viteConfig = resolvedConfig;
|
|
2645
2684
|
}
|
|
2646
2685
|
};
|
|
2647
2686
|
}
|
|
@@ -3024,7 +3063,7 @@ var reactRouterVitePlugin = () => {
|
|
|
3024
3063
|
let viteChildCompiler = null;
|
|
3025
3064
|
let cache = /* @__PURE__ */ new Map();
|
|
3026
3065
|
let reactRouterConfigLoader;
|
|
3027
|
-
let
|
|
3066
|
+
let typegenWatcherPromise2;
|
|
3028
3067
|
let logger;
|
|
3029
3068
|
let firstLoad = true;
|
|
3030
3069
|
let ctx;
|
|
@@ -3448,7 +3487,7 @@ var reactRouterVitePlugin = () => {
|
|
|
3448
3487
|
rootDirectory = viteUserConfig.root ?? process.env.REACT_ROUTER_ROOT ?? process.cwd();
|
|
3449
3488
|
let mode = viteConfigEnv.mode;
|
|
3450
3489
|
if (viteCommand === "serve") {
|
|
3451
|
-
|
|
3490
|
+
typegenWatcherPromise2 = watch(rootDirectory, {
|
|
3452
3491
|
mode,
|
|
3453
3492
|
rsc: false,
|
|
3454
3493
|
// ignore `info` logs from typegen since they are redundant when Vite plugin logs are active
|
|
@@ -3508,10 +3547,18 @@ var reactRouterVitePlugin = () => {
|
|
|
3508
3547
|
}) ? ["react-router-dom"] : []
|
|
3509
3548
|
]
|
|
3510
3549
|
},
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3550
|
+
...defineCompilerOptions({
|
|
3551
|
+
oxc: {
|
|
3552
|
+
jsx: {
|
|
3553
|
+
runtime: "automatic",
|
|
3554
|
+
development: viteCommand !== "build"
|
|
3555
|
+
}
|
|
3556
|
+
},
|
|
3557
|
+
esbuild: {
|
|
3558
|
+
jsx: "automatic",
|
|
3559
|
+
jsxDev: viteCommand !== "build"
|
|
3560
|
+
}
|
|
3561
|
+
}),
|
|
3515
3562
|
resolve: {
|
|
3516
3563
|
dedupe: [
|
|
3517
3564
|
// https://react.dev/warnings/invalid-hook-call-warning#duplicate-react
|
|
@@ -3771,32 +3818,51 @@ var reactRouterVitePlugin = () => {
|
|
|
3771
3818
|
let cachedHandler = null;
|
|
3772
3819
|
async function getHandler() {
|
|
3773
3820
|
if (cachedHandler) return cachedHandler;
|
|
3774
|
-
let
|
|
3821
|
+
let bundledHandlers = [];
|
|
3775
3822
|
let buildManifest = ctx.buildManifest ?? (ctx.reactRouterConfig.serverBundles ? await getBuildManifest({
|
|
3776
3823
|
reactRouterConfig: ctx.reactRouterConfig,
|
|
3777
3824
|
rootDirectory: ctx.rootDirectory
|
|
3778
3825
|
}) : null);
|
|
3779
3826
|
if (buildManifest?.serverBundles) {
|
|
3827
|
+
let routesByServerBundleId = getRoutesByServerBundleId(buildManifest);
|
|
3780
3828
|
for (let bundle of Object.values(buildManifest.serverBundles)) {
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3829
|
+
let build = await import(url.pathToFileURL(path7.resolve(ctx.rootDirectory, bundle.file)).href);
|
|
3830
|
+
bundledHandlers.push({
|
|
3831
|
+
handler: (0, import_react_router2.createRequestHandler)(build, "production"),
|
|
3832
|
+
routes: createPrerenderRoutes(
|
|
3833
|
+
routesByServerBundleId[bundle.id] ?? {}
|
|
3834
|
+
)
|
|
3835
|
+
});
|
|
3784
3836
|
}
|
|
3785
3837
|
} else {
|
|
3786
3838
|
let serverEntryPath = path7.resolve(
|
|
3787
3839
|
getServerBuildDirectory(ctx.reactRouterConfig),
|
|
3788
3840
|
"index.js"
|
|
3789
3841
|
);
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
handlers.push((0, import_react_router2.createRequestHandler)(build, "production"));
|
|
3842
|
+
let build = await import(url.pathToFileURL(serverEntryPath).href);
|
|
3843
|
+
bundledHandlers.push({
|
|
3844
|
+
handler: (0, import_react_router2.createRequestHandler)(build, "production"),
|
|
3845
|
+
routes: null
|
|
3846
|
+
});
|
|
3796
3847
|
}
|
|
3797
3848
|
cachedHandler = async (request, loadContext) => {
|
|
3798
3849
|
let response;
|
|
3799
|
-
|
|
3850
|
+
let handlersToTry = bundledHandlers;
|
|
3851
|
+
if (buildManifest?.serverBundles) {
|
|
3852
|
+
let pathname = new URL(request.url).pathname;
|
|
3853
|
+
handlersToTry = bundledHandlers.map((entry, index) => ({
|
|
3854
|
+
entry,
|
|
3855
|
+
index,
|
|
3856
|
+
matchDepth: (0, import_react_router2.matchRoutes)(
|
|
3857
|
+
entry.routes ?? [],
|
|
3858
|
+
pathname,
|
|
3859
|
+
ctx.reactRouterConfig.basename
|
|
3860
|
+
)?.length ?? -1
|
|
3861
|
+
})).sort(
|
|
3862
|
+
(a, b) => b.matchDepth - a.matchDepth || a.index - b.index
|
|
3863
|
+
).map(({ entry }) => entry);
|
|
3864
|
+
}
|
|
3865
|
+
for (let { handler } of handlersToTry) {
|
|
3800
3866
|
response = await handler(request, loadContext);
|
|
3801
3867
|
if (response.status !== 404) {
|
|
3802
3868
|
return response;
|
|
@@ -3805,7 +3871,10 @@ var reactRouterVitePlugin = () => {
|
|
|
3805
3871
|
if (response) {
|
|
3806
3872
|
return response;
|
|
3807
3873
|
}
|
|
3808
|
-
|
|
3874
|
+
let url2 = new URL(request.url);
|
|
3875
|
+
throw new Error(
|
|
3876
|
+
"No handlers were found for the request: " + url2.pathname + url2.search
|
|
3877
|
+
);
|
|
3809
3878
|
};
|
|
3810
3879
|
return cachedHandler;
|
|
3811
3880
|
}
|
|
@@ -3959,7 +4028,7 @@ var reactRouterVitePlugin = () => {
|
|
|
3959
4028
|
async buildEnd() {
|
|
3960
4029
|
await viteChildCompiler?.close();
|
|
3961
4030
|
await reactRouterConfigLoader.close();
|
|
3962
|
-
let typegenWatcher = await
|
|
4031
|
+
let typegenWatcher = await typegenWatcherPromise2;
|
|
3963
4032
|
await typegenWatcher?.close();
|
|
3964
4033
|
}
|
|
3965
4034
|
},
|
|
@@ -4390,9 +4459,6 @@ var reactRouterVitePlugin = () => {
|
|
|
4390
4459
|
async requests() {
|
|
4391
4460
|
invariant(viteConfig);
|
|
4392
4461
|
let { future } = ctx.reactRouterConfig;
|
|
4393
|
-
if (future.v8_viteEnvironmentApi ? this.environment.name === "client" : !viteConfigEnv.isSsrBuild) {
|
|
4394
|
-
return [];
|
|
4395
|
-
}
|
|
4396
4462
|
if (!future.unstable_previewServerPrerendering) {
|
|
4397
4463
|
return [];
|
|
4398
4464
|
}
|
|
@@ -4523,15 +4589,17 @@ ${new TextDecoder().decode(contents)}`
|
|
|
4523
4589
|
if (redirectStatusCodes.has(response.status)) {
|
|
4524
4590
|
let location = response.headers.get("Location");
|
|
4525
4591
|
let delay = response.status === 302 ? 2 : 0;
|
|
4592
|
+
let escapedLocation = escapeHtml(location ?? "");
|
|
4593
|
+
let escapedPathname = escapeHtml(pathname);
|
|
4526
4594
|
html = `<!doctype html>
|
|
4527
4595
|
<head>
|
|
4528
|
-
<title>Redirecting to: ${
|
|
4529
|
-
<meta http-equiv="refresh" content="${delay};url=${
|
|
4596
|
+
<title>Redirecting to: ${escapedLocation}</title>
|
|
4597
|
+
<meta http-equiv="refresh" content="${delay};url=${escapedLocation}">
|
|
4530
4598
|
<meta name="robots" content="noindex">
|
|
4531
4599
|
</head>
|
|
4532
4600
|
<body>
|
|
4533
|
-
<a href="${
|
|
4534
|
-
Redirecting from <code>${
|
|
4601
|
+
<a href="${escapedLocation}">
|
|
4602
|
+
Redirecting from <code>${escapedPathname}</code> to <code>${escapedLocation}</code>
|
|
4535
4603
|
</a>
|
|
4536
4604
|
</body>
|
|
4537
4605
|
</html>`;
|
|
@@ -4583,7 +4651,9 @@ ${html}`
|
|
|
4583
4651
|
);
|
|
4584
4652
|
}
|
|
4585
4653
|
}
|
|
4586
|
-
let serverBuildDirectory =
|
|
4654
|
+
let serverBuildDirectory = getServerBuildDirectory(
|
|
4655
|
+
ctx.reactRouterConfig
|
|
4656
|
+
);
|
|
4587
4657
|
viteConfig.logger.info(
|
|
4588
4658
|
[
|
|
4589
4659
|
"Removing the server build in",
|
|
@@ -4940,15 +5010,17 @@ async function prerenderRoute(handler, prerenderPath, clientBuildDirectory, reac
|
|
|
4940
5010
|
if (redirectStatusCodes.has(response.status)) {
|
|
4941
5011
|
let location = response.headers.get("Location");
|
|
4942
5012
|
let delay = response.status === 302 ? 2 : 0;
|
|
5013
|
+
let escapedLocation = escapeHtml(location ?? "");
|
|
5014
|
+
let escapedNormalizedPath = escapeHtml(normalizedPath);
|
|
4943
5015
|
html = `<!doctype html>
|
|
4944
5016
|
<head>
|
|
4945
|
-
<title>Redirecting to: ${
|
|
4946
|
-
<meta http-equiv="refresh" content="${delay};url=${
|
|
5017
|
+
<title>Redirecting to: ${escapedLocation}</title>
|
|
5018
|
+
<meta http-equiv="refresh" content="${delay};url=${escapedLocation}">
|
|
4947
5019
|
<meta name="robots" content="noindex">
|
|
4948
5020
|
</head>
|
|
4949
5021
|
<body>
|
|
4950
|
-
<a href="${
|
|
4951
|
-
Redirecting from <code>${
|
|
5022
|
+
<a href="${escapedLocation}">
|
|
5023
|
+
Redirecting from <code>${escapedNormalizedPath}</code> to <code>${escapedLocation}</code>
|
|
4952
5024
|
</a>
|
|
4953
5025
|
</body>
|
|
4954
5026
|
</html>`;
|
|
@@ -5590,23 +5662,113 @@ function createSpaModeRequest(reactRouterConfig) {
|
|
|
5590
5662
|
metadata: { type: "spa", path: "/" }
|
|
5591
5663
|
};
|
|
5592
5664
|
}
|
|
5665
|
+
var ESCAPE_REGEX = /[&><\u2028\u2029]/g;
|
|
5666
|
+
var ESCAPE_LOOKUP = {
|
|
5667
|
+
"&": "\\u0026",
|
|
5668
|
+
">": "\\u003e",
|
|
5669
|
+
"<": "\\u003c",
|
|
5670
|
+
"\u2028": "\\u2028",
|
|
5671
|
+
"\u2029": "\\u2029"
|
|
5672
|
+
};
|
|
5673
|
+
function escapeHtml(html) {
|
|
5674
|
+
return html.replace(ESCAPE_REGEX, (match) => ESCAPE_LOOKUP[match]);
|
|
5675
|
+
}
|
|
5593
5676
|
|
|
5594
5677
|
// vite/rsc/plugin.ts
|
|
5595
5678
|
var import_es_module_lexer3 = require("es-module-lexer");
|
|
5596
5679
|
var Path5 = __toESM(require("pathe"));
|
|
5597
|
-
var babel2 = __toESM(require("@babel/core"));
|
|
5598
5680
|
var import_picocolors5 = __toESM(require("picocolors"));
|
|
5681
|
+
var import_fs = require("fs");
|
|
5599
5682
|
var import_promises4 = require("fs/promises");
|
|
5600
5683
|
var import_pathe6 = __toESM(require("pathe"));
|
|
5601
5684
|
|
|
5602
5685
|
// vite/rsc/virtual-route-config.ts
|
|
5603
5686
|
var import_pathe5 = __toESM(require("pathe"));
|
|
5687
|
+
var js = String.raw;
|
|
5604
5688
|
function createVirtualRouteConfig({
|
|
5605
5689
|
appDirectory,
|
|
5606
5690
|
routeConfig
|
|
5607
5691
|
}) {
|
|
5608
5692
|
let routeIdByFile = /* @__PURE__ */ new Map();
|
|
5609
|
-
let code =
|
|
5693
|
+
let code = js`import * as React from "react";
|
|
5694
|
+
function frameworkRoute(lazy) {
|
|
5695
|
+
return async () => {
|
|
5696
|
+
const mod = await lazy();
|
|
5697
|
+
let Component;
|
|
5698
|
+
let Layout;
|
|
5699
|
+
let ErrorBoundary;
|
|
5700
|
+
let HydrateFallback;
|
|
5701
|
+
if ("default" in mod && mod.default) {
|
|
5702
|
+
if ("ServerComponent" in mod && mod.ServerComponent) {
|
|
5703
|
+
throw new Error("Module cannot have both a default export and a ServerComponent export");
|
|
5704
|
+
}
|
|
5705
|
+
Component = mod.default;
|
|
5706
|
+
} else if ("ServerComponent" in mod && mod.ServerComponent) {
|
|
5707
|
+
Component = mod.ServerComponent;
|
|
5708
|
+
}
|
|
5709
|
+
if ("Layout" in mod && mod.Layout) {
|
|
5710
|
+
if ("ServerLayout" in mod && mod.ServerLayout) {
|
|
5711
|
+
throw new Error("Module cannot have both a Layout export and a ServerLayout export");
|
|
5712
|
+
}
|
|
5713
|
+
Layout = mod.Layout;
|
|
5714
|
+
} else if ("ServerLayout" in mod && mod.ServerLayout) {
|
|
5715
|
+
Layout = mod.ServerLayout;
|
|
5716
|
+
}
|
|
5717
|
+
if ("ErrorBoundary" in mod && mod.ErrorBoundary) {
|
|
5718
|
+
if ("ServerErrorBoundary" in mod && mod.ServerErrorBoundary) {
|
|
5719
|
+
throw new Error(
|
|
5720
|
+
"Module cannot have both an ErrorBoundary export and a ServerErrorBoundary export",
|
|
5721
|
+
);
|
|
5722
|
+
}
|
|
5723
|
+
ErrorBoundary = mod.ErrorBoundary;
|
|
5724
|
+
} else if ("ServerErrorBoundary" in mod && mod.ServerErrorBoundary) {
|
|
5725
|
+
ErrorBoundary = mod.ServerErrorBoundary;
|
|
5726
|
+
}
|
|
5727
|
+
if ("HydrateFallback" in mod && mod.HydrateFallback) {
|
|
5728
|
+
if ("ServerHydrateFallback" in mod && mod.ServerHydrateFallback) {
|
|
5729
|
+
throw new Error(
|
|
5730
|
+
"Module cannot have both a HydrateFallback export and a ServerHydrateFallback export",
|
|
5731
|
+
);
|
|
5732
|
+
}
|
|
5733
|
+
HydrateFallback = mod.HydrateFallback;
|
|
5734
|
+
} else if ("ServerHydrateFallback" in mod && mod.ServerHydrateFallback) {
|
|
5735
|
+
HydrateFallback = mod.ServerHydrateFallback;
|
|
5736
|
+
}
|
|
5737
|
+
|
|
5738
|
+
const {
|
|
5739
|
+
action,
|
|
5740
|
+
clientAction,
|
|
5741
|
+
clientLoader,
|
|
5742
|
+
clientMiddleware,
|
|
5743
|
+
handle,
|
|
5744
|
+
headers,
|
|
5745
|
+
links,
|
|
5746
|
+
loader,
|
|
5747
|
+
meta,
|
|
5748
|
+
middleware,
|
|
5749
|
+
shouldRevalidate,
|
|
5750
|
+
} = mod;
|
|
5751
|
+
|
|
5752
|
+
return {
|
|
5753
|
+
Component,
|
|
5754
|
+
ErrorBoundary,
|
|
5755
|
+
HydrateFallback,
|
|
5756
|
+
Layout,
|
|
5757
|
+
action,
|
|
5758
|
+
clientAction,
|
|
5759
|
+
clientLoader,
|
|
5760
|
+
clientMiddleware,
|
|
5761
|
+
handle,
|
|
5762
|
+
headers,
|
|
5763
|
+
links,
|
|
5764
|
+
loader,
|
|
5765
|
+
meta,
|
|
5766
|
+
middleware,
|
|
5767
|
+
shouldRevalidate,
|
|
5768
|
+
};
|
|
5769
|
+
};
|
|
5770
|
+
}
|
|
5771
|
+
export default [`;
|
|
5610
5772
|
const closeRouteSymbol = Symbol("CLOSE_ROUTE");
|
|
5611
5773
|
let stack = [
|
|
5612
5774
|
...routeConfig
|
|
@@ -5622,9 +5784,9 @@ function createVirtualRouteConfig({
|
|
|
5622
5784
|
const routeFile = import_pathe5.default.resolve(appDirectory, route.file);
|
|
5623
5785
|
const routeId = route.id || createRouteId2(route.file, appDirectory);
|
|
5624
5786
|
routeIdByFile.set(routeFile, routeId);
|
|
5625
|
-
code += `lazy: () => import(${JSON.stringify(
|
|
5626
|
-
`${routeFile}
|
|
5627
|
-
)}),`;
|
|
5787
|
+
code += `lazy: frameworkRoute(() => import(${JSON.stringify(
|
|
5788
|
+
`${routeFile}`
|
|
5789
|
+
)})),`;
|
|
5628
5790
|
code += `id: ${JSON.stringify(routeId)},`;
|
|
5629
5791
|
if (typeof route.path === "string") {
|
|
5630
5792
|
code += `path: ${JSON.stringify(route.path)},`;
|
|
@@ -5652,289 +5814,323 @@ function createRouteId2(file, appDirectory) {
|
|
|
5652
5814
|
|
|
5653
5815
|
// vite/rsc/virtual-route-modules.ts
|
|
5654
5816
|
var import_es_module_lexer2 = require("es-module-lexer");
|
|
5655
|
-
var
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
"
|
|
5661
|
-
|
|
5662
|
-
|
|
5663
|
-
|
|
5664
|
-
function isServerOnlyRouteExport(name) {
|
|
5665
|
-
return SERVER_ONLY_ROUTE_EXPORTS_SET.has(name);
|
|
5666
|
-
}
|
|
5667
|
-
var COMMON_COMPONENT_EXPORTS = [
|
|
5668
|
-
"ErrorBoundary",
|
|
5669
|
-
"HydrateFallback",
|
|
5670
|
-
"Layout"
|
|
5671
|
-
];
|
|
5672
|
-
var SERVER_FIRST_COMPONENT_EXPORTS = [
|
|
5673
|
-
...COMMON_COMPONENT_EXPORTS,
|
|
5674
|
-
...SERVER_ONLY_COMPONENT_EXPORTS
|
|
5675
|
-
];
|
|
5676
|
-
var SERVER_FIRST_COMPONENT_EXPORTS_SET = new Set(
|
|
5677
|
-
SERVER_FIRST_COMPONENT_EXPORTS
|
|
5678
|
-
);
|
|
5679
|
-
function isServerFirstComponentExport(name) {
|
|
5680
|
-
return SERVER_FIRST_COMPONENT_EXPORTS_SET.has(
|
|
5681
|
-
name
|
|
5682
|
-
);
|
|
5683
|
-
}
|
|
5684
|
-
var CLIENT_COMPONENT_EXPORTS = [
|
|
5685
|
-
...COMMON_COMPONENT_EXPORTS,
|
|
5686
|
-
"default"
|
|
5687
|
-
];
|
|
5688
|
-
var CLIENT_NON_COMPONENT_EXPORTS2 = [
|
|
5689
|
-
"clientAction",
|
|
5690
|
-
"clientLoader",
|
|
5691
|
-
"clientMiddleware",
|
|
5692
|
-
"handle",
|
|
5693
|
-
"meta",
|
|
5694
|
-
"links",
|
|
5695
|
-
"shouldRevalidate"
|
|
5696
|
-
];
|
|
5697
|
-
var CLIENT_NON_COMPONENT_EXPORTS_SET = new Set(CLIENT_NON_COMPONENT_EXPORTS2);
|
|
5698
|
-
function isClientNonComponentExport(name) {
|
|
5699
|
-
return CLIENT_NON_COMPONENT_EXPORTS_SET.has(name);
|
|
5700
|
-
}
|
|
5701
|
-
var CLIENT_ROUTE_EXPORTS2 = [
|
|
5702
|
-
...CLIENT_NON_COMPONENT_EXPORTS2,
|
|
5703
|
-
...CLIENT_COMPONENT_EXPORTS
|
|
5704
|
-
];
|
|
5705
|
-
var CLIENT_ROUTE_EXPORTS_SET = new Set(CLIENT_ROUTE_EXPORTS2);
|
|
5706
|
-
function isClientRouteExport(name) {
|
|
5707
|
-
return CLIENT_ROUTE_EXPORTS_SET.has(name);
|
|
5708
|
-
}
|
|
5709
|
-
var ROUTE_EXPORTS = [
|
|
5710
|
-
...SERVER_ONLY_ROUTE_EXPORTS2,
|
|
5711
|
-
...CLIENT_ROUTE_EXPORTS2
|
|
5712
|
-
];
|
|
5713
|
-
var ROUTE_EXPORTS_SET = new Set(ROUTE_EXPORTS);
|
|
5714
|
-
function isRouteExport(name) {
|
|
5715
|
-
return ROUTE_EXPORTS_SET.has(name);
|
|
5716
|
-
}
|
|
5717
|
-
function isCustomRouteExport(name) {
|
|
5718
|
-
return !isRouteExport(name);
|
|
5719
|
-
}
|
|
5720
|
-
function hasReactServerCondition(viteEnvironment) {
|
|
5721
|
-
return viteEnvironment.config.resolve.conditions.includes("react-server");
|
|
5722
|
-
}
|
|
5723
|
-
function transformVirtualRouteModules({
|
|
5724
|
-
id,
|
|
5725
|
-
code,
|
|
5726
|
-
viteCommand,
|
|
5727
|
-
routeIdByFile,
|
|
5728
|
-
rootRouteFile,
|
|
5729
|
-
viteEnvironment
|
|
5730
|
-
}) {
|
|
5731
|
-
if (isVirtualRouteModuleId(id) || routeIdByFile.has(id)) {
|
|
5732
|
-
return createVirtualRouteModuleCode({
|
|
5733
|
-
id,
|
|
5734
|
-
code,
|
|
5735
|
-
rootRouteFile,
|
|
5736
|
-
viteCommand,
|
|
5737
|
-
viteEnvironment
|
|
5738
|
-
});
|
|
5739
|
-
}
|
|
5740
|
-
if (isVirtualServerRouteModuleId(id)) {
|
|
5741
|
-
return createVirtualServerRouteModuleCode({
|
|
5742
|
-
id,
|
|
5743
|
-
code,
|
|
5744
|
-
viteEnvironment
|
|
5745
|
-
});
|
|
5746
|
-
}
|
|
5747
|
-
if (isVirtualClientRouteModuleId(id)) {
|
|
5748
|
-
return createVirtualClientRouteModuleCode({
|
|
5749
|
-
id,
|
|
5750
|
-
code,
|
|
5751
|
-
rootRouteFile,
|
|
5752
|
-
viteCommand
|
|
5753
|
-
});
|
|
5754
|
-
}
|
|
5755
|
-
}
|
|
5756
|
-
async function createVirtualRouteModuleCode({
|
|
5757
|
-
id,
|
|
5758
|
-
code: routeSource,
|
|
5759
|
-
rootRouteFile,
|
|
5760
|
-
viteCommand,
|
|
5761
|
-
viteEnvironment
|
|
5817
|
+
var ENSURE_CLIENT_ROUTE_MODULE_CHUNK_FOR_HMR = `
|
|
5818
|
+
import * as ___EnsureClientRouteModuleForHMR_REACT___ from "react";
|
|
5819
|
+
export function EnsureClientRouteModuleForHMR___() { return ___EnsureClientRouteModuleForHMR_REACT___.createElement(___EnsureClientRouteModuleForHMR_REACT___.Fragment, null) }
|
|
5820
|
+
`;
|
|
5821
|
+
function virtualRouteModulesPlugin({
|
|
5822
|
+
environments: { client = ["client", "ssr"], server = ["rsc"] } = {},
|
|
5823
|
+
isRouteModule,
|
|
5824
|
+
isRootRouteModule,
|
|
5825
|
+
transformToJs
|
|
5762
5826
|
}) {
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5827
|
+
let clientEnvironments = new Set(client);
|
|
5828
|
+
let serverEnvironments = new Set(server);
|
|
5829
|
+
let cache = /* @__PURE__ */ new Map();
|
|
5830
|
+
async function createClientRouteEntry(id, code) {
|
|
5831
|
+
let result = "";
|
|
5832
|
+
let routeChunks = detectRouteChunks2(cache, id, code);
|
|
5833
|
+
let { staticExports } = await parseRouteExports(code);
|
|
5834
|
+
validateRouteModuleExports(staticExports);
|
|
5835
|
+
let needsReactImport = false;
|
|
5836
|
+
for (let exportName of staticExports) {
|
|
5837
|
+
if (isServerRouteExport(exportName)) {
|
|
5838
|
+
continue;
|
|
5839
|
+
}
|
|
5840
|
+
if ((exportName === "clientAction" || exportName === "clientLoader") && routeChunks.hasRouteChunkByExportName[exportName]) {
|
|
5841
|
+
result += `export const ${exportName} = async (...args) => import("${createId(id, "client-route-module", exportName)}").then(mod => mod.${exportName}(...args));
|
|
5842
|
+
`;
|
|
5843
|
+
} else if (exportName === "HydrateFallback") {
|
|
5844
|
+
needsReactImport = true;
|
|
5845
|
+
result += `export const ${exportName} = React.lazy(() => import("${createId(
|
|
5846
|
+
id,
|
|
5847
|
+
"client-route-module",
|
|
5848
|
+
routeChunks.hasRouteChunkByExportName[exportName] ? exportName : "shared"
|
|
5849
|
+
)}").then(mod => ({ default: mod.${exportName} })));
|
|
5850
|
+
`;
|
|
5851
|
+
} else {
|
|
5852
|
+
result += `export { ${exportName} } from "${createId(
|
|
5853
|
+
id,
|
|
5854
|
+
"client-route-module",
|
|
5855
|
+
routeChunks.hasRouteChunkByExportName[exportName] ? exportName : "shared"
|
|
5856
|
+
)}";
|
|
5771
5857
|
`;
|
|
5858
|
+
}
|
|
5772
5859
|
}
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5860
|
+
if (needsReactImport) {
|
|
5861
|
+
result = `import * as React from "react";
|
|
5862
|
+
${result}`;
|
|
5863
|
+
}
|
|
5864
|
+
return {
|
|
5865
|
+
code: '"use client";\n' + result
|
|
5866
|
+
};
|
|
5867
|
+
}
|
|
5868
|
+
async function createServerRouteEntry(id, code, isRootRouteModule2) {
|
|
5869
|
+
let result = "";
|
|
5870
|
+
let routeChunks = detectRouteChunks2(cache, id, code);
|
|
5871
|
+
let { staticExports } = await parseRouteExports(code);
|
|
5872
|
+
validateRouteModuleExports(staticExports);
|
|
5873
|
+
let needsReactImport = false;
|
|
5874
|
+
for (let exportName of staticExports) {
|
|
5875
|
+
if (isClientRouteExport(exportName)) {
|
|
5876
|
+
result += `export { ${exportName} } from "${createId(
|
|
5877
|
+
id,
|
|
5878
|
+
"client-route-module",
|
|
5879
|
+
routeChunks.hasRouteChunkByExportName[exportName] ? exportName : "shared"
|
|
5880
|
+
)}";
|
|
5776
5881
|
`;
|
|
5777
|
-
} else if (
|
|
5778
|
-
|
|
5779
|
-
|
|
5882
|
+
} else if (isServerComponentExport(exportName)) {
|
|
5883
|
+
needsReactImport = true;
|
|
5884
|
+
result += `import { ${exportName} as ${exportName}WithoutCss } from "${createId(id, "server-route-module")}";
|
|
5780
5885
|
`;
|
|
5781
|
-
|
|
5886
|
+
result += `export function ${exportName}(props) {
|
|
5782
5887
|
`;
|
|
5783
|
-
|
|
5888
|
+
result += ` return React.createElement(React.Fragment, null,
|
|
5784
5889
|
`;
|
|
5785
|
-
|
|
5890
|
+
result += ` import.meta.viteRsc.loadCss(),
|
|
5786
5891
|
`;
|
|
5787
|
-
|
|
5892
|
+
result += ` React.createElement(EnsureClientRouteModuleForHMR___, null),
|
|
5788
5893
|
`;
|
|
5789
|
-
|
|
5894
|
+
result += ` React.createElement(${exportName}WithoutCss, props),
|
|
5790
5895
|
`;
|
|
5791
|
-
|
|
5896
|
+
result += ` );
|
|
5792
5897
|
`;
|
|
5793
|
-
|
|
5794
|
-
code += `export { ${staticExport} } from "${serverModuleId}";
|
|
5898
|
+
result += `}
|
|
5795
5899
|
`;
|
|
5796
|
-
} else
|
|
5797
|
-
|
|
5900
|
+
} else {
|
|
5901
|
+
result += `export { ${exportName} } from "${createId(id, "server-route-module")}";
|
|
5798
5902
|
`;
|
|
5799
5903
|
}
|
|
5800
5904
|
}
|
|
5801
|
-
if (
|
|
5802
|
-
|
|
5803
|
-
|
|
5905
|
+
if (needsReactImport) {
|
|
5906
|
+
result = `import * as React from "react";
|
|
5907
|
+
import { EnsureClientRouteModuleForHMR___ } from "${createId(id, "client-route-module", "shared")}";
|
|
5908
|
+
|
|
5909
|
+
${result}`;
|
|
5804
5910
|
}
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
if (isClientRouteExport(staticExport)) {
|
|
5808
|
-
code += `export { ${staticExport} } from "${clientModuleId}";
|
|
5809
|
-
`;
|
|
5810
|
-
} else if (isReactServer && isServerOnlyRouteExport(staticExport)) {
|
|
5811
|
-
code += `export { ${staticExport} } from "${serverModuleId}";
|
|
5911
|
+
if (isRootRouteModule2 && !staticExports.includes("ErrorBoundary") && !staticExports.includes("ServerErrorBoundary")) {
|
|
5912
|
+
result += `export { ErrorBoundary } from "${createId(id, "client-route-module", "shared")}";
|
|
5812
5913
|
`;
|
|
5813
|
-
} else if (isCustomRouteExport(staticExport)) {
|
|
5814
|
-
code += `export { ${staticExport} } from "${isReactServer ? serverModuleId : clientModuleId}";
|
|
5815
|
-
`;
|
|
5816
|
-
}
|
|
5817
5914
|
}
|
|
5915
|
+
return {
|
|
5916
|
+
code: result
|
|
5917
|
+
};
|
|
5818
5918
|
}
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
function createVirtualServerRouteModuleCode({
|
|
5826
|
-
id,
|
|
5827
|
-
code: routeSource,
|
|
5828
|
-
viteEnvironment
|
|
5829
|
-
}) {
|
|
5830
|
-
if (!hasReactServerCondition(viteEnvironment)) {
|
|
5831
|
-
throw new Error(
|
|
5832
|
-
[
|
|
5833
|
-
"Virtual server route module was loaded outside of the RSC environment.",
|
|
5834
|
-
`Environment Name: ${viteEnvironment.name}`,
|
|
5835
|
-
`Module ID: ${id}`
|
|
5836
|
-
].join("\n")
|
|
5837
|
-
);
|
|
5919
|
+
function createServerRouteModule(code) {
|
|
5920
|
+
const ast = import_parser.parse(code, {
|
|
5921
|
+
sourceType: "module"
|
|
5922
|
+
});
|
|
5923
|
+
removeExports(ast, CLIENT_ROUTE_EXPORTS2);
|
|
5924
|
+
return generate(ast);
|
|
5838
5925
|
}
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
`;
|
|
5855
|
-
}
|
|
5926
|
+
async function createClientRouteModuleChunk(id, code, chunk, isRootRouteModule2) {
|
|
5927
|
+
let routeChunks = detectRouteChunks2(cache, id, code);
|
|
5928
|
+
const ast = import_parser.parse(code, {
|
|
5929
|
+
sourceType: "module"
|
|
5930
|
+
});
|
|
5931
|
+
const { staticExports } = await parseRouteExports(code);
|
|
5932
|
+
if (chunk === "shared") {
|
|
5933
|
+
removeExports(ast, [
|
|
5934
|
+
...SERVER_ROUTE_EXPORTS,
|
|
5935
|
+
...routeChunks.chunkedExports
|
|
5936
|
+
]);
|
|
5937
|
+
} else {
|
|
5938
|
+
const toRemove = /* @__PURE__ */ new Set([...SERVER_ROUTE_EXPORTS, ...staticExports]);
|
|
5939
|
+
toRemove.delete(chunk);
|
|
5940
|
+
removeExports(ast, Array.from(toRemove));
|
|
5856
5941
|
}
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
rootRouteFile,
|
|
5864
|
-
viteCommand
|
|
5865
|
-
}) {
|
|
5866
|
-
const { staticExports, isServerFirstRoute, hasClientExports } = parseRouteExports(routeSource);
|
|
5867
|
-
const exportsToRemove = isServerFirstRoute ? [...SERVER_ONLY_ROUTE_EXPORTS2, ...CLIENT_COMPONENT_EXPORTS] : SERVER_ONLY_ROUTE_EXPORTS2;
|
|
5868
|
-
const clientRouteModuleAst = import_parser.parse(routeSource, {
|
|
5869
|
-
sourceType: "module"
|
|
5870
|
-
});
|
|
5871
|
-
removeExports(clientRouteModuleAst, exportsToRemove);
|
|
5872
|
-
const generatorResult = generate(clientRouteModuleAst);
|
|
5873
|
-
generatorResult.code = '"use client";' + generatorResult.code;
|
|
5874
|
-
if (isRootRouteFile({ id, rootRouteFile }) && !staticExports.includes("ErrorBoundary")) {
|
|
5875
|
-
const hasRootLayout = staticExports.includes("Layout");
|
|
5876
|
-
generatorResult.code += `
|
|
5942
|
+
const generated = generate(ast);
|
|
5943
|
+
let result = '"use client";\n' + generated.code;
|
|
5944
|
+
if (chunk === "shared") {
|
|
5945
|
+
if (isRootRouteModule2 && !staticExports.includes("ErrorBoundary") && !staticExports.includes("ServerErrorBoundary")) {
|
|
5946
|
+
const hasRootLayout = staticExports.includes("Layout") || staticExports.includes("ServerLayout");
|
|
5947
|
+
result += `
|
|
5877
5948
|
import { createElement as __rr_createElement } from "react";
|
|
5878
5949
|
`;
|
|
5879
|
-
|
|
5950
|
+
result += `import { UNSAFE_RSCDefaultRootErrorBoundary } from "react-router";
|
|
5880
5951
|
`;
|
|
5881
|
-
|
|
5952
|
+
result += `export function ErrorBoundary() {
|
|
5882
5953
|
`;
|
|
5883
|
-
|
|
5954
|
+
result += ` return __rr_createElement(UNSAFE_RSCDefaultRootErrorBoundary, { hasRootLayout: ${hasRootLayout} });
|
|
5884
5955
|
`;
|
|
5885
|
-
|
|
5956
|
+
result += `}
|
|
5886
5957
|
`;
|
|
5958
|
+
}
|
|
5959
|
+
result += ENSURE_CLIENT_ROUTE_MODULE_CHUNK_FOR_HMR;
|
|
5960
|
+
}
|
|
5961
|
+
result += `
|
|
5962
|
+
if (import.meta.hot) {
|
|
5963
|
+
`;
|
|
5964
|
+
result += ` import.meta.hot.accept((mod) => {
|
|
5965
|
+
if (!mod.default) {
|
|
5966
|
+
__reactRouterDataRouter.revalidate();
|
|
5967
|
+
}
|
|
5968
|
+
});
|
|
5969
|
+
`;
|
|
5970
|
+
result += `}
|
|
5971
|
+
`;
|
|
5972
|
+
return {
|
|
5973
|
+
code: result
|
|
5974
|
+
};
|
|
5887
5975
|
}
|
|
5888
|
-
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5976
|
+
return {
|
|
5977
|
+
name: "react-router-rsc-virtual-route-modules",
|
|
5978
|
+
transform: {
|
|
5979
|
+
order: "pre",
|
|
5980
|
+
async handler(_code, id) {
|
|
5981
|
+
const [filename2, ...rest] = id.split("?");
|
|
5982
|
+
if (!isRouteModule(filename2)) {
|
|
5983
|
+
return;
|
|
5984
|
+
}
|
|
5985
|
+
let isClientEnvironment = clientEnvironments.has(this.environment.name);
|
|
5986
|
+
let isServerEnvironment = serverEnvironments.has(this.environment.name);
|
|
5987
|
+
if (!isClientEnvironment && !isServerEnvironment) {
|
|
5988
|
+
return;
|
|
5989
|
+
}
|
|
5990
|
+
let code = await transformToJs(_code, filename2);
|
|
5991
|
+
let searchParams = rest.length > 0 ? new URLSearchParams(rest.join("?")) : null;
|
|
5992
|
+
let clientRouteModuleType = searchParams?.get("client-route-module");
|
|
5993
|
+
let isServerRouteModule = searchParams?.has("server-route-module");
|
|
5994
|
+
if (clientRouteModuleType) {
|
|
5995
|
+
return await createClientRouteModuleChunk(
|
|
5996
|
+
id,
|
|
5997
|
+
code,
|
|
5998
|
+
clientRouteModuleType,
|
|
5999
|
+
isRootRouteModule(filename2)
|
|
6000
|
+
);
|
|
6001
|
+
}
|
|
6002
|
+
if (isServerRouteModule) {
|
|
6003
|
+
return createServerRouteModule(code);
|
|
6004
|
+
}
|
|
6005
|
+
if (isClientEnvironment) {
|
|
6006
|
+
return await createClientRouteEntry(id, code);
|
|
6007
|
+
}
|
|
6008
|
+
return await createServerRouteEntry(
|
|
6009
|
+
id,
|
|
6010
|
+
code,
|
|
6011
|
+
isRootRouteModule(filename2)
|
|
6012
|
+
);
|
|
6013
|
+
}
|
|
6014
|
+
}
|
|
6015
|
+
};
|
|
5893
6016
|
}
|
|
5894
|
-
function
|
|
6017
|
+
function createId(id, type, value) {
|
|
6018
|
+
let [base, ...rest] = id.split("?");
|
|
6019
|
+
const searchParams = new URLSearchParams(rest.join("?"));
|
|
6020
|
+
searchParams.delete("client-route-module");
|
|
6021
|
+
searchParams.delete("server-route-module");
|
|
6022
|
+
searchParams.set(type, value || "");
|
|
6023
|
+
return `${base}?${searchParams.toString()}`;
|
|
6024
|
+
}
|
|
6025
|
+
async function parseRouteExports(code) {
|
|
6026
|
+
await import_es_module_lexer2.init;
|
|
5895
6027
|
const [, exportSpecifiers] = (0, import_es_module_lexer2.parse)(code);
|
|
5896
6028
|
const staticExports = exportSpecifiers.map(({ n: name }) => name);
|
|
5897
|
-
const isServerFirstRoute = staticExports.some(
|
|
5898
|
-
(staticExport) => staticExport === "ServerComponent"
|
|
5899
|
-
);
|
|
5900
6029
|
return {
|
|
5901
6030
|
staticExports,
|
|
5902
|
-
|
|
5903
|
-
hasClientExports: staticExports.some(
|
|
5904
|
-
isServerFirstRoute ? isClientNonComponentExport : isClientRouteExport
|
|
5905
|
-
)
|
|
6031
|
+
hasClientExports: staticExports.some(isClientRouteExport)
|
|
5906
6032
|
};
|
|
5907
6033
|
}
|
|
5908
|
-
|
|
5909
|
-
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
|
|
6034
|
+
var CLIENT_NON_COMPONENT_EXPORTS2 = [
|
|
6035
|
+
"clientAction",
|
|
6036
|
+
"clientLoader",
|
|
6037
|
+
"clientMiddleware",
|
|
6038
|
+
"handle",
|
|
6039
|
+
"meta",
|
|
6040
|
+
"links",
|
|
6041
|
+
"shouldRevalidate"
|
|
6042
|
+
];
|
|
6043
|
+
var CLIENT_ROUTE_EXPORTS2 = [
|
|
6044
|
+
...CLIENT_NON_COMPONENT_EXPORTS2,
|
|
6045
|
+
"default",
|
|
6046
|
+
"ErrorBoundary",
|
|
6047
|
+
"HydrateFallback",
|
|
6048
|
+
"Layout"
|
|
6049
|
+
];
|
|
6050
|
+
var CLIENT_ROUTE_EXPORTS_SET = new Set(CLIENT_ROUTE_EXPORTS2);
|
|
6051
|
+
function isClientRouteExport(name) {
|
|
6052
|
+
return CLIENT_ROUTE_EXPORTS_SET.has(name);
|
|
5913
6053
|
}
|
|
5914
|
-
|
|
5915
|
-
|
|
6054
|
+
var SERVER_COMPONENT_EXPORTS = [
|
|
6055
|
+
"ServerComponent",
|
|
6056
|
+
"ServerLayout",
|
|
6057
|
+
"ServerHydrateFallback",
|
|
6058
|
+
"ServerErrorBoundary"
|
|
6059
|
+
];
|
|
6060
|
+
var SERVER_COMPONENT_EXPORTS_SET = new Set(SERVER_COMPONENT_EXPORTS);
|
|
6061
|
+
function isServerComponentExport(name) {
|
|
6062
|
+
return SERVER_COMPONENT_EXPORTS_SET.has(name);
|
|
5916
6063
|
}
|
|
5917
|
-
|
|
5918
|
-
|
|
6064
|
+
var SERVER_ROUTE_EXPORTS = [
|
|
6065
|
+
...SERVER_COMPONENT_EXPORTS,
|
|
6066
|
+
"loader",
|
|
6067
|
+
"action",
|
|
6068
|
+
"middleware",
|
|
6069
|
+
"headers"
|
|
6070
|
+
];
|
|
6071
|
+
var SERVER_ROUTE_EXPORTS_SET = new Set(SERVER_ROUTE_EXPORTS);
|
|
6072
|
+
function isServerRouteExport(name) {
|
|
6073
|
+
return SERVER_ROUTE_EXPORTS_SET.has(name);
|
|
5919
6074
|
}
|
|
5920
|
-
|
|
5921
|
-
|
|
6075
|
+
var CLIENT_MODULE_CHUNKS = /* @__PURE__ */ new Set([
|
|
6076
|
+
"clientAction",
|
|
6077
|
+
"clientLoader",
|
|
6078
|
+
"clientMiddleware",
|
|
6079
|
+
"HydrateFallback"
|
|
6080
|
+
]);
|
|
6081
|
+
var MUTUALLY_EXCLUSIVE_ROUTE_EXPORTS = /* @__PURE__ */ new Map([
|
|
6082
|
+
["ErrorBoundary", "ServerErrorBoundary"],
|
|
6083
|
+
["HydrateFallback", "ServerHydrateFallback"],
|
|
6084
|
+
["Layout", "ServerLayout"],
|
|
6085
|
+
["default", "ServerComponent"]
|
|
6086
|
+
]);
|
|
6087
|
+
function validateRouteModuleExports(toValidate) {
|
|
6088
|
+
let errors = [];
|
|
6089
|
+
for (let [clientExport, serverExport] of MUTUALLY_EXCLUSIVE_ROUTE_EXPORTS) {
|
|
6090
|
+
if (toValidate.includes(clientExport) && toValidate.includes(serverExport)) {
|
|
6091
|
+
errors.push([clientExport, serverExport]);
|
|
6092
|
+
}
|
|
6093
|
+
}
|
|
6094
|
+
if (errors.length > 0) {
|
|
6095
|
+
throw new Error(
|
|
6096
|
+
`Invalid route module exports. The following pairs of exports are mutually exclusive and cannot be exported from the same module:
|
|
6097
|
+
` + errors.map(
|
|
6098
|
+
([clientExport, serverExport]) => `- ${clientExport} and ${serverExport}`
|
|
6099
|
+
).join("\n")
|
|
6100
|
+
);
|
|
6101
|
+
}
|
|
5922
6102
|
}
|
|
5923
|
-
function
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
|
|
6103
|
+
function detectRouteChunks2(cache, id, code) {
|
|
6104
|
+
function noRouteChunks() {
|
|
6105
|
+
return {
|
|
6106
|
+
chunkedExports: [],
|
|
6107
|
+
hasRouteChunks: false,
|
|
6108
|
+
hasRouteChunkByExportName: {
|
|
6109
|
+
clientAction: false,
|
|
6110
|
+
clientLoader: false,
|
|
6111
|
+
clientMiddleware: false,
|
|
6112
|
+
HydrateFallback: false
|
|
6113
|
+
}
|
|
6114
|
+
};
|
|
6115
|
+
}
|
|
6116
|
+
if (!Array.from(CLIENT_MODULE_CHUNKS).some(
|
|
6117
|
+
(exportName) => code.includes(exportName)
|
|
6118
|
+
)) {
|
|
6119
|
+
return noRouteChunks();
|
|
6120
|
+
}
|
|
6121
|
+
let [filename2] = id.split("?");
|
|
6122
|
+
return detectRouteChunks(code, cache, filename2);
|
|
5929
6123
|
}
|
|
5930
6124
|
|
|
5931
6125
|
// vite/rsc/plugin.ts
|
|
6126
|
+
var redirectStatusCodes2 = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
|
|
6127
|
+
var configLoaderPromise;
|
|
6128
|
+
var typegenWatcherPromise;
|
|
5932
6129
|
function reactRouterRSCVitePlugin() {
|
|
5933
6130
|
let runningWithinTheReactRouterMonoRepo = Boolean(
|
|
5934
6131
|
arguments && arguments.length === 1 && typeof arguments[0] === "object" && arguments[0] && "__runningWithinTheReactRouterMonoRepo" in arguments[0] && arguments[0].__runningWithinTheReactRouterMonoRepo === true
|
|
5935
6132
|
);
|
|
5936
6133
|
let configLoader;
|
|
5937
|
-
let typegenWatcherPromise;
|
|
5938
6134
|
let viteCommand;
|
|
5939
6135
|
let resolvedViteConfig;
|
|
5940
6136
|
let routeIdByFile;
|
|
@@ -5949,6 +6145,25 @@ function reactRouterRSCVitePlugin() {
|
|
|
5949
6145
|
newConfig.routes.root.file
|
|
5950
6146
|
);
|
|
5951
6147
|
}
|
|
6148
|
+
function isRouteModule(id) {
|
|
6149
|
+
if (routeIdByFile?.has(id)) {
|
|
6150
|
+
return true;
|
|
6151
|
+
}
|
|
6152
|
+
return false;
|
|
6153
|
+
}
|
|
6154
|
+
function isRootRouteModule(id) {
|
|
6155
|
+
return import_pathe6.default.normalize(id) === import_pathe6.default.normalize(rootRouteFile);
|
|
6156
|
+
}
|
|
6157
|
+
async function transformToJs(code, filename2) {
|
|
6158
|
+
await preloadVite();
|
|
6159
|
+
let vite2 = getVite();
|
|
6160
|
+
return (await vite2.transformWithEsbuild(code, filename2, {
|
|
6161
|
+
target: "esnext",
|
|
6162
|
+
format: "esm",
|
|
6163
|
+
jsx: "automatic",
|
|
6164
|
+
jsxDev: viteCommand !== "build"
|
|
6165
|
+
})).code;
|
|
6166
|
+
}
|
|
5952
6167
|
return [
|
|
5953
6168
|
{
|
|
5954
6169
|
name: "react-router/rsc",
|
|
@@ -5957,24 +6172,21 @@ function reactRouterRSCVitePlugin() {
|
|
|
5957
6172
|
await preloadVite();
|
|
5958
6173
|
viteCommand = command;
|
|
5959
6174
|
const rootDirectory = getRootDirectory(viteUserConfig);
|
|
5960
|
-
const watch2 = command === "serve";
|
|
6175
|
+
const watch2 = command === "serve" && process.env.IS_RR_BUILD_REQUEST !== "yes";
|
|
5961
6176
|
await loadDotenv({
|
|
5962
6177
|
rootDirectory,
|
|
5963
6178
|
viteUserConfig,
|
|
5964
6179
|
mode
|
|
5965
6180
|
});
|
|
5966
|
-
|
|
6181
|
+
configLoaderPromise ??= createConfigLoader({
|
|
5967
6182
|
rootDirectory,
|
|
5968
6183
|
mode,
|
|
5969
6184
|
watch: watch2,
|
|
5970
6185
|
validateConfig: (userConfig) => {
|
|
5971
6186
|
let errors = [];
|
|
5972
6187
|
if (userConfig.buildEnd) errors.push("buildEnd");
|
|
5973
|
-
if (userConfig.prerender) errors.push("prerender");
|
|
5974
6188
|
if (userConfig.presets?.length) errors.push("presets");
|
|
5975
|
-
if (userConfig.routeDiscovery) errors.push("routeDiscovery");
|
|
5976
6189
|
if (userConfig.serverBundles) errors.push("serverBundles");
|
|
5977
|
-
if (userConfig.ssr === false) errors.push("ssr: false");
|
|
5978
6190
|
if (userConfig.future?.v8_middleware === false)
|
|
5979
6191
|
errors.push("future.v8_middleware: false");
|
|
5980
6192
|
if (userConfig.future?.v8_splitRouteModules)
|
|
@@ -5990,6 +6202,7 @@ ${errors.map((x) => ` - ${x}`).join("\n")}
|
|
|
5990
6202
|
}
|
|
5991
6203
|
}
|
|
5992
6204
|
});
|
|
6205
|
+
configLoader = await configLoaderPromise;
|
|
5993
6206
|
const configResult = await configLoader.getConfig();
|
|
5994
6207
|
if (!configResult.ok) throw new Error(configResult.error);
|
|
5995
6208
|
updateConfig(configResult.value);
|
|
@@ -6032,9 +6245,16 @@ ${errors.map((x) => ` - ${x}`).join("\n")}
|
|
|
6032
6245
|
entryClientFilePath: entries.client,
|
|
6033
6246
|
reactRouterConfig: config
|
|
6034
6247
|
}),
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6248
|
+
...defineOptimizeDepsCompilerOptions({
|
|
6249
|
+
rolldown: {
|
|
6250
|
+
transform: {
|
|
6251
|
+
jsx: "react-jsx"
|
|
6252
|
+
}
|
|
6253
|
+
},
|
|
6254
|
+
esbuild: {
|
|
6255
|
+
jsx: "automatic"
|
|
6256
|
+
}
|
|
6257
|
+
}),
|
|
6038
6258
|
include: [
|
|
6039
6259
|
// Pre-bundle React dependencies to avoid React duplicates,
|
|
6040
6260
|
// even if React dependencies are not direct dependencies.
|
|
@@ -6056,10 +6276,18 @@ ${errors.map((x) => ` - ${x}`).join("\n")}
|
|
|
6056
6276
|
"react-router > set-cookie-parser"
|
|
6057
6277
|
]
|
|
6058
6278
|
},
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
|
|
6062
|
-
|
|
6279
|
+
...defineCompilerOptions({
|
|
6280
|
+
oxc: {
|
|
6281
|
+
jsx: {
|
|
6282
|
+
runtime: "automatic",
|
|
6283
|
+
development: viteCommand !== "build"
|
|
6284
|
+
}
|
|
6285
|
+
},
|
|
6286
|
+
esbuild: {
|
|
6287
|
+
jsx: "automatic",
|
|
6288
|
+
jsxDev: viteCommand !== "build"
|
|
6289
|
+
}
|
|
6290
|
+
}),
|
|
6063
6291
|
environments: {
|
|
6064
6292
|
client: {
|
|
6065
6293
|
build: {
|
|
@@ -6125,27 +6353,6 @@ ${errors.map((x) => ` - ${x}`).join("\n")}
|
|
|
6125
6353
|
]
|
|
6126
6354
|
}
|
|
6127
6355
|
}
|
|
6128
|
-
},
|
|
6129
|
-
build: {
|
|
6130
|
-
rollupOptions: {
|
|
6131
|
-
// Copied from https://github.com/vitejs/vite-plugin-react/blob/c602225271d4acf462ba00f8d6d8a2e42492c5cd/packages/common/warning.ts
|
|
6132
|
-
onwarn(warning, defaultHandler) {
|
|
6133
|
-
if (warning.code === "MODULE_LEVEL_DIRECTIVE" && (warning.message.includes("use client") || warning.message.includes("use server"))) {
|
|
6134
|
-
return;
|
|
6135
|
-
}
|
|
6136
|
-
if (warning.code === "SOURCEMAP_ERROR" && warning.message.includes("resolve original location") && warning.pos === 0) {
|
|
6137
|
-
return;
|
|
6138
|
-
}
|
|
6139
|
-
if (viteUserConfig.build?.rollupOptions?.onwarn) {
|
|
6140
|
-
viteUserConfig.build.rollupOptions.onwarn(
|
|
6141
|
-
warning,
|
|
6142
|
-
defaultHandler
|
|
6143
|
-
);
|
|
6144
|
-
} else {
|
|
6145
|
-
defaultHandler(warning);
|
|
6146
|
-
}
|
|
6147
|
-
}
|
|
6148
|
-
}
|
|
6149
6356
|
}
|
|
6150
6357
|
};
|
|
6151
6358
|
},
|
|
@@ -6181,6 +6388,50 @@ ${errors.map((x) => ` - ${x}`).join("\n")}
|
|
|
6181
6388
|
}
|
|
6182
6389
|
);
|
|
6183
6390
|
},
|
|
6391
|
+
configurePreviewServer(previewServer) {
|
|
6392
|
+
const clientBuildDirectory = getClientBuildDirectory2(config);
|
|
6393
|
+
if ((config.prerender || config.ssr === false) && process.env.IS_RR_BUILD_REQUEST !== "yes") {
|
|
6394
|
+
previewServer.middlewares.use(async (req, res, next) => {
|
|
6395
|
+
try {
|
|
6396
|
+
const htmlFileBase = ((req.url || "/") + (req.url?.endsWith("/") ? "" : "/") + "index.html").slice(1);
|
|
6397
|
+
const htmlFilePath = import_pathe6.default.join(
|
|
6398
|
+
clientBuildDirectory,
|
|
6399
|
+
htmlFileBase
|
|
6400
|
+
);
|
|
6401
|
+
if ((0, import_fs.existsSync)(htmlFilePath)) {
|
|
6402
|
+
res.setHeader("Content-Type", "text/html");
|
|
6403
|
+
res.end(await (0, import_promises4.readFile)(htmlFilePath, "utf-8"));
|
|
6404
|
+
return;
|
|
6405
|
+
}
|
|
6406
|
+
next();
|
|
6407
|
+
} catch (error) {
|
|
6408
|
+
next(error);
|
|
6409
|
+
}
|
|
6410
|
+
});
|
|
6411
|
+
return () => {
|
|
6412
|
+
if (config.ssr === false) {
|
|
6413
|
+
previewServer.middlewares.use(async (req, res, next) => {
|
|
6414
|
+
try {
|
|
6415
|
+
res.statusCode = 404;
|
|
6416
|
+
const url2 = new URL(req.url || "/", `http://localhost`);
|
|
6417
|
+
const htmlFilePath = import_pathe6.default.join(
|
|
6418
|
+
clientBuildDirectory,
|
|
6419
|
+
url2.pathname.endsWith(".rsc") ? "__spa-fallback.rsc" : "__spa-fallback.html"
|
|
6420
|
+
);
|
|
6421
|
+
if ((0, import_fs.existsSync)(htmlFilePath)) {
|
|
6422
|
+
res.setHeader("Content-Type", "text/html");
|
|
6423
|
+
res.end(await (0, import_promises4.readFile)(htmlFilePath, "utf-8"));
|
|
6424
|
+
return;
|
|
6425
|
+
}
|
|
6426
|
+
res.end();
|
|
6427
|
+
} catch (error) {
|
|
6428
|
+
next(error);
|
|
6429
|
+
}
|
|
6430
|
+
});
|
|
6431
|
+
}
|
|
6432
|
+
};
|
|
6433
|
+
}
|
|
6434
|
+
},
|
|
6184
6435
|
async buildEnd() {
|
|
6185
6436
|
await configLoader.close();
|
|
6186
6437
|
}
|
|
@@ -6203,12 +6454,12 @@ ${errors.map((x) => ` - ${x}`).join("\n")}
|
|
|
6203
6454
|
configureServer: logExperimentalNotice
|
|
6204
6455
|
};
|
|
6205
6456
|
})(),
|
|
6206
|
-
{
|
|
6457
|
+
process.env.IS_RR_BUILD_REQUEST !== "yes" ? {
|
|
6207
6458
|
name: "react-router/rsc/typegen",
|
|
6208
6459
|
async config(viteUserConfig, { command, mode }) {
|
|
6209
6460
|
if (command === "serve") {
|
|
6210
6461
|
const vite2 = await import("vite");
|
|
6211
|
-
typegenWatcherPromise
|
|
6462
|
+
typegenWatcherPromise ??= watch(
|
|
6212
6463
|
getRootDirectory(viteUserConfig),
|
|
6213
6464
|
{
|
|
6214
6465
|
mode,
|
|
@@ -6225,7 +6476,7 @@ ${errors.map((x) => ` - ${x}`).join("\n")}
|
|
|
6225
6476
|
async buildEnd() {
|
|
6226
6477
|
(await typegenWatcherPromise)?.close();
|
|
6227
6478
|
}
|
|
6228
|
-
},
|
|
6479
|
+
} : null,
|
|
6229
6480
|
{
|
|
6230
6481
|
name: "react-router/rsc/virtual-route-config",
|
|
6231
6482
|
resolveId(id) {
|
|
@@ -6244,20 +6495,15 @@ ${errors.map((x) => ` - ${x}`).join("\n")}
|
|
|
6244
6495
|
}
|
|
6245
6496
|
}
|
|
6246
6497
|
},
|
|
6247
|
-
{
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
rootRouteFile,
|
|
6257
|
-
viteEnvironment: this.environment
|
|
6258
|
-
});
|
|
6259
|
-
}
|
|
6260
|
-
},
|
|
6498
|
+
virtualRouteModulesPlugin({
|
|
6499
|
+
environments: {
|
|
6500
|
+
client: ["client", "ssr"],
|
|
6501
|
+
server: ["rsc"]
|
|
6502
|
+
},
|
|
6503
|
+
isRouteModule,
|
|
6504
|
+
isRootRouteModule,
|
|
6505
|
+
transformToJs
|
|
6506
|
+
}),
|
|
6261
6507
|
{
|
|
6262
6508
|
name: "react-router/rsc/virtual-basename",
|
|
6263
6509
|
resolveId(id) {
|
|
@@ -6271,6 +6517,23 @@ ${errors.map((x) => ` - ${x}`).join("\n")}
|
|
|
6271
6517
|
}
|
|
6272
6518
|
}
|
|
6273
6519
|
},
|
|
6520
|
+
{
|
|
6521
|
+
name: "react-router/rsc/virtual-route-discovery",
|
|
6522
|
+
resolveId(id) {
|
|
6523
|
+
if (id === virtual2.routeDiscovery.id) {
|
|
6524
|
+
return virtual2.routeDiscovery.resolvedId;
|
|
6525
|
+
}
|
|
6526
|
+
},
|
|
6527
|
+
load(id) {
|
|
6528
|
+
if (id === virtual2.routeDiscovery.resolvedId) {
|
|
6529
|
+
return `export default ${JSON.stringify(
|
|
6530
|
+
config.ssr === false ? {
|
|
6531
|
+
mode: "initial"
|
|
6532
|
+
} : config.routeDiscovery ?? { mode: "lazy" }
|
|
6533
|
+
)};`;
|
|
6534
|
+
}
|
|
6535
|
+
}
|
|
6536
|
+
},
|
|
6274
6537
|
{
|
|
6275
6538
|
name: "react-router/rsc/hmr/inject-runtime",
|
|
6276
6539
|
enforce: "pre",
|
|
@@ -6282,121 +6545,129 @@ ${errors.map((x) => ` - ${x}`).join("\n")}
|
|
|
6282
6545
|
async load(id) {
|
|
6283
6546
|
if (id !== virtual2.injectHmrRuntime.resolvedId) return;
|
|
6284
6547
|
return viteCommand === "serve" ? [
|
|
6285
|
-
`import
|
|
6286
|
-
|
|
6287
|
-
|
|
6288
|
-
|
|
6289
|
-
|
|
6548
|
+
`if (import.meta.hot) {
|
|
6549
|
+
import.meta.hot.accept();
|
|
6550
|
+
import.meta.hot.on('rsc:update', () => {
|
|
6551
|
+
__reactRouterDataRouter.revalidate()
|
|
6552
|
+
})
|
|
6553
|
+
}`
|
|
6290
6554
|
].join("\n") : "";
|
|
6291
6555
|
}
|
|
6292
6556
|
},
|
|
6293
|
-
{
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
|
|
6301
|
-
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6312
|
-
|
|
6313
|
-
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
},
|
|
6319
|
-
{
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
},
|
|
6357
|
-
{
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6557
|
+
// {
|
|
6558
|
+
// name: "react-router/rsc/hmr/runtime",
|
|
6559
|
+
// enforce: "pre",
|
|
6560
|
+
// resolveId(id) {
|
|
6561
|
+
// if (id === virtual.hmrRuntime.id) return virtual.hmrRuntime.resolvedId;
|
|
6562
|
+
// },
|
|
6563
|
+
// async load(id) {
|
|
6564
|
+
// if (id !== virtual.hmrRuntime.resolvedId) return;
|
|
6565
|
+
// const reactRefreshDir = path.dirname(
|
|
6566
|
+
// require.resolve("react-refresh/package.json"),
|
|
6567
|
+
// );
|
|
6568
|
+
// const reactRefreshRuntimePath = join(
|
|
6569
|
+
// reactRefreshDir,
|
|
6570
|
+
// "cjs/react-refresh-runtime.development.js",
|
|
6571
|
+
// );
|
|
6572
|
+
// return [
|
|
6573
|
+
// "const exports = {}",
|
|
6574
|
+
// await readFile(reactRefreshRuntimePath, "utf8"),
|
|
6575
|
+
// await readFile(
|
|
6576
|
+
// require.resolve("./static/rsc-refresh-utils.mjs"),
|
|
6577
|
+
// "utf8",
|
|
6578
|
+
// ),
|
|
6579
|
+
// "export default exports",
|
|
6580
|
+
// ].join("\n");
|
|
6581
|
+
// },
|
|
6582
|
+
// },
|
|
6583
|
+
// {
|
|
6584
|
+
// name: "react-router/rsc/hmr/react-refresh",
|
|
6585
|
+
// async transform(code, id, options) {
|
|
6586
|
+
// if (viteCommand !== "serve") return;
|
|
6587
|
+
// if (id.includes("/node_modules/")) return;
|
|
6588
|
+
// const filepath = id.split("?")[0];
|
|
6589
|
+
// const extensionsRE = /\.(jsx?|tsx?|mdx?)$/;
|
|
6590
|
+
// if (!extensionsRE.test(filepath)) return;
|
|
6591
|
+
// const devRuntime = "react/jsx-dev-runtime";
|
|
6592
|
+
// const ssr = options?.ssr === true;
|
|
6593
|
+
// const isJSX = filepath.endsWith("x");
|
|
6594
|
+
// const useFastRefresh = !ssr && (isJSX || code.includes(devRuntime));
|
|
6595
|
+
// if (!useFastRefresh) return;
|
|
6596
|
+
// // if (isVirtualClientRouteModuleId(id)) {
|
|
6597
|
+
// // const routeId = routeIdByFile?.get(filepath);
|
|
6598
|
+
// // return { code: addRefreshWrapper({ routeId, code, id }) };
|
|
6599
|
+
// // }
|
|
6600
|
+
// const result = await babel.transformAsync(code, {
|
|
6601
|
+
// babelrc: false,
|
|
6602
|
+
// configFile: false,
|
|
6603
|
+
// filename: id,
|
|
6604
|
+
// sourceFileName: filepath,
|
|
6605
|
+
// parserOpts: {
|
|
6606
|
+
// sourceType: "module",
|
|
6607
|
+
// allowAwaitOutsideFunction: true,
|
|
6608
|
+
// },
|
|
6609
|
+
// plugins: [[require("react-refresh/babel"), { skipEnvCheck: true }]],
|
|
6610
|
+
// sourceMaps: true,
|
|
6611
|
+
// });
|
|
6612
|
+
// if (result === null) return;
|
|
6613
|
+
// code = result.code!;
|
|
6614
|
+
// const refreshContentRE = /\$Refresh(?:Reg|Sig)\$\(/;
|
|
6615
|
+
// if (refreshContentRE.test(code)) {
|
|
6616
|
+
// code = addRefreshWrapper({ code, id });
|
|
6617
|
+
// }
|
|
6618
|
+
// return { code, map: result.map };
|
|
6619
|
+
// },
|
|
6620
|
+
// },
|
|
6621
|
+
// {
|
|
6622
|
+
// name: "react-router/rsc/hmr/updates",
|
|
6623
|
+
// async hotUpdate(this, { server, file, modules }) {
|
|
6624
|
+
// if (this.environment.name !== "rsc") return;
|
|
6625
|
+
// const clientModules =
|
|
6626
|
+
// server.environments.client.moduleGraph.getModulesByFile(file);
|
|
6627
|
+
// const vite = await import("vite");
|
|
6628
|
+
// const isServerOnlyChange =
|
|
6629
|
+
// !clientModules ||
|
|
6630
|
+
// clientModules.size === 0 ||
|
|
6631
|
+
// // Handle CSS injected from server-first routes (with ?direct query
|
|
6632
|
+
// // string) since the client graph has a reference to the CSS
|
|
6633
|
+
// (vite.isCSSRequest(file) &&
|
|
6634
|
+
// Array.from(clientModules).some((mod) =>
|
|
6635
|
+
// mod.id?.includes("?direct"),
|
|
6636
|
+
// ));
|
|
6637
|
+
// for (const mod of getModulesWithImporters(modules)) {
|
|
6638
|
+
// if (!mod.file) continue;
|
|
6639
|
+
// const normalizedPath = path.normalize(mod.file);
|
|
6640
|
+
// const routeId = routeIdByFile?.get(normalizedPath);
|
|
6641
|
+
// if (routeId !== undefined) {
|
|
6642
|
+
// const routeSource = await readFile(normalizedPath, "utf8");
|
|
6643
|
+
// const virtualRouteModuleCode = (
|
|
6644
|
+
// await server.environments.rsc.pluginContainer.transform(
|
|
6645
|
+
// routeSource,
|
|
6646
|
+
// `${normalizedPath}?route-module`,
|
|
6647
|
+
// )
|
|
6648
|
+
// ).code;
|
|
6649
|
+
// const { staticExports } = parseRouteExports(virtualRouteModuleCode);
|
|
6650
|
+
// const hasAction = staticExports.includes("action");
|
|
6651
|
+
// const hasComponent = staticExports.includes("default");
|
|
6652
|
+
// const hasErrorBoundary = staticExports.includes("ErrorBoundary");
|
|
6653
|
+
// const hasLoader = staticExports.includes("loader");
|
|
6654
|
+
// server.hot.send({
|
|
6655
|
+
// type: "custom",
|
|
6656
|
+
// event: "react-router:hmr",
|
|
6657
|
+
// data: {
|
|
6658
|
+
// routeId,
|
|
6659
|
+
// isServerOnlyChange,
|
|
6660
|
+
// hasAction,
|
|
6661
|
+
// hasComponent,
|
|
6662
|
+
// hasErrorBoundary,
|
|
6663
|
+
// hasLoader,
|
|
6664
|
+
// },
|
|
6665
|
+
// });
|
|
6666
|
+
// }
|
|
6667
|
+
// }
|
|
6668
|
+
// return modules;
|
|
6669
|
+
// },
|
|
6670
|
+
// },
|
|
6400
6671
|
{
|
|
6401
6672
|
name: "react-router/rsc/virtual-react-router-serve-config",
|
|
6402
6673
|
resolveId(id) {
|
|
@@ -6420,13 +6691,107 @@ ${errors.map((x) => ` - ${x}`).join("\n")}
|
|
|
6420
6691
|
}
|
|
6421
6692
|
},
|
|
6422
6693
|
validatePluginOrder(),
|
|
6423
|
-
warnOnClientSourceMaps()
|
|
6694
|
+
warnOnClientSourceMaps(),
|
|
6695
|
+
prerender({
|
|
6696
|
+
config() {
|
|
6697
|
+
return {
|
|
6698
|
+
buildDirectory: getClientBuildDirectory2(config),
|
|
6699
|
+
concurrency: getPrerenderConcurrencyConfig2(config)
|
|
6700
|
+
};
|
|
6701
|
+
},
|
|
6702
|
+
logFile: (path10) => logger.info(`Prerendered ${import_picocolors5.default.bold(path10)}`),
|
|
6703
|
+
async requests() {
|
|
6704
|
+
const prerenderPaths = new Set(
|
|
6705
|
+
await getPrerenderPaths(
|
|
6706
|
+
config.prerender,
|
|
6707
|
+
config.ssr,
|
|
6708
|
+
config.routes,
|
|
6709
|
+
true
|
|
6710
|
+
)
|
|
6711
|
+
);
|
|
6712
|
+
let basename3 = !config.basename || config.basename === "/" ? "/" : config.basename.endsWith("/") ? config.basename : config.basename + "/";
|
|
6713
|
+
if (config.ssr === false) {
|
|
6714
|
+
prerenderPaths.add("/__spa-fallback.html");
|
|
6715
|
+
}
|
|
6716
|
+
return Array.from(prerenderPaths).map(
|
|
6717
|
+
(prerenderPath) => `http://localhost${basename3}${prerenderPath.slice(1)}`
|
|
6718
|
+
);
|
|
6719
|
+
},
|
|
6720
|
+
async postProcess(request, response, metadata) {
|
|
6721
|
+
let url2 = new URL(request.url);
|
|
6722
|
+
let isRedirect = redirectStatusCodes2.has(response.status);
|
|
6723
|
+
if (!isRedirect && response.status !== 200 && response.status !== 202 && !(url2.pathname === "/__spa-fallback.html" && response.status === 404)) {
|
|
6724
|
+
throw new Error(
|
|
6725
|
+
`Prerender (data): Received a ${response.status} status code from \`entry.server.tsx\` while prerendering the \`${url2.pathname}\` path.
|
|
6726
|
+
${url2.pathname}`,
|
|
6727
|
+
{ cause: response }
|
|
6728
|
+
);
|
|
6729
|
+
}
|
|
6730
|
+
if (metadata?.manifest) {
|
|
6731
|
+
return [
|
|
6732
|
+
{
|
|
6733
|
+
path: url2.pathname,
|
|
6734
|
+
contents: await response.text()
|
|
6735
|
+
}
|
|
6736
|
+
];
|
|
6737
|
+
}
|
|
6738
|
+
let isHtml = response.headers.get("content-type")?.includes("text/html");
|
|
6739
|
+
let htmlResponse = isHtml ? isRedirect ? response : response.clone() : null;
|
|
6740
|
+
let location = response.headers.get("Location");
|
|
6741
|
+
let delay = response.status === 302 ? 2 : 0;
|
|
6742
|
+
let redirectBody = isRedirect ? `<!doctype html>
|
|
6743
|
+
<head>
|
|
6744
|
+
<title>Redirecting to: ${location}</title>
|
|
6745
|
+
<meta http-equiv="refresh" content="${delay};url=${location}">
|
|
6746
|
+
<meta name="robots" content="noindex">
|
|
6747
|
+
</head>
|
|
6748
|
+
<body>
|
|
6749
|
+
<a href="${location}">
|
|
6750
|
+
Redirecting from <code>${url2.pathname}</code> to <code>${location}</code>
|
|
6751
|
+
</a>
|
|
6752
|
+
</body>
|
|
6753
|
+
</html>` : "";
|
|
6754
|
+
let files = [
|
|
6755
|
+
{
|
|
6756
|
+
path: isHtml || redirectBody ? url2.pathname === "/__spa-fallback.html" ? "__spa-fallback.html" : (url2.pathname.endsWith("/") ? url2.pathname : url2.pathname + "/") + "index.html" : url2.pathname,
|
|
6757
|
+
contents: redirectBody || (isHtml ? await response.text() : new Uint8Array(await response.arrayBuffer()))
|
|
6758
|
+
}
|
|
6759
|
+
];
|
|
6760
|
+
if (htmlResponse) {
|
|
6761
|
+
let body = await htmlResponse.text();
|
|
6762
|
+
let matches = Array.from(
|
|
6763
|
+
body.matchAll(
|
|
6764
|
+
/<script>\(self\.__FLIGHT_DATA\|\|=\[\]\)\.push\(("(?:[^"\\]|\\.)*")\)<\/script>/gim
|
|
6765
|
+
)
|
|
6766
|
+
);
|
|
6767
|
+
if (matches.length) {
|
|
6768
|
+
let rscData = "";
|
|
6769
|
+
for (const match of matches) {
|
|
6770
|
+
rscData += JSON.parse(match[1]);
|
|
6771
|
+
}
|
|
6772
|
+
files.push({
|
|
6773
|
+
path: url2.pathname === "/" ? "_.rsc" : (url2.pathname === "/__spa-fallback.html" ? "__spa-fallback" : url2.pathname) + ".rsc",
|
|
6774
|
+
contents: rscData
|
|
6775
|
+
});
|
|
6776
|
+
}
|
|
6777
|
+
} else if (!url2.pathname.endsWith(".rsc")) {
|
|
6778
|
+
let dataUrl = new URL(url2);
|
|
6779
|
+
dataUrl.pathname += ".rsc";
|
|
6780
|
+
return {
|
|
6781
|
+
files,
|
|
6782
|
+
requests: [dataUrl.href]
|
|
6783
|
+
};
|
|
6784
|
+
}
|
|
6785
|
+
return files;
|
|
6786
|
+
}
|
|
6787
|
+
})
|
|
6424
6788
|
];
|
|
6425
6789
|
}
|
|
6426
6790
|
var virtual2 = {
|
|
6427
6791
|
routeConfig: create("unstable_rsc/routes"),
|
|
6792
|
+
routeDiscovery: create("unstable_rsc/route-discovery"),
|
|
6428
6793
|
injectHmrRuntime: create("unstable_rsc/inject-hmr-runtime"),
|
|
6429
|
-
hmrRuntime: create("unstable_rsc/runtime"),
|
|
6794
|
+
// hmrRuntime: create("unstable_rsc/runtime"),
|
|
6430
6795
|
basename: create("unstable_rsc/basename"),
|
|
6431
6796
|
reactRouterServeConfig: create("unstable_rsc/react-router-serve-config")
|
|
6432
6797
|
};
|
|
@@ -6443,65 +6808,15 @@ function invalidateVirtualModules2(viteDevServer) {
|
|
|
6443
6808
|
function getRootDirectory(viteUserConfig) {
|
|
6444
6809
|
return viteUserConfig.root ?? process.env.REACT_ROUTER_ROOT ?? process.cwd();
|
|
6445
6810
|
}
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
result.add(module2);
|
|
6453
|
-
for (const importer of module2.importers) {
|
|
6454
|
-
walk(importer);
|
|
6455
|
-
}
|
|
6456
|
-
}
|
|
6457
|
-
for (const module2 of modules) {
|
|
6458
|
-
walk(module2);
|
|
6811
|
+
var getClientBuildDirectory2 = (reactRouterConfig) => import_pathe6.default.join(reactRouterConfig.buildDirectory, "client");
|
|
6812
|
+
function getPrerenderConcurrencyConfig2(reactRouterConfig) {
|
|
6813
|
+
let concurrency = 1;
|
|
6814
|
+
let { prerender: prerender2 } = reactRouterConfig;
|
|
6815
|
+
if (typeof prerender2 === "object" && "unstable_concurrency" in prerender2) {
|
|
6816
|
+
concurrency = prerender2.unstable_concurrency ?? 1;
|
|
6459
6817
|
}
|
|
6460
|
-
return
|
|
6461
|
-
}
|
|
6462
|
-
function addRefreshWrapper2({
|
|
6463
|
-
routeId,
|
|
6464
|
-
code,
|
|
6465
|
-
id
|
|
6466
|
-
}) {
|
|
6467
|
-
const acceptExports = routeId !== void 0 ? CLIENT_NON_COMPONENT_EXPORTS2 : [];
|
|
6468
|
-
return REACT_REFRESH_HEADER2.replaceAll("__SOURCE__", JSON.stringify(id)) + code + REACT_REFRESH_FOOTER2.replaceAll("__SOURCE__", JSON.stringify(id)).replaceAll("__ACCEPT_EXPORTS__", JSON.stringify(acceptExports)).replaceAll("__ROUTE_ID__", JSON.stringify(routeId));
|
|
6818
|
+
return concurrency;
|
|
6469
6819
|
}
|
|
6470
|
-
var REACT_REFRESH_HEADER2 = `
|
|
6471
|
-
import RefreshRuntime from "${virtual2.hmrRuntime.id}";
|
|
6472
|
-
|
|
6473
|
-
const inWebWorker = typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope;
|
|
6474
|
-
let prevRefreshReg;
|
|
6475
|
-
let prevRefreshSig;
|
|
6476
|
-
|
|
6477
|
-
if (import.meta.hot && !inWebWorker) {
|
|
6478
|
-
if (!window.__vite_plugin_react_preamble_installed__) {
|
|
6479
|
-
throw new Error(
|
|
6480
|
-
"React Router Vite plugin can't detect preamble. Something is wrong."
|
|
6481
|
-
);
|
|
6482
|
-
}
|
|
6483
|
-
|
|
6484
|
-
prevRefreshReg = window.$RefreshReg$;
|
|
6485
|
-
prevRefreshSig = window.$RefreshSig$;
|
|
6486
|
-
window.$RefreshReg$ = (type, id) => {
|
|
6487
|
-
RefreshRuntime.register(type, __SOURCE__ + " " + id)
|
|
6488
|
-
};
|
|
6489
|
-
window.$RefreshSig$ = RefreshRuntime.createSignatureFunctionForTransform;
|
|
6490
|
-
}`.replaceAll("\n", "");
|
|
6491
|
-
var REACT_REFRESH_FOOTER2 = `
|
|
6492
|
-
if (import.meta.hot && !inWebWorker) {
|
|
6493
|
-
window.$RefreshReg$ = prevRefreshReg;
|
|
6494
|
-
window.$RefreshSig$ = prevRefreshSig;
|
|
6495
|
-
RefreshRuntime.__hmr_import(import.meta.url).then((currentExports) => {
|
|
6496
|
-
RefreshRuntime.registerExportsForReactRefresh(__SOURCE__, currentExports);
|
|
6497
|
-
import.meta.hot.accept((nextExports) => {
|
|
6498
|
-
if (!nextExports) return;
|
|
6499
|
-
__ROUTE_ID__ && window.__reactRouterRouteModuleUpdates.set(__ROUTE_ID__, nextExports);
|
|
6500
|
-
const invalidateMessage = RefreshRuntime.validateRefreshBoundaryAndEnqueueUpdate(currentExports, nextExports, __ACCEPT_EXPORTS__);
|
|
6501
|
-
if (invalidateMessage) import.meta.hot.invalidate(invalidateMessage);
|
|
6502
|
-
});
|
|
6503
|
-
});
|
|
6504
|
-
}`;
|
|
6505
6820
|
// Annotate the CommonJS export names for ESM import in node:
|
|
6506
6821
|
0 && (module.exports = {
|
|
6507
6822
|
reactRouter,
|