@react-router/dev 0.0.0-experimental-de3b900 → 0.0.0-experimental-adadca553
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/dist/cli/index.js +17 -7
- package/dist/config.d.ts +14 -4
- package/dist/config.js +1 -1
- package/dist/routes.js +1 -1
- package/dist/vite/cloudflare.js +15 -6
- package/dist/vite.js +56 -31
- package/package.json +7 -6
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-adadca553
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) Remix Software Inc.
|
|
6
6
|
*
|
|
@@ -390,11 +390,20 @@ async function resolveConfig({
|
|
|
390
390
|
if (!ssr && serverBundles) {
|
|
391
391
|
serverBundles = void 0;
|
|
392
392
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
393
|
+
if (prerender) {
|
|
394
|
+
let isValidPrerenderPathsConfig = (p) => typeof p === "boolean" || typeof p === "function" || Array.isArray(p);
|
|
395
|
+
let isValidPrerenderConfig = isValidPrerenderPathsConfig(prerender) || typeof prerender === "object" && "paths" in prerender && isValidPrerenderPathsConfig(prerender.paths);
|
|
396
|
+
if (!isValidPrerenderConfig) {
|
|
397
|
+
return err(
|
|
398
|
+
"The `prerender`/`prerender.paths` config must be a boolean, an array of string paths, or a function returning a boolean or array of string paths."
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
let isValidConcurrencyConfig = typeof prerender != "object" || !("unstable_concurrency" in prerender) || typeof prerender.unstable_concurrency === "number" && Number.isInteger(prerender.unstable_concurrency) && prerender.unstable_concurrency > 0;
|
|
402
|
+
if (!isValidConcurrencyConfig) {
|
|
403
|
+
return err(
|
|
404
|
+
"The `prerender.unstable_concurrency` config must be a positive integer if specified."
|
|
405
|
+
);
|
|
406
|
+
}
|
|
398
407
|
}
|
|
399
408
|
let routeDiscovery;
|
|
400
409
|
if (userRouteDiscovery == null) {
|
|
@@ -1771,7 +1780,7 @@ function resolveEnvironmentsOptions(environmentResolvers, resolverOptions) {
|
|
|
1771
1780
|
function isNonNullable(x) {
|
|
1772
1781
|
return x != null;
|
|
1773
1782
|
}
|
|
1774
|
-
var import_node_crypto, import_node_fs3, import_promises2, path7, url, babel2, import_node_fetch_server2, import_react_router2, import_es_module_lexer, import_pick3, import_jsesc, import_picocolors5, import_kebabCase, CLIENT_NON_COMPONENT_EXPORTS, CLIENT_ROUTE_EXPORTS, BUILD_CLIENT_ROUTE_QUERY_STRING, SSR_BUNDLE_PREFIX, virtualHmrRuntime, virtualInjectHmrRuntime, virtual, getServerBuildDirectory, getClientBuildDirectory, defaultEntriesDir, defaultEntries, REACT_REFRESH_HEADER;
|
|
1783
|
+
var import_node_crypto, import_node_fs3, import_promises2, path7, url, babel2, import_node_fetch_server2, import_react_router2, import_es_module_lexer, import_pick3, import_jsesc, import_picocolors5, import_kebabCase, import_p_map, CLIENT_NON_COMPONENT_EXPORTS, CLIENT_ROUTE_EXPORTS, BUILD_CLIENT_ROUTE_QUERY_STRING, SSR_BUNDLE_PREFIX, virtualHmrRuntime, virtualInjectHmrRuntime, virtual, getServerBuildDirectory, getClientBuildDirectory, defaultEntriesDir, defaultEntries, REACT_REFRESH_HEADER;
|
|
1775
1784
|
var init_plugin = __esm({
|
|
1776
1785
|
"vite/plugin.ts"() {
|
|
1777
1786
|
"use strict";
|
|
@@ -1788,6 +1797,7 @@ var init_plugin = __esm({
|
|
|
1788
1797
|
import_jsesc = __toESM(require("jsesc"));
|
|
1789
1798
|
import_picocolors5 = __toESM(require("picocolors"));
|
|
1790
1799
|
import_kebabCase = __toESM(require("lodash/kebabCase"));
|
|
1800
|
+
import_p_map = __toESM(require("p-map"));
|
|
1791
1801
|
init_typegen();
|
|
1792
1802
|
init_invariant();
|
|
1793
1803
|
init_babel();
|
package/dist/config.d.ts
CHANGED
|
@@ -58,6 +58,9 @@ type BuildEndHook = (args: {
|
|
|
58
58
|
reactRouterConfig: ResolvedReactRouterConfig;
|
|
59
59
|
viteConfig: Vite.ResolvedConfig;
|
|
60
60
|
}) => void | Promise<void>;
|
|
61
|
+
type PrerenderPaths = boolean | Array<string> | ((args: {
|
|
62
|
+
getStaticPaths: () => string[];
|
|
63
|
+
}) => Array<string> | Promise<Array<string>>);
|
|
61
64
|
/**
|
|
62
65
|
* Config to be exported via the default export from `react-router.config.ts`.
|
|
63
66
|
*/
|
|
@@ -93,10 +96,17 @@ type ReactRouterConfig = {
|
|
|
93
96
|
/**
|
|
94
97
|
* An array of URLs to prerender to HTML files at build time. Can also be a
|
|
95
98
|
* function returning an array to dynamically generate URLs.
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
99
|
+
*
|
|
100
|
+
* `unstable_concurrency` defaults to 1, which means "no concurrency" - fully serial execution.
|
|
101
|
+
* Setting it to a value more than 1 enables concurrent prerendering.
|
|
102
|
+
* Setting it to a value higher than one can increase the speed of the build,
|
|
103
|
+
* but may consume more resources, and send more concurrent requests to the
|
|
104
|
+
* server/CMS.
|
|
105
|
+
*/
|
|
106
|
+
prerender?: PrerenderPaths | {
|
|
107
|
+
paths: PrerenderPaths;
|
|
108
|
+
unstable_concurrency?: number;
|
|
109
|
+
};
|
|
100
110
|
/**
|
|
101
111
|
* An array of React Router plugin config presets to ease integration with
|
|
102
112
|
* other platforms and tools.
|
package/dist/config.js
CHANGED
package/dist/routes.js
CHANGED
package/dist/vite/cloudflare.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @react-router/dev v0.0.0-experimental-
|
|
2
|
+
* @react-router/dev v0.0.0-experimental-adadca553
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -420,11 +420,20 @@ async function resolveConfig({
|
|
|
420
420
|
if (!ssr && serverBundles) {
|
|
421
421
|
serverBundles = void 0;
|
|
422
422
|
}
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
423
|
+
if (prerender) {
|
|
424
|
+
let isValidPrerenderPathsConfig = (p) => typeof p === "boolean" || typeof p === "function" || Array.isArray(p);
|
|
425
|
+
let isValidPrerenderConfig = isValidPrerenderPathsConfig(prerender) || typeof prerender === "object" && "paths" in prerender && isValidPrerenderPathsConfig(prerender.paths);
|
|
426
|
+
if (!isValidPrerenderConfig) {
|
|
427
|
+
return err(
|
|
428
|
+
"The `prerender`/`prerender.paths` config must be a boolean, an array of string paths, or a function returning a boolean or array of string paths."
|
|
429
|
+
);
|
|
430
|
+
}
|
|
431
|
+
let isValidConcurrencyConfig = typeof prerender != "object" || !("unstable_concurrency" in prerender) || typeof prerender.unstable_concurrency === "number" && Number.isInteger(prerender.unstable_concurrency) && prerender.unstable_concurrency > 0;
|
|
432
|
+
if (!isValidConcurrencyConfig) {
|
|
433
|
+
return err(
|
|
434
|
+
"The `prerender.unstable_concurrency` config must be a positive integer if specified."
|
|
435
|
+
);
|
|
436
|
+
}
|
|
428
437
|
}
|
|
429
438
|
let routeDiscovery;
|
|
430
439
|
if (userRouteDiscovery == null) {
|
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-adadca553
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -59,6 +59,7 @@ var import_pick3 = __toESM(require("lodash/pick"));
|
|
|
59
59
|
var import_jsesc = __toESM(require("jsesc"));
|
|
60
60
|
var import_picocolors4 = __toESM(require("picocolors"));
|
|
61
61
|
var import_kebabCase = __toESM(require("lodash/kebabCase"));
|
|
62
|
+
var import_p_map = __toESM(require("p-map"));
|
|
62
63
|
|
|
63
64
|
// typegen/index.ts
|
|
64
65
|
var import_promises = __toESM(require("fs/promises"));
|
|
@@ -447,11 +448,20 @@ async function resolveConfig({
|
|
|
447
448
|
if (!ssr && serverBundles) {
|
|
448
449
|
serverBundles = void 0;
|
|
449
450
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
451
|
+
if (prerender) {
|
|
452
|
+
let isValidPrerenderPathsConfig = (p) => typeof p === "boolean" || typeof p === "function" || Array.isArray(p);
|
|
453
|
+
let isValidPrerenderConfig = isValidPrerenderPathsConfig(prerender) || typeof prerender === "object" && "paths" in prerender && isValidPrerenderPathsConfig(prerender.paths);
|
|
454
|
+
if (!isValidPrerenderConfig) {
|
|
455
|
+
return err(
|
|
456
|
+
"The `prerender`/`prerender.paths` config must be a boolean, an array of string paths, or a function returning a boolean or array of string paths."
|
|
457
|
+
);
|
|
458
|
+
}
|
|
459
|
+
let isValidConcurrencyConfig = typeof prerender != "object" || !("unstable_concurrency" in prerender) || typeof prerender.unstable_concurrency === "number" && Number.isInteger(prerender.unstable_concurrency) && prerender.unstable_concurrency > 0;
|
|
460
|
+
if (!isValidConcurrencyConfig) {
|
|
461
|
+
return err(
|
|
462
|
+
"The `prerender.unstable_concurrency` config must be a positive integer if specified."
|
|
463
|
+
);
|
|
464
|
+
}
|
|
455
465
|
}
|
|
456
466
|
let routeDiscovery;
|
|
457
467
|
if (userRouteDiscovery == null) {
|
|
@@ -4246,10 +4256,10 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
|
|
|
4246
4256
|
}
|
|
4247
4257
|
}
|
|
4248
4258
|
let buildRoutes = createPrerenderRoutes(build.routes);
|
|
4249
|
-
|
|
4259
|
+
let prerenderSinglePath = async (path9) => {
|
|
4250
4260
|
let matches = (0, import_react_router2.matchRoutes)(buildRoutes, `/${path9}/`.replace(/^\/\/+/, "/"));
|
|
4251
4261
|
if (!matches) {
|
|
4252
|
-
|
|
4262
|
+
return;
|
|
4253
4263
|
}
|
|
4254
4264
|
let leafRoute = matches ? matches[matches.length - 1].route : null;
|
|
4255
4265
|
let manifestRoute = leafRoute ? build.routes[leafRoute.id]?.module : null;
|
|
@@ -4306,7 +4316,13 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
|
|
|
4306
4316
|
} : void 0
|
|
4307
4317
|
);
|
|
4308
4318
|
}
|
|
4319
|
+
};
|
|
4320
|
+
let concurrency = 1;
|
|
4321
|
+
let { prerender } = reactRouterConfig;
|
|
4322
|
+
if (typeof prerender === "object" && "unstable_concurrency" in prerender) {
|
|
4323
|
+
concurrency = prerender.unstable_concurrency ?? 1;
|
|
4309
4324
|
}
|
|
4325
|
+
await (0, import_p_map.default)(build.prerender, prerenderSinglePath, { concurrency });
|
|
4310
4326
|
}
|
|
4311
4327
|
function getStaticPrerenderPaths(routes) {
|
|
4312
4328
|
let paths = ["/"];
|
|
@@ -4422,31 +4438,40 @@ ${content.toString("utf8")}`
|
|
|
4422
4438
|
);
|
|
4423
4439
|
}
|
|
4424
4440
|
async function getPrerenderPaths(prerender, ssr, routes, logWarning = false) {
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4441
|
+
if (prerender == null || prerender === false) {
|
|
4442
|
+
return [];
|
|
4443
|
+
}
|
|
4444
|
+
let pathsConfig;
|
|
4445
|
+
if (typeof prerender === "object" && "paths" in prerender) {
|
|
4446
|
+
pathsConfig = prerender.paths;
|
|
4447
|
+
} else {
|
|
4448
|
+
pathsConfig = prerender;
|
|
4449
|
+
}
|
|
4450
|
+
if (pathsConfig === false) {
|
|
4451
|
+
return [];
|
|
4452
|
+
}
|
|
4453
|
+
let prerenderRoutes = createPrerenderRoutes(routes);
|
|
4454
|
+
if (pathsConfig === true) {
|
|
4455
|
+
let { paths, paramRoutes } = getStaticPrerenderPaths(prerenderRoutes);
|
|
4456
|
+
if (logWarning && !ssr && paramRoutes.length > 0) {
|
|
4457
|
+
console.warn(
|
|
4458
|
+
import_picocolors4.default.yellow(
|
|
4459
|
+
[
|
|
4460
|
+
"\u26A0\uFE0F Paths with dynamic/splat params cannot be prerendered when using `prerender: true`. You may want to use the `prerender()` API to prerender the following paths:",
|
|
4461
|
+
...paramRoutes.map((p) => " - " + p)
|
|
4462
|
+
].join("\n")
|
|
4463
|
+
)
|
|
4464
|
+
);
|
|
4447
4465
|
}
|
|
4466
|
+
return paths;
|
|
4467
|
+
}
|
|
4468
|
+
if (typeof pathsConfig === "function") {
|
|
4469
|
+
let paths = await pathsConfig({
|
|
4470
|
+
getStaticPaths: () => getStaticPrerenderPaths(prerenderRoutes).paths
|
|
4471
|
+
});
|
|
4472
|
+
return paths;
|
|
4448
4473
|
}
|
|
4449
|
-
return
|
|
4474
|
+
return pathsConfig;
|
|
4450
4475
|
}
|
|
4451
4476
|
function groupRoutesByParentId2(manifest) {
|
|
4452
4477
|
let routes = {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-router/dev",
|
|
3
|
-
"version": "0.0.0-experimental-
|
|
3
|
+
"version": "0.0.0-experimental-adadca553",
|
|
4
4
|
"description": "Dev tools and CLI for React Router",
|
|
5
5
|
"homepage": "https://reactrouter.com",
|
|
6
6
|
"bugs": {
|
|
@@ -78,6 +78,7 @@
|
|
|
78
78
|
"isbot": "^5.1.11",
|
|
79
79
|
"jsesc": "3.0.2",
|
|
80
80
|
"lodash": "^4.17.21",
|
|
81
|
+
"p-map": "^7.0.3",
|
|
81
82
|
"pathe": "^1.1.2",
|
|
82
83
|
"picocolors": "^1.1.1",
|
|
83
84
|
"prettier": "^3.6.2",
|
|
@@ -86,7 +87,7 @@
|
|
|
86
87
|
"tinyglobby": "^0.2.14",
|
|
87
88
|
"valibot": "^1.1.0",
|
|
88
89
|
"vite-node": "^3.2.2",
|
|
89
|
-
"@react-router/node": "0.0.0-experimental-
|
|
90
|
+
"@react-router/node": "0.0.0-experimental-adadca553"
|
|
90
91
|
},
|
|
91
92
|
"devDependencies": {
|
|
92
93
|
"@types/babel__core": "^7.20.5",
|
|
@@ -109,16 +110,16 @@
|
|
|
109
110
|
"vite": "^6.1.0",
|
|
110
111
|
"wireit": "0.14.9",
|
|
111
112
|
"wrangler": "^4.23.0",
|
|
112
|
-
"react-router": "
|
|
113
|
-
"
|
|
113
|
+
"@react-router/serve": "0.0.0-experimental-adadca553",
|
|
114
|
+
"react-router": "^0.0.0-experimental-adadca553"
|
|
114
115
|
},
|
|
115
116
|
"peerDependencies": {
|
|
116
117
|
"@vitejs/plugin-rsc": "*",
|
|
117
118
|
"typescript": "^5.1.0",
|
|
118
119
|
"vite": "^5.1.0 || ^6.0.0 || ^7.0.0",
|
|
119
120
|
"wrangler": "^3.28.2 || ^4.0.0",
|
|
120
|
-
"@react-router/serve": "^0.0.0-experimental-
|
|
121
|
-
"react-router": "^0.0.0-experimental-
|
|
121
|
+
"@react-router/serve": "^0.0.0-experimental-adadca553",
|
|
122
|
+
"react-router": "^0.0.0-experimental-adadca553"
|
|
122
123
|
},
|
|
123
124
|
"peerDependenciesMeta": {
|
|
124
125
|
"@vitejs/plugin-rsc": {
|