@react-router/dev 0.0.0-experimental-89dc2043e → 0.0.0-experimental-6844c5934
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 +48 -0
- package/bin.js +13 -0
- package/dist/cli/index.js +177 -107
- package/dist/config/defaults/entry.server.node.tsx +5 -7
- package/dist/config.js +1 -1
- package/dist/routes.js +1 -1
- package/dist/vite/cloudflare.js +1 -1
- package/dist/vite.js +209 -151
- package/package.json +11 -11
- package/dist/cli/dev.d.ts +0 -22
- package/dist/cli/dev.js +0 -155
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,57 @@
|
|
|
1
1
|
# `@react-router/dev`
|
|
2
2
|
|
|
3
|
+
## 7.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix for a crash when optional args are passed to the CLI ([`5b1ca202f`](https://github.com/remix-run/react-router/commit/5b1ca202f77ef342db0109c6b791d33188077cd0))
|
|
8
|
+
- Updated dependencies:
|
|
9
|
+
- `react-router@7.1.1`
|
|
10
|
+
- `@react-router/node@7.1.1`
|
|
11
|
+
- `@react-router/serve@7.1.1`
|
|
12
|
+
|
|
13
|
+
## 7.1.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- Add support for Vite v6 ([#12469](https://github.com/remix-run/react-router/pull/12469))
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Properly initialize `NODE_ENV` if not already set for compatibility with React 19 ([#12578](https://github.com/remix-run/react-router/pull/12578))
|
|
22
|
+
|
|
23
|
+
- Remove the leftover/unused `abortDelay` prop from `ServerRouter` and update the default `entry.server.tsx` to use the new `streamTimeout` value for Single Fetch ([#12478](https://github.com/remix-run/react-router/pull/12478))
|
|
24
|
+
|
|
25
|
+
- The `abortDelay` functionality was removed in v7 as it was coupled to the `defer` implementation from Remix v2, but this removal of this prop was missed
|
|
26
|
+
- If you were still using this prop in your `entry.server` file, it's likely your app is not aborting streams as you would expect and you will need to adopt the new [`streamTimeout`](https://reactrouter.com/explanation/special-files#streamtimeout) value introduced with Single Fetch
|
|
27
|
+
|
|
28
|
+
- Updated dependencies:
|
|
29
|
+
- `react-router@7.1.0`
|
|
30
|
+
- `@react-router/node@7.1.0`
|
|
31
|
+
- `@react-router/serve@7.1.0`
|
|
32
|
+
|
|
33
|
+
## 7.0.2
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- Support `moduleResolution` `Node16` and `NodeNext` ([#12440](https://github.com/remix-run/react-router/pull/12440))
|
|
38
|
+
|
|
39
|
+
- Generate wide `matches` and `params` types for current route and child routes ([#12397](https://github.com/remix-run/react-router/pull/12397))
|
|
40
|
+
|
|
41
|
+
At runtime, `matches` includes child route matches and `params` include child route path parameters.
|
|
42
|
+
But previously, we only generated types for parent routes in `matches`; for `params`, we only considered the parent routes and the current route.
|
|
43
|
+
To align our generated types more closely to the runtime behavior, we now generate more permissive, wider types when accessing child route information.
|
|
44
|
+
|
|
45
|
+
- Updated dependencies:
|
|
46
|
+
- `react-router@7.0.2`
|
|
47
|
+
- `@react-router/node@7.0.2`
|
|
48
|
+
- `@react-router/serve@7.0.2`
|
|
49
|
+
|
|
3
50
|
## 7.0.1
|
|
4
51
|
|
|
5
52
|
### Patch Changes
|
|
6
53
|
|
|
54
|
+
- Pass route error to ErrorBoundary as a prop ([#12338](https://github.com/remix-run/react-router/pull/12338))
|
|
7
55
|
- Ensure typegen file watcher is cleaned up when Vite dev server restarts ([#12331](https://github.com/remix-run/react-router/pull/12331))
|
|
8
56
|
- Updated dependencies:
|
|
9
57
|
- `react-router@7.0.1`
|
package/bin.js
CHANGED
|
@@ -1,2 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
let arg = require("arg");
|
|
3
|
+
|
|
4
|
+
// Minimal replication of our actual parsing in `run.ts`. If not already set,
|
|
5
|
+
// default `NODE_ENV` so React loads the proper version in it's CJS entry script.
|
|
6
|
+
// We have to do this before importing `run.ts` since that is what imports
|
|
7
|
+
// `react` (indirectly via `react-router`)
|
|
8
|
+
let args = arg({}, { argv: process.argv.slice(2), stopAtPositional: true });
|
|
9
|
+
if (args._[0] === "dev") {
|
|
10
|
+
process.env.NODE_ENV = process.env.NODE_ENV ?? "development";
|
|
11
|
+
} else {
|
|
12
|
+
process.env.NODE_ENV = process.env.NODE_ENV ?? "production";
|
|
13
|
+
}
|
|
14
|
+
|
|
2
15
|
require("./dist/cli/index");
|
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-6844c5934
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) Remix Software Inc.
|
|
6
6
|
*
|
|
@@ -100,11 +100,11 @@ async function createContext(viteConfig = {}) {
|
|
|
100
100
|
const runner = new import_client.ViteNodeRunner({
|
|
101
101
|
root: devServer.config.root,
|
|
102
102
|
base: devServer.config.base,
|
|
103
|
-
fetchModule(
|
|
104
|
-
return server.fetchModule(
|
|
103
|
+
fetchModule(id) {
|
|
104
|
+
return server.fetchModule(id);
|
|
105
105
|
},
|
|
106
|
-
resolveId(
|
|
107
|
-
return server.resolveId(
|
|
106
|
+
resolveId(id, importer) {
|
|
107
|
+
return server.resolveId(id, importer);
|
|
108
108
|
}
|
|
109
109
|
});
|
|
110
110
|
return { devServer, server, runner };
|
|
@@ -160,24 +160,24 @@ ${message}`
|
|
|
160
160
|
function configRoutesToRouteManifest(appDirectory, routes2, rootId = "root") {
|
|
161
161
|
let routeManifest = {};
|
|
162
162
|
function walk(route, parentId) {
|
|
163
|
-
let
|
|
163
|
+
let id = route.id || createRouteId(route.file);
|
|
164
164
|
let manifestItem = {
|
|
165
|
-
id
|
|
165
|
+
id,
|
|
166
166
|
parentId,
|
|
167
167
|
file: Path.isAbsolute(route.file) ? Path.relative(appDirectory, route.file) : route.file,
|
|
168
168
|
path: route.path,
|
|
169
169
|
index: route.index,
|
|
170
170
|
caseSensitive: route.caseSensitive
|
|
171
171
|
};
|
|
172
|
-
if (routeManifest.hasOwnProperty(
|
|
172
|
+
if (routeManifest.hasOwnProperty(id)) {
|
|
173
173
|
throw new Error(
|
|
174
|
-
`Unable to define routes with duplicate route id: "${
|
|
174
|
+
`Unable to define routes with duplicate route id: "${id}"`
|
|
175
175
|
);
|
|
176
176
|
}
|
|
177
|
-
routeManifest[
|
|
177
|
+
routeManifest[id] = manifestItem;
|
|
178
178
|
if (route.children) {
|
|
179
179
|
for (let child of route.children) {
|
|
180
|
-
walk(child,
|
|
180
|
+
walk(child, id);
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
}
|
|
@@ -600,7 +600,7 @@ function generate(ctx, route) {
|
|
|
600
600
|
const indent = i === 0 ? "" : " ".repeat(2);
|
|
601
601
|
let source = noExtension(rel);
|
|
602
602
|
if (!source.startsWith("../")) source = "./" + source;
|
|
603
|
-
return `${indent}import type { Info as Parent${i} } from "${source}"`;
|
|
603
|
+
return `${indent}import type { Info as Parent${i} } from "${source}.js"`;
|
|
604
604
|
}).join("\n");
|
|
605
605
|
return import_dedent.default`
|
|
606
606
|
// React Router generated types for route:
|
|
@@ -610,14 +610,16 @@ function generate(ctx, route) {
|
|
|
610
610
|
|
|
611
611
|
${parentTypeImports}
|
|
612
612
|
|
|
613
|
-
type Module = typeof import("../${Pathe2.filename(route.file)}")
|
|
613
|
+
type Module = typeof import("../${Pathe2.filename(route.file)}.js")
|
|
614
614
|
|
|
615
615
|
export type Info = {
|
|
616
616
|
parents: [${parents.map((_, i) => `Parent${i}`).join(", ")}],
|
|
617
617
|
id: "${route.id}"
|
|
618
618
|
file: "${route.file}"
|
|
619
619
|
path: "${route.path}"
|
|
620
|
-
params: {${formatParamProperties(
|
|
620
|
+
params: {${formatParamProperties(
|
|
621
|
+
urlpath
|
|
622
|
+
)}} & { [key: string]: string | undefined }
|
|
621
623
|
module: Module
|
|
622
624
|
loaderData: T.CreateLoaderData<Module>
|
|
623
625
|
actionData: T.CreateActionData<Module>
|
|
@@ -806,17 +808,24 @@ var init_styles = __esm({
|
|
|
806
808
|
path3 = __toESM(require("path"));
|
|
807
809
|
import_react_router = require("react-router");
|
|
808
810
|
init_resolve_file_url();
|
|
811
|
+
init_import_vite_esm_sync();
|
|
809
812
|
cssFileRegExp = /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
|
|
810
813
|
cssModulesRegExp = new RegExp(`\\.module${cssFileRegExp.source}`);
|
|
811
814
|
}
|
|
812
815
|
});
|
|
813
816
|
|
|
814
|
-
// vite/
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
817
|
+
// vite/virtual-module.ts
|
|
818
|
+
function create(name) {
|
|
819
|
+
let id = `virtual:react-router/${name}`;
|
|
820
|
+
return {
|
|
821
|
+
id,
|
|
822
|
+
resolvedId: `\0${id}`,
|
|
823
|
+
url: `/@id/__x00__${id}`
|
|
824
|
+
};
|
|
825
|
+
}
|
|
826
|
+
var init_virtual_module = __esm({
|
|
827
|
+
"vite/virtual-module.ts"() {
|
|
818
828
|
"use strict";
|
|
819
|
-
id = (name) => `virtual:react-router/${name}`;
|
|
820
829
|
}
|
|
821
830
|
});
|
|
822
831
|
|
|
@@ -838,14 +847,14 @@ var init_remove_exports = __esm({
|
|
|
838
847
|
});
|
|
839
848
|
|
|
840
849
|
// vite/with-props.ts
|
|
841
|
-
var import_dedent2,
|
|
850
|
+
var import_dedent2, vmod;
|
|
842
851
|
var init_with_props = __esm({
|
|
843
852
|
"vite/with-props.ts"() {
|
|
844
853
|
"use strict";
|
|
845
854
|
import_dedent2 = __toESM(require("dedent"));
|
|
846
855
|
init_babel();
|
|
847
|
-
|
|
848
|
-
|
|
856
|
+
init_virtual_module();
|
|
857
|
+
vmod = create("with-props");
|
|
849
858
|
}
|
|
850
859
|
});
|
|
851
860
|
|
|
@@ -910,7 +919,7 @@ function findConfig(dir, basename2, extensions) {
|
|
|
910
919
|
}
|
|
911
920
|
return void 0;
|
|
912
921
|
}
|
|
913
|
-
var import_node_crypto, path4, url, fse, babel, import_react_router2, import_es_module_lexer, import_jsesc, import_picocolors3,
|
|
922
|
+
var import_node_crypto, path4, url, fse, babel, import_react_router2, import_es_module_lexer, import_jsesc, import_picocolors3, virtualHmrRuntime, virtualInjectHmrRuntime, virtual, getServerBuildDirectory, defaultEntriesDir, defaultEntries, REACT_REFRESH_HEADER, REACT_REFRESH_FOOTER;
|
|
914
923
|
var init_plugin = __esm({
|
|
915
924
|
"vite/plugin.ts"() {
|
|
916
925
|
"use strict";
|
|
@@ -928,18 +937,20 @@ var init_plugin = __esm({
|
|
|
928
937
|
init_babel();
|
|
929
938
|
init_node_adapter();
|
|
930
939
|
init_styles();
|
|
931
|
-
|
|
940
|
+
init_virtual_module();
|
|
932
941
|
init_resolve_file_url();
|
|
933
942
|
init_combine_urls();
|
|
934
943
|
init_remove_exports();
|
|
935
944
|
init_import_vite_esm_sync();
|
|
936
945
|
init_config();
|
|
937
946
|
init_with_props();
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
947
|
+
virtualHmrRuntime = create("hmr-runtime");
|
|
948
|
+
virtualInjectHmrRuntime = create("inject-hmr-runtime");
|
|
949
|
+
virtual = {
|
|
950
|
+
serverBuild: create("server-build"),
|
|
951
|
+
serverManifest: create("server-manifest"),
|
|
952
|
+
browserManifest: create("browser-manifest")
|
|
953
|
+
};
|
|
943
954
|
getServerBuildDirectory = (ctx) => path4.join(
|
|
944
955
|
ctx.reactRouterConfig.buildDirectory,
|
|
945
956
|
"server",
|
|
@@ -954,7 +965,7 @@ var init_plugin = __esm({
|
|
|
954
965
|
defaultEntries = fse.readdirSync(defaultEntriesDir).map((filename3) => path4.join(defaultEntriesDir, filename3));
|
|
955
966
|
invariant(defaultEntries.length > 0, "No default entries found");
|
|
956
967
|
REACT_REFRESH_HEADER = `
|
|
957
|
-
import RefreshRuntime from "${
|
|
968
|
+
import RefreshRuntime from "${virtualHmrRuntime.id}";
|
|
958
969
|
|
|
959
970
|
const inWebWorker = typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope;
|
|
960
971
|
let prevRefreshReg;
|
|
@@ -991,6 +1002,45 @@ if (import.meta.hot && !inWebWorker) {
|
|
|
991
1002
|
}
|
|
992
1003
|
});
|
|
993
1004
|
|
|
1005
|
+
// vite/profiler.ts
|
|
1006
|
+
var import_node_fs3, import_node_path, import_picocolors4, getSession, start, profileCount, stop;
|
|
1007
|
+
var init_profiler = __esm({
|
|
1008
|
+
"vite/profiler.ts"() {
|
|
1009
|
+
"use strict";
|
|
1010
|
+
import_node_fs3 = __toESM(require("fs"));
|
|
1011
|
+
import_node_path = __toESM(require("path"));
|
|
1012
|
+
import_picocolors4 = __toESM(require("picocolors"));
|
|
1013
|
+
getSession = () => global.__reactRouter_profile_session;
|
|
1014
|
+
start = async (callback) => {
|
|
1015
|
+
let inspector = await import("inspector").then((r) => r.default);
|
|
1016
|
+
let session = global.__reactRouter_profile_session = new inspector.Session();
|
|
1017
|
+
session.connect();
|
|
1018
|
+
session.post("Profiler.enable", () => {
|
|
1019
|
+
session.post("Profiler.start", callback);
|
|
1020
|
+
});
|
|
1021
|
+
};
|
|
1022
|
+
profileCount = 0;
|
|
1023
|
+
stop = (log) => {
|
|
1024
|
+
let session = getSession();
|
|
1025
|
+
if (!session) return;
|
|
1026
|
+
return new Promise((res, rej) => {
|
|
1027
|
+
session.post("Profiler.stop", (err2, { profile }) => {
|
|
1028
|
+
if (err2) return rej(err2);
|
|
1029
|
+
let outPath = import_node_path.default.resolve(`./react-router-${profileCount++}.cpuprofile`);
|
|
1030
|
+
import_node_fs3.default.writeFileSync(outPath, JSON.stringify(profile));
|
|
1031
|
+
log(
|
|
1032
|
+
import_picocolors4.default.yellow(
|
|
1033
|
+
`CPU profile written to ${import_picocolors4.default.white(import_picocolors4.default.dim(outPath))}`
|
|
1034
|
+
)
|
|
1035
|
+
);
|
|
1036
|
+
global.__reactRouter_profile_session = void 0;
|
|
1037
|
+
res();
|
|
1038
|
+
});
|
|
1039
|
+
});
|
|
1040
|
+
};
|
|
1041
|
+
}
|
|
1042
|
+
});
|
|
1043
|
+
|
|
994
1044
|
// vite/build.ts
|
|
995
1045
|
var build_exports = {};
|
|
996
1046
|
__export(build_exports, {
|
|
@@ -998,8 +1048,8 @@ __export(build_exports, {
|
|
|
998
1048
|
});
|
|
999
1049
|
function getAddressableRoutes(routes2) {
|
|
1000
1050
|
let nonAddressableIds = /* @__PURE__ */ new Set();
|
|
1001
|
-
for (let
|
|
1002
|
-
let route = routes2[
|
|
1051
|
+
for (let id in routes2) {
|
|
1052
|
+
let route = routes2[id];
|
|
1003
1053
|
if (route.index) {
|
|
1004
1054
|
invariant(
|
|
1005
1055
|
route.parentId,
|
|
@@ -1008,7 +1058,7 @@ function getAddressableRoutes(routes2) {
|
|
|
1008
1058
|
nonAddressableIds.add(route.parentId);
|
|
1009
1059
|
}
|
|
1010
1060
|
if (typeof route.path !== "string" && !route.index) {
|
|
1011
|
-
nonAddressableIds.add(
|
|
1061
|
+
nonAddressableIds.add(id);
|
|
1012
1062
|
}
|
|
1013
1063
|
}
|
|
1014
1064
|
return Object.values(routes2).filter(
|
|
@@ -1039,12 +1089,12 @@ async function getServerBuilds(ctx) {
|
|
|
1039
1089
|
let { normalizePath } = await import("vite");
|
|
1040
1090
|
let resolvedAppDirectory = import_node_path2.default.resolve(rootDirectory, appDirectory);
|
|
1041
1091
|
let rootRelativeRoutes = Object.fromEntries(
|
|
1042
|
-
Object.entries(routes2).map(([
|
|
1092
|
+
Object.entries(routes2).map(([id, route]) => {
|
|
1043
1093
|
let filePath = import_node_path2.default.join(resolvedAppDirectory, route.file);
|
|
1044
1094
|
let rootRelativeFilePath = normalizePath(
|
|
1045
1095
|
import_node_path2.default.relative(rootDirectory, filePath)
|
|
1046
1096
|
);
|
|
1047
|
-
return [
|
|
1097
|
+
return [id, { ...route, file: rootRelativeFilePath }];
|
|
1048
1098
|
})
|
|
1049
1099
|
);
|
|
1050
1100
|
let buildManifest = {
|
|
@@ -1216,18 +1266,80 @@ var init_build = __esm({
|
|
|
1216
1266
|
}
|
|
1217
1267
|
});
|
|
1218
1268
|
|
|
1269
|
+
// vite/dev.ts
|
|
1270
|
+
var dev_exports = {};
|
|
1271
|
+
__export(dev_exports, {
|
|
1272
|
+
dev: () => dev
|
|
1273
|
+
});
|
|
1274
|
+
async function dev(root, {
|
|
1275
|
+
clearScreen,
|
|
1276
|
+
config: configFile,
|
|
1277
|
+
cors,
|
|
1278
|
+
force,
|
|
1279
|
+
host,
|
|
1280
|
+
logLevel,
|
|
1281
|
+
mode,
|
|
1282
|
+
open,
|
|
1283
|
+
port,
|
|
1284
|
+
strictPort
|
|
1285
|
+
}) {
|
|
1286
|
+
await preloadViteEsm();
|
|
1287
|
+
let vite2 = await import("vite");
|
|
1288
|
+
let server = await vite2.createServer({
|
|
1289
|
+
root,
|
|
1290
|
+
mode,
|
|
1291
|
+
configFile,
|
|
1292
|
+
server: { open, cors, host, port, strictPort },
|
|
1293
|
+
optimizeDeps: { force },
|
|
1294
|
+
clearScreen,
|
|
1295
|
+
logLevel
|
|
1296
|
+
});
|
|
1297
|
+
if (!server.config.plugins.find((plugin2) => plugin2.name === "react-router")) {
|
|
1298
|
+
console.error(
|
|
1299
|
+
import_picocolors6.default.red("React Router Vite plugin not found in Vite config")
|
|
1300
|
+
);
|
|
1301
|
+
process.exit(1);
|
|
1302
|
+
}
|
|
1303
|
+
await server.listen();
|
|
1304
|
+
server.printUrls();
|
|
1305
|
+
let customShortcuts = [
|
|
1306
|
+
{
|
|
1307
|
+
key: "p",
|
|
1308
|
+
description: "start/stop the profiler",
|
|
1309
|
+
async action(server2) {
|
|
1310
|
+
if (getSession()) {
|
|
1311
|
+
await stop(server2.config.logger.info);
|
|
1312
|
+
} else {
|
|
1313
|
+
await start(() => {
|
|
1314
|
+
server2.config.logger.info("Profiler started");
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
}
|
|
1319
|
+
];
|
|
1320
|
+
server.bindCLIShortcuts({ print: true, customShortcuts });
|
|
1321
|
+
}
|
|
1322
|
+
var import_picocolors6;
|
|
1323
|
+
var init_dev = __esm({
|
|
1324
|
+
"vite/dev.ts"() {
|
|
1325
|
+
"use strict";
|
|
1326
|
+
import_picocolors6 = __toESM(require("picocolors"));
|
|
1327
|
+
init_import_vite_esm_sync();
|
|
1328
|
+
init_profiler();
|
|
1329
|
+
}
|
|
1330
|
+
});
|
|
1331
|
+
|
|
1219
1332
|
// cli/run.ts
|
|
1220
1333
|
var import_arg = __toESM(require("arg"));
|
|
1221
1334
|
var import_semver = __toESM(require("semver"));
|
|
1222
|
-
var
|
|
1335
|
+
var import_picocolors8 = __toESM(require("picocolors"));
|
|
1223
1336
|
|
|
1224
1337
|
// cli/commands.ts
|
|
1225
1338
|
var path7 = __toESM(require("path"));
|
|
1226
1339
|
var import_fs_extra2 = __toESM(require("fs-extra"));
|
|
1227
1340
|
var import_package_json2 = __toESM(require("@npmcli/package-json"));
|
|
1228
|
-
var
|
|
1229
|
-
var
|
|
1230
|
-
init_invariant();
|
|
1341
|
+
var import_exit_hook = __toESM(require("exit-hook"));
|
|
1342
|
+
var import_picocolors7 = __toESM(require("picocolors"));
|
|
1231
1343
|
|
|
1232
1344
|
// config/format.ts
|
|
1233
1345
|
function formatRoutes(routeManifest, format) {
|
|
@@ -1306,40 +1418,8 @@ function transpile(tsx, options = {}) {
|
|
|
1306
1418
|
return import_prettier.default.format(mjs.code, { parser: "babel" });
|
|
1307
1419
|
}
|
|
1308
1420
|
|
|
1309
|
-
// vite/profiler.ts
|
|
1310
|
-
var import_node_fs3 = __toESM(require("fs"));
|
|
1311
|
-
var import_node_path = __toESM(require("path"));
|
|
1312
|
-
var import_picocolors4 = __toESM(require("picocolors"));
|
|
1313
|
-
var getSession = () => global.__reactRouter_profile_session;
|
|
1314
|
-
var start = async (callback) => {
|
|
1315
|
-
let inspector = await import("inspector").then((r) => r.default);
|
|
1316
|
-
let session = global.__reactRouter_profile_session = new inspector.Session();
|
|
1317
|
-
session.connect();
|
|
1318
|
-
session.post("Profiler.enable", () => {
|
|
1319
|
-
session.post("Profiler.start", callback);
|
|
1320
|
-
});
|
|
1321
|
-
};
|
|
1322
|
-
var profileCount = 0;
|
|
1323
|
-
var stop = (log) => {
|
|
1324
|
-
let session = getSession();
|
|
1325
|
-
if (!session) return;
|
|
1326
|
-
return new Promise((res, rej) => {
|
|
1327
|
-
session.post("Profiler.stop", (err2, { profile }) => {
|
|
1328
|
-
if (err2) return rej(err2);
|
|
1329
|
-
let outPath = import_node_path.default.resolve(`./react-router-${profileCount++}.cpuprofile`);
|
|
1330
|
-
import_node_fs3.default.writeFileSync(outPath, JSON.stringify(profile));
|
|
1331
|
-
log(
|
|
1332
|
-
import_picocolors4.default.yellow(
|
|
1333
|
-
`CPU profile written to ${import_picocolors4.default.white(import_picocolors4.default.dim(outPath))}`
|
|
1334
|
-
)
|
|
1335
|
-
);
|
|
1336
|
-
global.__reactRouter_profile_session = void 0;
|
|
1337
|
-
res();
|
|
1338
|
-
});
|
|
1339
|
-
});
|
|
1340
|
-
};
|
|
1341
|
-
|
|
1342
1421
|
// cli/commands.ts
|
|
1422
|
+
init_profiler();
|
|
1343
1423
|
init_typegen();
|
|
1344
1424
|
init_import_vite_esm_sync();
|
|
1345
1425
|
async function routes(reactRouterRoot, flags = {}) {
|
|
@@ -1349,7 +1429,7 @@ async function routes(reactRouterRoot, flags = {}) {
|
|
|
1349
1429
|
});
|
|
1350
1430
|
if (!ctx) {
|
|
1351
1431
|
console.error(
|
|
1352
|
-
|
|
1432
|
+
import_picocolors7.default.red("React Router Vite plugin not found in Vite config")
|
|
1353
1433
|
);
|
|
1354
1434
|
process.exit(1);
|
|
1355
1435
|
}
|
|
@@ -1370,23 +1450,13 @@ async function build2(root, options = {}) {
|
|
|
1370
1450
|
await stop(console.info);
|
|
1371
1451
|
}
|
|
1372
1452
|
}
|
|
1373
|
-
async function
|
|
1374
|
-
let
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
);
|
|
1379
|
-
|
|
1380
|
-
let { NODE_OPTIONS } = process.env;
|
|
1381
|
-
if (!NODE_OPTIONS?.includes("--conditions")) {
|
|
1382
|
-
NODE_OPTIONS = `${NODE_OPTIONS ?? ""} --conditions=development`.trim();
|
|
1383
|
-
}
|
|
1384
|
-
(0, import_execa.default)(process.execPath, [devScriptPath, JSON.stringify(args)], {
|
|
1385
|
-
env: { ...process.env, NODE_OPTIONS },
|
|
1386
|
-
stdin: "inherit",
|
|
1387
|
-
stdout: "inherit",
|
|
1388
|
-
stderr: "inherit"
|
|
1389
|
-
});
|
|
1453
|
+
async function dev2(root, options = {}) {
|
|
1454
|
+
let { dev: dev3 } = await Promise.resolve().then(() => (init_dev(), dev_exports));
|
|
1455
|
+
if (options.profile) {
|
|
1456
|
+
await start();
|
|
1457
|
+
}
|
|
1458
|
+
(0, import_exit_hook.default)(() => stop(console.info));
|
|
1459
|
+
await dev3(root, options);
|
|
1390
1460
|
await new Promise(() => {
|
|
1391
1461
|
});
|
|
1392
1462
|
}
|
|
@@ -1413,14 +1483,14 @@ async function generateEntry(entry, reactRouterRoot, flags = {}) {
|
|
|
1413
1483
|
let entriesArray = Array.from(entries);
|
|
1414
1484
|
let list = conjunctionListFormat.format(entriesArray);
|
|
1415
1485
|
console.error(
|
|
1416
|
-
|
|
1486
|
+
import_picocolors7.default.red(`Invalid entry file. Valid entry files are ${list}`)
|
|
1417
1487
|
);
|
|
1418
1488
|
return;
|
|
1419
1489
|
}
|
|
1420
1490
|
let pkgJson = await import_package_json2.default.load(rootDirectory);
|
|
1421
1491
|
let deps = pkgJson.content.dependencies ?? {};
|
|
1422
1492
|
if (!deps["@react-router/node"]) {
|
|
1423
|
-
console.error(
|
|
1493
|
+
console.error(import_picocolors7.default.red(`No default server entry detected.`));
|
|
1424
1494
|
return;
|
|
1425
1495
|
}
|
|
1426
1496
|
let defaultsDirectory = path7.resolve(
|
|
@@ -1450,7 +1520,7 @@ async function generateEntry(entry, reactRouterRoot, flags = {}) {
|
|
|
1450
1520
|
await import_fs_extra2.default.writeFile(outputFile2, contents, "utf-8");
|
|
1451
1521
|
}
|
|
1452
1522
|
console.log(
|
|
1453
|
-
|
|
1523
|
+
import_picocolors7.default.blue(
|
|
1454
1524
|
`Entry file ${entry} created at ${path7.relative(
|
|
1455
1525
|
rootDirectory,
|
|
1456
1526
|
outputFile2
|
|
@@ -1464,7 +1534,7 @@ async function checkForEntry(rootDirectory, appDirectory, entries2) {
|
|
|
1464
1534
|
let exists = await import_fs_extra2.default.pathExists(entryPath);
|
|
1465
1535
|
if (exists) {
|
|
1466
1536
|
let relative8 = path7.relative(rootDirectory, entryPath);
|
|
1467
|
-
console.error(
|
|
1537
|
+
console.error(import_picocolors7.default.red(`Entry file ${relative8} already exists.`));
|
|
1468
1538
|
return process.exit(1);
|
|
1469
1539
|
}
|
|
1470
1540
|
}
|
|
@@ -1495,14 +1565,14 @@ async function typegen(root, flags) {
|
|
|
1495
1565
|
|
|
1496
1566
|
// cli/run.ts
|
|
1497
1567
|
var helpText = `
|
|
1498
|
-
${
|
|
1568
|
+
${import_picocolors8.default.blueBright("react-router")}
|
|
1499
1569
|
|
|
1500
|
-
${
|
|
1501
|
-
$ react-router build [${
|
|
1502
|
-
$ react-router dev [${
|
|
1503
|
-
$ react-router routes [${
|
|
1570
|
+
${import_picocolors8.default.underline("Usage")}:
|
|
1571
|
+
$ react-router build [${import_picocolors8.default.yellowBright("projectDir")}]
|
|
1572
|
+
$ react-router dev [${import_picocolors8.default.yellowBright("projectDir")}]
|
|
1573
|
+
$ react-router routes [${import_picocolors8.default.yellowBright("projectDir")}]
|
|
1504
1574
|
|
|
1505
|
-
${
|
|
1575
|
+
${import_picocolors8.default.underline("Options")}:
|
|
1506
1576
|
--help, -h Print this help message and exit
|
|
1507
1577
|
--version, -v Print the CLI version and exit
|
|
1508
1578
|
--no-color Disable ANSI colors in console output
|
|
@@ -1538,22 +1608,22 @@ ${import_picocolors7.default.blueBright("react-router")}
|
|
|
1538
1608
|
\`typegen\` Options:
|
|
1539
1609
|
--watch Automatically regenerate types whenever route config (\`routes.ts\`) or route modules change
|
|
1540
1610
|
|
|
1541
|
-
${
|
|
1611
|
+
${import_picocolors8.default.underline("Build your project")}:
|
|
1542
1612
|
|
|
1543
1613
|
$ react-router build
|
|
1544
1614
|
|
|
1545
|
-
${
|
|
1615
|
+
${import_picocolors8.default.underline("Run your project locally in development")}:
|
|
1546
1616
|
|
|
1547
1617
|
$ react-router dev
|
|
1548
1618
|
|
|
1549
|
-
${
|
|
1619
|
+
${import_picocolors8.default.underline("Show all routes in your app")}:
|
|
1550
1620
|
|
|
1551
1621
|
$ react-router routes
|
|
1552
1622
|
$ react-router routes my-app
|
|
1553
1623
|
$ react-router routes --json
|
|
1554
1624
|
$ react-router routes --config vite.react-router.config.ts
|
|
1555
1625
|
|
|
1556
|
-
${
|
|
1626
|
+
${import_picocolors8.default.underline("Reveal the used entry point")}:
|
|
1557
1627
|
|
|
1558
1628
|
$ react-router reveal entry.client
|
|
1559
1629
|
$ react-router reveal entry.server
|
|
@@ -1561,7 +1631,7 @@ ${import_picocolors7.default.blueBright("react-router")}
|
|
|
1561
1631
|
$ react-router reveal entry.server --no-typescript
|
|
1562
1632
|
$ react-router reveal entry.server --config vite.react-router.config.ts
|
|
1563
1633
|
|
|
1564
|
-
${
|
|
1634
|
+
${import_picocolors8.default.underline("Generate types for route modules")}:
|
|
1565
1635
|
|
|
1566
1636
|
$ react-router typegen
|
|
1567
1637
|
$ react-router typegen --watch
|
|
@@ -1647,13 +1717,13 @@ async function run2(argv = process.argv.slice(2)) {
|
|
|
1647
1717
|
break;
|
|
1648
1718
|
}
|
|
1649
1719
|
case "dev":
|
|
1650
|
-
await
|
|
1720
|
+
await dev2(input[1], flags);
|
|
1651
1721
|
break;
|
|
1652
1722
|
case "typegen":
|
|
1653
1723
|
await typegen(input[1], flags);
|
|
1654
1724
|
break;
|
|
1655
1725
|
default:
|
|
1656
|
-
await
|
|
1726
|
+
await dev2(input[0], flags);
|
|
1657
1727
|
}
|
|
1658
1728
|
}
|
|
1659
1729
|
|
|
@@ -7,7 +7,7 @@ import { isbot } from "isbot";
|
|
|
7
7
|
import type { RenderToPipeableStreamOptions } from "react-dom/server";
|
|
8
8
|
import { renderToPipeableStream } from "react-dom/server";
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
export const streamTimeout = 5_000;
|
|
11
11
|
|
|
12
12
|
export default function handleRequest(
|
|
13
13
|
request: Request,
|
|
@@ -28,11 +28,7 @@ export default function handleRequest(
|
|
|
28
28
|
: "onShellReady";
|
|
29
29
|
|
|
30
30
|
const { pipe, abort } = renderToPipeableStream(
|
|
31
|
-
<ServerRouter
|
|
32
|
-
context={routerContext}
|
|
33
|
-
url={request.url}
|
|
34
|
-
abortDelay={ABORT_DELAY}
|
|
35
|
-
/>,
|
|
31
|
+
<ServerRouter context={routerContext} url={request.url} />,
|
|
36
32
|
{
|
|
37
33
|
[readyOption]() {
|
|
38
34
|
shellRendered = true;
|
|
@@ -65,6 +61,8 @@ export default function handleRequest(
|
|
|
65
61
|
}
|
|
66
62
|
);
|
|
67
63
|
|
|
68
|
-
|
|
64
|
+
// Abort the rendering stream after the `streamTimeout` so it has tine to
|
|
65
|
+
// flush down the rejected boundaries
|
|
66
|
+
setTimeout(abort, streamTimeout + 1000);
|
|
69
67
|
});
|
|
70
68
|
}
|
package/dist/config.js
CHANGED
package/dist/routes.js
CHANGED
package/dist/vite/cloudflare.js
CHANGED