@react-router/dev 0.0.0-experimental-759a11a62 → 0.0.0-experimental-df0f1dfda
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 +23 -0
- package/dist/cli/index.js +233 -244
- package/dist/config/defaults/entry.server.node.tsx +1 -1
- package/dist/config.d.ts +4 -0
- package/dist/config.js +1 -1
- package/dist/routes.js +1 -1
- package/dist/vite/cloudflare.js +1 -1
- package/dist/vite.js +1095 -190
- 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 +14 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# `@react-router/dev`
|
|
2
2
|
|
|
3
|
+
## 7.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix `reveal` and `routes` CLI commands ([#12745](https://github.com/remix-run/react-router/pull/12745))
|
|
8
|
+
- Updated dependencies:
|
|
9
|
+
- `react-router@7.1.3`
|
|
10
|
+
- `@react-router/node@7.1.3`
|
|
11
|
+
- `@react-router/serve@7.1.3`
|
|
12
|
+
|
|
13
|
+
## 7.1.2
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Fix default external conditions in Vite v6. This fixes resolution issues with certain npm packages. ([#12644](https://github.com/remix-run/react-router/pull/12644))
|
|
18
|
+
- Fix mismatch in prerendering html/data files when path is missing a leading slash ([#12684](https://github.com/remix-run/react-router/pull/12684))
|
|
19
|
+
- Use `module-sync` server condition when enabled in the runtime. This fixes React context mismatches (e.g. `useHref() may be used only in the context of a <Router> component.`) during development on Node 22.10.0+ when using libraries that have a peer dependency on React Router. ([#12729](https://github.com/remix-run/react-router/pull/12729))
|
|
20
|
+
- Fix react-refresh source maps ([#12686](https://github.com/remix-run/react-router/pull/12686))
|
|
21
|
+
- Updated dependencies:
|
|
22
|
+
- `react-router@7.1.2`
|
|
23
|
+
- `@react-router/node@7.1.2`
|
|
24
|
+
- `@react-router/serve@7.1.2`
|
|
25
|
+
|
|
3
26
|
## 7.1.1
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
package/dist/cli/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* @react-router/dev v0.0.0-experimental-
|
|
3
|
+
* @react-router/dev v0.0.0-experimental-df0f1dfda
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) Remix Software Inc.
|
|
6
6
|
*
|
|
@@ -389,7 +389,8 @@ async function resolveConfig({
|
|
|
389
389
|
);
|
|
390
390
|
}
|
|
391
391
|
let future = {
|
|
392
|
-
unstable_optimizeDeps: reactRouterUserConfig.future?.unstable_optimizeDeps ?? false
|
|
392
|
+
unstable_optimizeDeps: reactRouterUserConfig.future?.unstable_optimizeDeps ?? false,
|
|
393
|
+
unstable_splitRouteModules: reactRouterUserConfig.future?.unstable_splitRouteModules ?? false
|
|
393
394
|
};
|
|
394
395
|
let reactRouterConfig = deepFreeze({
|
|
395
396
|
appDirectory,
|
|
@@ -496,6 +497,15 @@ async function createConfigLoader({
|
|
|
496
497
|
}
|
|
497
498
|
};
|
|
498
499
|
}
|
|
500
|
+
async function loadConfig({ rootDirectory }) {
|
|
501
|
+
let configLoader = await createConfigLoader({
|
|
502
|
+
rootDirectory,
|
|
503
|
+
watch: false
|
|
504
|
+
});
|
|
505
|
+
let config = await configLoader.getConfig();
|
|
506
|
+
await configLoader.close();
|
|
507
|
+
return config;
|
|
508
|
+
}
|
|
499
509
|
function findEntry(dir, basename2, options) {
|
|
500
510
|
for (let ext of entryExts) {
|
|
501
511
|
let file = import_pathe3.default.resolve(dir, basename2 + ext);
|
|
@@ -586,46 +596,42 @@ var init_config = __esm({
|
|
|
586
596
|
}
|
|
587
597
|
});
|
|
588
598
|
|
|
589
|
-
//
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
// ${route.file}
|
|
594
|
-
|
|
595
|
-
import type { RouteExports, Routes } from "react-router/types";
|
|
596
|
-
|
|
597
|
-
type RouteId = "${route.id}"
|
|
598
|
-
export type Info = Routes[RouteId];
|
|
599
|
-
|
|
600
|
-
type Exports = RouteExports[RouteId];
|
|
601
|
-
|
|
602
|
-
export namespace Route {
|
|
603
|
-
export type LinkDescriptors = Exports["links"]["return"];
|
|
604
|
-
export type LinksFunction = () => LinkDescriptors;
|
|
605
|
-
|
|
606
|
-
export type MetaArgs = Exports["meta"]["args"];
|
|
607
|
-
export type MetaDescriptors = Exports["meta"]["return"];
|
|
608
|
-
export type MetaFunction = (args: MetaArgs) => MetaDescriptors;
|
|
609
|
-
|
|
610
|
-
export type HeadersArgs = Exports["headers"]["args"];
|
|
611
|
-
export type HeadersFunction = (args: HeadersArgs) => Headers | HeadersInit;
|
|
612
|
-
|
|
613
|
-
export type LoaderArgs = Exports["loader"]["args"];
|
|
614
|
-
export type ClientLoaderArgs = Exports["clientLoader"]["args"];
|
|
615
|
-
export type ActionArgs = Exports["action"]["args"];
|
|
616
|
-
export type ClientActionArgs = Exports["clientAction"]["args"];
|
|
617
|
-
|
|
618
|
-
export type HydrateFallbackProps = Exports["HydrateFallback"]["args"];
|
|
619
|
-
export type ComponentProps = Exports["default"]["args"];
|
|
620
|
-
export type ErrorBoundaryProps = Exports["ErrorBoundary"]["args"];
|
|
621
|
-
}
|
|
622
|
-
`;
|
|
623
|
-
}
|
|
624
|
-
var import_dedent;
|
|
625
|
-
var init_generate = __esm({
|
|
626
|
-
"typegen/generate.ts"() {
|
|
599
|
+
// vite/profiler.ts
|
|
600
|
+
var import_node_fs2, import_node_path, import_picocolors2, getSession, start, profileCount, stop;
|
|
601
|
+
var init_profiler = __esm({
|
|
602
|
+
"vite/profiler.ts"() {
|
|
627
603
|
"use strict";
|
|
628
|
-
|
|
604
|
+
import_node_fs2 = __toESM(require("fs"));
|
|
605
|
+
import_node_path = __toESM(require("path"));
|
|
606
|
+
import_picocolors2 = __toESM(require("picocolors"));
|
|
607
|
+
getSession = () => global.__reactRouter_profile_session;
|
|
608
|
+
start = async (callback) => {
|
|
609
|
+
let inspector = await import("inspector").then((r) => r.default);
|
|
610
|
+
let session = global.__reactRouter_profile_session = new inspector.Session();
|
|
611
|
+
session.connect();
|
|
612
|
+
session.post("Profiler.enable", () => {
|
|
613
|
+
session.post("Profiler.start", callback);
|
|
614
|
+
});
|
|
615
|
+
};
|
|
616
|
+
profileCount = 0;
|
|
617
|
+
stop = (log) => {
|
|
618
|
+
let session = getSession();
|
|
619
|
+
if (!session) return;
|
|
620
|
+
return new Promise((res, rej) => {
|
|
621
|
+
session.post("Profiler.stop", (err2, { profile }) => {
|
|
622
|
+
if (err2) return rej(err2);
|
|
623
|
+
let outPath = import_node_path.default.resolve(`./react-router-${profileCount++}.cpuprofile`);
|
|
624
|
+
import_node_fs2.default.writeFileSync(outPath, JSON.stringify(profile));
|
|
625
|
+
log(
|
|
626
|
+
import_picocolors2.default.yellow(
|
|
627
|
+
`CPU profile written to ${import_picocolors2.default.white(import_picocolors2.default.dim(outPath))}`
|
|
628
|
+
)
|
|
629
|
+
);
|
|
630
|
+
global.__reactRouter_profile_session = void 0;
|
|
631
|
+
res();
|
|
632
|
+
});
|
|
633
|
+
});
|
|
634
|
+
};
|
|
629
635
|
}
|
|
630
636
|
});
|
|
631
637
|
|
|
@@ -650,6 +656,119 @@ var init_paths = __esm({
|
|
|
650
656
|
}
|
|
651
657
|
});
|
|
652
658
|
|
|
659
|
+
// typegen/generate.ts
|
|
660
|
+
function generate(ctx, route) {
|
|
661
|
+
const lineage = getRouteLineage(ctx.config.routes, route);
|
|
662
|
+
const urlpath = lineage.map((route2) => route2.path).join("/");
|
|
663
|
+
const typesPath = getTypesPath(ctx, route);
|
|
664
|
+
const parents = lineage.slice(0, -1);
|
|
665
|
+
const parentTypeImports = parents.map((parent, i) => {
|
|
666
|
+
const rel = Path3.relative(
|
|
667
|
+
Path3.dirname(typesPath),
|
|
668
|
+
getTypesPath(ctx, parent)
|
|
669
|
+
);
|
|
670
|
+
const indent = i === 0 ? "" : " ".repeat(2);
|
|
671
|
+
let source = noExtension(rel);
|
|
672
|
+
if (!source.startsWith("../")) source = "./" + source;
|
|
673
|
+
return `${indent}import type { Info as Parent${i} } from "${source}.js"`;
|
|
674
|
+
}).join("\n");
|
|
675
|
+
return import_dedent.default`
|
|
676
|
+
// React Router generated types for route:
|
|
677
|
+
// ${route.file}
|
|
678
|
+
|
|
679
|
+
import type * as T from "react-router/route-module"
|
|
680
|
+
|
|
681
|
+
${parentTypeImports}
|
|
682
|
+
|
|
683
|
+
type Module = typeof import("../${Pathe2.filename(route.file)}.js")
|
|
684
|
+
|
|
685
|
+
export type Info = {
|
|
686
|
+
parents: [${parents.map((_, i) => `Parent${i}`).join(", ")}],
|
|
687
|
+
id: "${route.id}"
|
|
688
|
+
file: "${route.file}"
|
|
689
|
+
path: "${route.path}"
|
|
690
|
+
params: {${formatParamProperties(
|
|
691
|
+
urlpath
|
|
692
|
+
)}} & { [key: string]: string | undefined }
|
|
693
|
+
module: Module
|
|
694
|
+
loaderData: T.CreateLoaderData<Module>
|
|
695
|
+
actionData: T.CreateActionData<Module>
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
export namespace Route {
|
|
699
|
+
export type LinkDescriptors = T.LinkDescriptors
|
|
700
|
+
export type LinksFunction = () => LinkDescriptors
|
|
701
|
+
|
|
702
|
+
export type MetaArgs = T.CreateMetaArgs<Info>
|
|
703
|
+
export type MetaDescriptors = T.MetaDescriptors
|
|
704
|
+
export type MetaFunction = (args: MetaArgs) => MetaDescriptors
|
|
705
|
+
|
|
706
|
+
export type HeadersArgs = T.HeadersArgs
|
|
707
|
+
export type HeadersFunction = (args: HeadersArgs) => Headers | HeadersInit
|
|
708
|
+
|
|
709
|
+
export type LoaderArgs = T.CreateServerLoaderArgs<Info>
|
|
710
|
+
export type ClientLoaderArgs = T.CreateClientLoaderArgs<Info>
|
|
711
|
+
export type ActionArgs = T.CreateServerActionArgs<Info>
|
|
712
|
+
export type ClientActionArgs = T.CreateClientActionArgs<Info>
|
|
713
|
+
|
|
714
|
+
export type HydrateFallbackProps = T.CreateHydrateFallbackProps<Info>
|
|
715
|
+
export type ComponentProps = T.CreateComponentProps<Info>
|
|
716
|
+
export type ErrorBoundaryProps = T.CreateErrorBoundaryProps<Info>
|
|
717
|
+
}
|
|
718
|
+
`;
|
|
719
|
+
}
|
|
720
|
+
function getRouteLineage(routes2, route) {
|
|
721
|
+
const result = [];
|
|
722
|
+
while (route) {
|
|
723
|
+
result.push(route);
|
|
724
|
+
if (!route.parentId) break;
|
|
725
|
+
route = routes2[route.parentId];
|
|
726
|
+
}
|
|
727
|
+
result.reverse();
|
|
728
|
+
return result;
|
|
729
|
+
}
|
|
730
|
+
function formatParamProperties(urlpath) {
|
|
731
|
+
const params = parseParams(urlpath);
|
|
732
|
+
const properties = Object.entries(params).map(([name, values]) => {
|
|
733
|
+
if (values.length === 1) {
|
|
734
|
+
const isOptional = values[0];
|
|
735
|
+
return isOptional ? `"${name}"?: string` : `"${name}": string`;
|
|
736
|
+
}
|
|
737
|
+
const items = values.map(
|
|
738
|
+
(isOptional) => isOptional ? "string | undefined" : "string"
|
|
739
|
+
);
|
|
740
|
+
return `"${name}": [${items.join(", ")}]`;
|
|
741
|
+
});
|
|
742
|
+
return properties.join("; ");
|
|
743
|
+
}
|
|
744
|
+
function parseParams(urlpath) {
|
|
745
|
+
const result = {};
|
|
746
|
+
let segments = urlpath.split("/");
|
|
747
|
+
segments.forEach((segment) => {
|
|
748
|
+
const match = segment.match(/^:([\w-]+)(\?)?/);
|
|
749
|
+
if (!match) return;
|
|
750
|
+
const param = match[1];
|
|
751
|
+
const isOptional = match[2] !== void 0;
|
|
752
|
+
result[param] ??= [];
|
|
753
|
+
result[param].push(isOptional);
|
|
754
|
+
return;
|
|
755
|
+
});
|
|
756
|
+
const hasSplat = segments.at(-1) === "*";
|
|
757
|
+
if (hasSplat) result["*"] = [false];
|
|
758
|
+
return result;
|
|
759
|
+
}
|
|
760
|
+
var import_dedent, Path3, Pathe2, noExtension;
|
|
761
|
+
var init_generate = __esm({
|
|
762
|
+
"typegen/generate.ts"() {
|
|
763
|
+
"use strict";
|
|
764
|
+
import_dedent = __toESM(require("dedent"));
|
|
765
|
+
Path3 = __toESM(require("pathe"));
|
|
766
|
+
Pathe2 = __toESM(require("pathe/utils"));
|
|
767
|
+
init_paths();
|
|
768
|
+
noExtension = (path10) => Path3.join(Path3.dirname(path10), Pathe2.filename(path10));
|
|
769
|
+
}
|
|
770
|
+
});
|
|
771
|
+
|
|
653
772
|
// typegen/index.ts
|
|
654
773
|
async function run(rootDirectory) {
|
|
655
774
|
const ctx = await createContext2({ rootDirectory, watch: false });
|
|
@@ -658,16 +777,16 @@ async function run(rootDirectory) {
|
|
|
658
777
|
async function watch(rootDirectory, { logger } = {}) {
|
|
659
778
|
const ctx = await createContext2({ rootDirectory, watch: true });
|
|
660
779
|
await writeAll(ctx);
|
|
661
|
-
logger?.info(
|
|
780
|
+
logger?.info(import_picocolors3.default.green("generated types"), { timestamp: true, clear: true });
|
|
662
781
|
ctx.configLoader.onChange(async ({ result, routeConfigChanged }) => {
|
|
663
782
|
if (!result.ok) {
|
|
664
|
-
logger?.error(
|
|
783
|
+
logger?.error(import_picocolors3.default.red(result.error), { timestamp: true, clear: true });
|
|
665
784
|
return;
|
|
666
785
|
}
|
|
667
786
|
ctx.config = result.value;
|
|
668
787
|
if (routeConfigChanged) {
|
|
669
788
|
await writeAll(ctx);
|
|
670
|
-
logger?.info(
|
|
789
|
+
logger?.info(import_picocolors3.default.green("regenerated types"), {
|
|
671
790
|
timestamp: true,
|
|
672
791
|
clear: true
|
|
673
792
|
});
|
|
@@ -693,105 +812,23 @@ async function createContext2({
|
|
|
693
812
|
config
|
|
694
813
|
};
|
|
695
814
|
}
|
|
696
|
-
function asJS(path10) {
|
|
697
|
-
return path10.replace(/\.(js|ts)x?$/, ".js");
|
|
698
|
-
}
|
|
699
|
-
function formatRoute(ctx, { id, path: path10, file, parentId }) {
|
|
700
|
-
const modulePath = Path3.relative(
|
|
701
|
-
ctx.rootDirectory,
|
|
702
|
-
Path3.join(ctx.config.appDirectory, file)
|
|
703
|
-
);
|
|
704
|
-
return [
|
|
705
|
-
`"${id}": {`,
|
|
706
|
-
` parentId: ${JSON.stringify(parentId)}`,
|
|
707
|
-
` path: ${JSON.stringify(path10)}`,
|
|
708
|
-
` module: typeof import("${asJS(modulePath)}")`,
|
|
709
|
-
`}`
|
|
710
|
-
].map((line) => ` ${line}`).join("\n");
|
|
711
|
-
}
|
|
712
815
|
async function writeAll(ctx) {
|
|
713
|
-
let routes2 = Object.values(ctx.config.routes);
|
|
714
|
-
let pathsToParams = /* @__PURE__ */ new Map();
|
|
715
|
-
for (let route of routes2) {
|
|
716
|
-
if (route.path === void 0) continue;
|
|
717
|
-
let lineage = getRouteLineage(ctx.config.routes, route);
|
|
718
|
-
let path10 = lineage.filter((route2) => route2.path !== void 0).map((route2) => route2.path).join("/");
|
|
719
|
-
if (path10 === "") path10 = "/";
|
|
720
|
-
pathsToParams.set(path10, parseParams(path10));
|
|
721
|
-
}
|
|
722
|
-
let formattedPaths = `type Paths = {`;
|
|
723
|
-
for (let [path10, params] of pathsToParams.entries()) {
|
|
724
|
-
let formattedParams = Object.entries(params).map(
|
|
725
|
-
([param, required]) => `"${param}"${required ? "" : "?"}: string`
|
|
726
|
-
);
|
|
727
|
-
let formattedEntry = `"${path10}": {${formattedParams.join(",")}},
|
|
728
|
-
`;
|
|
729
|
-
formattedPaths += formattedEntry;
|
|
730
|
-
}
|
|
731
|
-
formattedPaths += `}`;
|
|
732
816
|
const typegenDir = getTypesDir(ctx);
|
|
733
|
-
|
|
734
|
-
const newTypes = Path3.join(typegenDir, "routes.ts");
|
|
735
|
-
import_node_fs2.default.mkdirSync(Path3.dirname(newTypes), { recursive: true });
|
|
736
|
-
import_node_fs2.default.writeFileSync(
|
|
737
|
-
newTypes,
|
|
738
|
-
formattedPaths + `
|
|
739
|
-
|
|
740
|
-
type Routes = {
|
|
741
|
-
${routes2.map((route) => formatRoute(ctx, route)).join("\n")}
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
` + import_dedent2.default`
|
|
745
|
-
declare module "react-router/types" {
|
|
746
|
-
interface Register {
|
|
747
|
-
paths: Paths
|
|
748
|
-
routes: Routes
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
export {}
|
|
753
|
-
`
|
|
754
|
-
);
|
|
817
|
+
import_node_fs3.default.rmSync(typegenDir, { recursive: true, force: true });
|
|
755
818
|
Object.values(ctx.config.routes).forEach((route) => {
|
|
756
819
|
const typesPath = getTypesPath(ctx, route);
|
|
757
|
-
const content = generate(route);
|
|
758
|
-
|
|
759
|
-
|
|
820
|
+
const content = generate(ctx, route);
|
|
821
|
+
import_node_fs3.default.mkdirSync(Path4.dirname(typesPath), { recursive: true });
|
|
822
|
+
import_node_fs3.default.writeFileSync(typesPath, content);
|
|
760
823
|
});
|
|
761
824
|
}
|
|
762
|
-
|
|
763
|
-
const result = [];
|
|
764
|
-
while (route) {
|
|
765
|
-
result.push(route);
|
|
766
|
-
if (!route.parentId) break;
|
|
767
|
-
route = routes2[route.parentId];
|
|
768
|
-
}
|
|
769
|
-
result.reverse();
|
|
770
|
-
return result;
|
|
771
|
-
}
|
|
772
|
-
function parseParams(urlpath) {
|
|
773
|
-
const result = {};
|
|
774
|
-
let segments = urlpath.split("/");
|
|
775
|
-
segments.forEach((segment) => {
|
|
776
|
-
const match = segment.match(/^:([\w-]+)(\?)?/);
|
|
777
|
-
if (!match) return;
|
|
778
|
-
const param = match[1];
|
|
779
|
-
const isRequired = match[2] === void 0;
|
|
780
|
-
result[param] ||= isRequired;
|
|
781
|
-
return;
|
|
782
|
-
});
|
|
783
|
-
const hasSplat = segments.at(-1) === "*";
|
|
784
|
-
if (hasSplat) result["*"] = true;
|
|
785
|
-
return result;
|
|
786
|
-
}
|
|
787
|
-
var import_node_fs2, import_dedent2, Path3, import_picocolors2;
|
|
825
|
+
var import_node_fs3, Path4, import_picocolors3;
|
|
788
826
|
var init_typegen = __esm({
|
|
789
827
|
"typegen/index.ts"() {
|
|
790
828
|
"use strict";
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
import_picocolors2 = __toESM(require("picocolors"));
|
|
829
|
+
import_node_fs3 = __toESM(require("fs"));
|
|
830
|
+
Path4 = __toESM(require("pathe"));
|
|
831
|
+
import_picocolors3 = __toESM(require("picocolors"));
|
|
795
832
|
init_config();
|
|
796
833
|
init_generate();
|
|
797
834
|
init_paths();
|
|
@@ -824,21 +861,21 @@ var init_node_adapter = __esm({
|
|
|
824
861
|
});
|
|
825
862
|
|
|
826
863
|
// vite/resolve-file-url.ts
|
|
827
|
-
var
|
|
864
|
+
var path5;
|
|
828
865
|
var init_resolve_file_url = __esm({
|
|
829
866
|
"vite/resolve-file-url.ts"() {
|
|
830
867
|
"use strict";
|
|
831
|
-
|
|
868
|
+
path5 = __toESM(require("path"));
|
|
832
869
|
init_vite();
|
|
833
870
|
}
|
|
834
871
|
});
|
|
835
872
|
|
|
836
873
|
// vite/styles.ts
|
|
837
|
-
var
|
|
874
|
+
var path6, import_react_router, cssFileRegExp, cssModulesRegExp;
|
|
838
875
|
var init_styles = __esm({
|
|
839
876
|
"vite/styles.ts"() {
|
|
840
877
|
"use strict";
|
|
841
|
-
|
|
878
|
+
path6 = __toESM(require("path"));
|
|
842
879
|
import_react_router = require("react-router");
|
|
843
880
|
init_resolve_file_url();
|
|
844
881
|
init_vite();
|
|
@@ -879,12 +916,43 @@ var init_remove_exports = __esm({
|
|
|
879
916
|
}
|
|
880
917
|
});
|
|
881
918
|
|
|
919
|
+
// vite/cache.ts
|
|
920
|
+
var init_cache = __esm({
|
|
921
|
+
"vite/cache.ts"() {
|
|
922
|
+
"use strict";
|
|
923
|
+
}
|
|
924
|
+
});
|
|
925
|
+
|
|
926
|
+
// vite/route-chunks.ts
|
|
927
|
+
var routeChunkExportNames, routeChunkNames, routeChunkQueryStringPrefix, routeChunkQueryStrings;
|
|
928
|
+
var init_route_chunks = __esm({
|
|
929
|
+
"vite/route-chunks.ts"() {
|
|
930
|
+
"use strict";
|
|
931
|
+
init_invariant();
|
|
932
|
+
init_cache();
|
|
933
|
+
init_babel();
|
|
934
|
+
routeChunkExportNames = [
|
|
935
|
+
"clientAction",
|
|
936
|
+
"clientLoader",
|
|
937
|
+
"HydrateFallback"
|
|
938
|
+
];
|
|
939
|
+
routeChunkNames = ["main", ...routeChunkExportNames];
|
|
940
|
+
routeChunkQueryStringPrefix = "?route-chunk=";
|
|
941
|
+
routeChunkQueryStrings = {
|
|
942
|
+
main: `${routeChunkQueryStringPrefix}main`,
|
|
943
|
+
clientAction: `${routeChunkQueryStringPrefix}clientAction`,
|
|
944
|
+
clientLoader: `${routeChunkQueryStringPrefix}clientLoader`,
|
|
945
|
+
HydrateFallback: `${routeChunkQueryStringPrefix}HydrateFallback`
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
});
|
|
949
|
+
|
|
882
950
|
// vite/with-props.ts
|
|
883
|
-
var
|
|
951
|
+
var import_dedent2, vmod;
|
|
884
952
|
var init_with_props = __esm({
|
|
885
953
|
"vite/with-props.ts"() {
|
|
886
954
|
"use strict";
|
|
887
|
-
|
|
955
|
+
import_dedent2 = __toESM(require("dedent"));
|
|
888
956
|
init_babel();
|
|
889
957
|
init_virtual_module();
|
|
890
958
|
vmod = create("with-props");
|
|
@@ -915,56 +983,19 @@ async function resolveViteConfig({
|
|
|
915
983
|
async function extractPluginContext(viteConfig) {
|
|
916
984
|
return viteConfig["__reactRouterPluginContext"];
|
|
917
985
|
}
|
|
918
|
-
|
|
919
|
-
configFile,
|
|
920
|
-
root
|
|
921
|
-
}) {
|
|
922
|
-
if (!root) {
|
|
923
|
-
root = process.env.REACT_ROUTER_ROOT || process.cwd();
|
|
924
|
-
}
|
|
925
|
-
configFile = configFile ?? findConfig(root, "vite.config", [
|
|
926
|
-
".ts",
|
|
927
|
-
".cts",
|
|
928
|
-
".mts",
|
|
929
|
-
".js",
|
|
930
|
-
".cjs",
|
|
931
|
-
".mjs"
|
|
932
|
-
]);
|
|
933
|
-
if (!configFile) {
|
|
934
|
-
console.error(import_picocolors3.default.red("Vite config file not found"));
|
|
935
|
-
process.exit(1);
|
|
936
|
-
}
|
|
937
|
-
let viteConfig = await resolveViteConfig({ configFile, root });
|
|
938
|
-
let ctx = await extractPluginContext(viteConfig);
|
|
939
|
-
if (!ctx) {
|
|
940
|
-
console.error(
|
|
941
|
-
import_picocolors3.default.red("React Router Vite plugin not found in Vite config")
|
|
942
|
-
);
|
|
943
|
-
process.exit(1);
|
|
944
|
-
}
|
|
945
|
-
return ctx;
|
|
946
|
-
}
|
|
947
|
-
function findConfig(dir, basename2, extensions) {
|
|
948
|
-
for (let ext of extensions) {
|
|
949
|
-
let name = basename2 + ext;
|
|
950
|
-
let file = path6.join(dir, name);
|
|
951
|
-
if (fse.existsSync(file)) return file;
|
|
952
|
-
}
|
|
953
|
-
return void 0;
|
|
954
|
-
}
|
|
955
|
-
var import_node_crypto, path6, url, fse, babel, import_react_router2, import_es_module_lexer, import_jsesc, import_picocolors3, virtualHmrRuntime, virtualInjectHmrRuntime, virtual, getServerBuildDirectory, defaultEntriesDir, defaultEntries, REACT_REFRESH_HEADER;
|
|
986
|
+
var import_node_crypto, path7, url, fse, babel2, import_react_router2, import_es_module_lexer, import_jsesc, import_picocolors4, virtualHmrRuntime, virtualInjectHmrRuntime, virtual, getServerBuildDirectory, defaultEntriesDir, defaultEntries, REACT_REFRESH_HEADER;
|
|
956
987
|
var init_plugin = __esm({
|
|
957
988
|
"vite/plugin.ts"() {
|
|
958
989
|
"use strict";
|
|
959
990
|
import_node_crypto = require("crypto");
|
|
960
|
-
|
|
991
|
+
path7 = __toESM(require("path"));
|
|
961
992
|
url = __toESM(require("url"));
|
|
962
993
|
fse = __toESM(require("fs-extra"));
|
|
963
|
-
|
|
994
|
+
babel2 = __toESM(require("@babel/core"));
|
|
964
995
|
import_react_router2 = require("react-router");
|
|
965
996
|
import_es_module_lexer = require("es-module-lexer");
|
|
966
997
|
import_jsesc = __toESM(require("jsesc"));
|
|
967
|
-
|
|
998
|
+
import_picocolors4 = __toESM(require("picocolors"));
|
|
968
999
|
init_typegen();
|
|
969
1000
|
init_invariant();
|
|
970
1001
|
init_babel();
|
|
@@ -974,6 +1005,7 @@ var init_plugin = __esm({
|
|
|
974
1005
|
init_resolve_file_url();
|
|
975
1006
|
init_combine_urls();
|
|
976
1007
|
init_remove_exports();
|
|
1008
|
+
init_route_chunks();
|
|
977
1009
|
init_vite();
|
|
978
1010
|
init_config();
|
|
979
1011
|
init_with_props();
|
|
@@ -984,18 +1016,18 @@ var init_plugin = __esm({
|
|
|
984
1016
|
serverManifest: create("server-manifest"),
|
|
985
1017
|
browserManifest: create("browser-manifest")
|
|
986
1018
|
};
|
|
987
|
-
getServerBuildDirectory = (ctx) =>
|
|
1019
|
+
getServerBuildDirectory = (ctx) => path7.join(
|
|
988
1020
|
ctx.reactRouterConfig.buildDirectory,
|
|
989
1021
|
"server",
|
|
990
1022
|
...ctx.serverBundleBuildConfig ? [ctx.serverBundleBuildConfig.serverBundleId] : []
|
|
991
1023
|
);
|
|
992
|
-
defaultEntriesDir =
|
|
993
|
-
|
|
1024
|
+
defaultEntriesDir = path7.resolve(
|
|
1025
|
+
path7.dirname(require.resolve("@react-router/dev/package.json")),
|
|
994
1026
|
"dist",
|
|
995
1027
|
"config",
|
|
996
1028
|
"defaults"
|
|
997
1029
|
);
|
|
998
|
-
defaultEntries = fse.readdirSync(defaultEntriesDir).map((
|
|
1030
|
+
defaultEntries = fse.readdirSync(defaultEntriesDir).map((filename3) => path7.join(defaultEntriesDir, filename3));
|
|
999
1031
|
invariant(defaultEntries.length > 0, "No default entries found");
|
|
1000
1032
|
REACT_REFRESH_HEADER = `
|
|
1001
1033
|
import RefreshRuntime from "${virtualHmrRuntime.id}";
|
|
@@ -1021,45 +1053,6 @@ if (import.meta.hot && !inWebWorker) {
|
|
|
1021
1053
|
}
|
|
1022
1054
|
});
|
|
1023
1055
|
|
|
1024
|
-
// vite/profiler.ts
|
|
1025
|
-
var import_node_fs3, import_node_path, import_picocolors4, getSession, start, profileCount, stop;
|
|
1026
|
-
var init_profiler = __esm({
|
|
1027
|
-
"vite/profiler.ts"() {
|
|
1028
|
-
"use strict";
|
|
1029
|
-
import_node_fs3 = __toESM(require("fs"));
|
|
1030
|
-
import_node_path = __toESM(require("path"));
|
|
1031
|
-
import_picocolors4 = __toESM(require("picocolors"));
|
|
1032
|
-
getSession = () => global.__reactRouter_profile_session;
|
|
1033
|
-
start = async (callback) => {
|
|
1034
|
-
let inspector = await import("inspector").then((r) => r.default);
|
|
1035
|
-
let session = global.__reactRouter_profile_session = new inspector.Session();
|
|
1036
|
-
session.connect();
|
|
1037
|
-
session.post("Profiler.enable", () => {
|
|
1038
|
-
session.post("Profiler.start", callback);
|
|
1039
|
-
});
|
|
1040
|
-
};
|
|
1041
|
-
profileCount = 0;
|
|
1042
|
-
stop = (log) => {
|
|
1043
|
-
let session = getSession();
|
|
1044
|
-
if (!session) return;
|
|
1045
|
-
return new Promise((res, rej) => {
|
|
1046
|
-
session.post("Profiler.stop", (err2, { profile }) => {
|
|
1047
|
-
if (err2) return rej(err2);
|
|
1048
|
-
let outPath = import_node_path.default.resolve(`./react-router-${profileCount++}.cpuprofile`);
|
|
1049
|
-
import_node_fs3.default.writeFileSync(outPath, JSON.stringify(profile));
|
|
1050
|
-
log(
|
|
1051
|
-
import_picocolors4.default.yellow(
|
|
1052
|
-
`CPU profile written to ${import_picocolors4.default.white(import_picocolors4.default.dim(outPath))}`
|
|
1053
|
-
)
|
|
1054
|
-
);
|
|
1055
|
-
global.__reactRouter_profile_session = void 0;
|
|
1056
|
-
res();
|
|
1057
|
-
});
|
|
1058
|
-
});
|
|
1059
|
-
};
|
|
1060
|
-
}
|
|
1061
|
-
});
|
|
1062
|
-
|
|
1063
1056
|
// vite/build.ts
|
|
1064
1057
|
var build_exports = {};
|
|
1065
1058
|
__export(build_exports, {
|
|
@@ -1359,6 +1352,8 @@ var import_fs_extra2 = __toESM(require("fs-extra"));
|
|
|
1359
1352
|
var import_package_json2 = __toESM(require("@npmcli/package-json"));
|
|
1360
1353
|
var import_exit_hook = __toESM(require("exit-hook"));
|
|
1361
1354
|
var import_picocolors7 = __toESM(require("picocolors"));
|
|
1355
|
+
var import_react_router3 = require("react-router");
|
|
1356
|
+
init_config();
|
|
1362
1357
|
|
|
1363
1358
|
// config/format.ts
|
|
1364
1359
|
function formatRoutes(routeManifest, format) {
|
|
@@ -1416,16 +1411,13 @@ function formatRoutesAsJsx(routeManifest) {
|
|
|
1416
1411
|
return output;
|
|
1417
1412
|
}
|
|
1418
1413
|
|
|
1419
|
-
// cli/commands.ts
|
|
1420
|
-
init_plugin();
|
|
1421
|
-
|
|
1422
1414
|
// cli/useJavascript.ts
|
|
1423
|
-
var
|
|
1415
|
+
var babel = __toESM(require("@babel/core"));
|
|
1424
1416
|
var import_plugin_syntax_jsx = __toESM(require("@babel/plugin-syntax-jsx"));
|
|
1425
1417
|
var import_preset_typescript = __toESM(require("@babel/preset-typescript"));
|
|
1426
1418
|
var import_prettier = __toESM(require("prettier"));
|
|
1427
1419
|
function transpile(tsx, options = {}) {
|
|
1428
|
-
let mjs =
|
|
1420
|
+
let mjs = babel.transformSync(tsx, {
|
|
1429
1421
|
compact: false,
|
|
1430
1422
|
cwd: options.cwd,
|
|
1431
1423
|
filename: options.filename,
|
|
@@ -1442,18 +1434,14 @@ init_profiler();
|
|
|
1442
1434
|
init_typegen();
|
|
1443
1435
|
init_vite();
|
|
1444
1436
|
async function routes(reactRouterRoot, flags = {}) {
|
|
1445
|
-
let
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
if (!ctx) {
|
|
1450
|
-
console.error(
|
|
1451
|
-
import_picocolors7.default.red("React Router Vite plugin not found in Vite config")
|
|
1452
|
-
);
|
|
1437
|
+
let rootDirectory = reactRouterRoot ?? process.cwd();
|
|
1438
|
+
let configResult = await loadConfig({ rootDirectory });
|
|
1439
|
+
if (!configResult.ok) {
|
|
1440
|
+
console.error(import_picocolors7.default.red(configResult.error));
|
|
1453
1441
|
process.exit(1);
|
|
1454
1442
|
}
|
|
1455
1443
|
let format = flags.json ? "json" : "jsx";
|
|
1456
|
-
console.log(formatRoutes(
|
|
1444
|
+
console.log(formatRoutes(configResult.value.routes, format));
|
|
1457
1445
|
}
|
|
1458
1446
|
async function build2(root, options = {}) {
|
|
1459
1447
|
if (!root) {
|
|
@@ -1487,17 +1475,18 @@ var conjunctionListFormat = new Intl.ListFormat("en", {
|
|
|
1487
1475
|
type: "conjunction"
|
|
1488
1476
|
});
|
|
1489
1477
|
async function generateEntry(entry, reactRouterRoot, flags = {}) {
|
|
1490
|
-
let ctx = await loadPluginContext({
|
|
1491
|
-
root: reactRouterRoot,
|
|
1492
|
-
configFile: flags.config
|
|
1493
|
-
});
|
|
1494
|
-
let rootDirectory = ctx.rootDirectory;
|
|
1495
|
-
let appDirectory = ctx.reactRouterConfig.appDirectory;
|
|
1496
1478
|
if (!entry) {
|
|
1497
1479
|
await generateEntry("entry.client", reactRouterRoot, flags);
|
|
1498
1480
|
await generateEntry("entry.server", reactRouterRoot, flags);
|
|
1499
1481
|
return;
|
|
1500
1482
|
}
|
|
1483
|
+
let rootDirectory = reactRouterRoot ?? process.cwd();
|
|
1484
|
+
let configResult = await loadConfig({ rootDirectory });
|
|
1485
|
+
if (!configResult.ok) {
|
|
1486
|
+
console.error(import_picocolors7.default.red(configResult.error));
|
|
1487
|
+
return;
|
|
1488
|
+
}
|
|
1489
|
+
let appDirectory = configResult.value.appDirectory;
|
|
1501
1490
|
if (!entries.includes(entry)) {
|
|
1502
1491
|
let entriesArray = Array.from(entries);
|
|
1503
1492
|
let list = conjunctionListFormat.format(entriesArray);
|
|
@@ -61,7 +61,7 @@ export default function handleRequest(
|
|
|
61
61
|
}
|
|
62
62
|
);
|
|
63
63
|
|
|
64
|
-
// Abort the rendering stream after the `streamTimeout` so it has
|
|
64
|
+
// Abort the rendering stream after the `streamTimeout` so it has time to
|
|
65
65
|
// flush down the rejected boundaries
|
|
66
66
|
setTimeout(abort, streamTimeout + 1000);
|
|
67
67
|
});
|