@c0va23/react-router-dev 7.8.3-alpha.1 → 7.8.3-alpha.2
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 +3 -0
- package/dist/cli/index.js +58 -148
- package/dist/config/default-rsc-entries/entry.client.tsx +1 -9
- package/dist/config/default-rsc-entries/entry.rsc.tsx +1 -9
- package/dist/config/default-rsc-entries/entry.ssr.tsx +1 -7
- package/dist/config/defaults/entry.server.node.tsx +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -1
- package/dist/internal.js +100 -306
- package/dist/routes.js +1 -1
- package/dist/vite/cloudflare.d.ts +2 -2
- package/dist/vite/cloudflare.js +5 -19
- package/dist/vite.js +232 -267
- package/package.json +4 -8
package/CHANGELOG.md
CHANGED
package/dist/cli/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* @c0va23/react-router-dev v7.8.3-alpha.
|
|
3
|
+
* @c0va23/react-router-dev v7.8.3-alpha.2
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) Remix Software Inc.
|
|
6
6
|
*
|
|
@@ -217,7 +217,7 @@ function validateRouteConfig({
|
|
|
217
217
|
`Route config in "${routeConfigFile}" is invalid.`,
|
|
218
218
|
root ? `${root}` : [],
|
|
219
219
|
nested ? Object.entries(nested).map(
|
|
220
|
-
([
|
|
220
|
+
([path8, message]) => `Path: routes.${path8}
|
|
221
221
|
${message}`
|
|
222
222
|
) : []
|
|
223
223
|
].flat().join("\n\n")
|
|
@@ -311,8 +311,7 @@ async function resolveConfig({
|
|
|
311
311
|
root,
|
|
312
312
|
viteNodeContext,
|
|
313
313
|
reactRouterConfigFile,
|
|
314
|
-
skipRoutes
|
|
315
|
-
validateConfig
|
|
314
|
+
skipRoutes
|
|
316
315
|
}) {
|
|
317
316
|
let reactRouterUserConfig = {};
|
|
318
317
|
if (reactRouterConfigFile) {
|
|
@@ -330,12 +329,6 @@ async function resolveConfig({
|
|
|
330
329
|
return err(`${reactRouterConfigFile} must export a config`);
|
|
331
330
|
}
|
|
332
331
|
reactRouterUserConfig = configModule.default;
|
|
333
|
-
if (validateConfig) {
|
|
334
|
-
const error = validateConfig(reactRouterUserConfig);
|
|
335
|
-
if (error) {
|
|
336
|
-
return err(error);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
332
|
} catch (error) {
|
|
340
333
|
return err(`Error loading ${reactRouterConfigFile}: ${error}`);
|
|
341
334
|
}
|
|
@@ -484,7 +477,7 @@ async function resolveConfig({
|
|
|
484
477
|
}
|
|
485
478
|
}
|
|
486
479
|
let future = {
|
|
487
|
-
|
|
480
|
+
unstable_middleware: reactRouterUserConfig.future?.unstable_middleware ?? false,
|
|
488
481
|
unstable_optimizeDeps: reactRouterUserConfig.future?.unstable_optimizeDeps ?? false,
|
|
489
482
|
unstable_splitRouteModules: reactRouterUserConfig.future?.unstable_splitRouteModules ?? false,
|
|
490
483
|
unstable_subResourceIntegrity: reactRouterUserConfig.future?.unstable_subResourceIntegrity ?? false,
|
|
@@ -514,8 +507,7 @@ async function createConfigLoader({
|
|
|
514
507
|
rootDirectory: root,
|
|
515
508
|
watch: watch2,
|
|
516
509
|
mode,
|
|
517
|
-
skipRoutes
|
|
518
|
-
validateConfig
|
|
510
|
+
skipRoutes
|
|
519
511
|
}) {
|
|
520
512
|
root = import_pathe3.default.normalize(root ?? process.env.REACT_ROUTER_ROOT ?? process.cwd());
|
|
521
513
|
let vite2 = await import("vite");
|
|
@@ -534,13 +526,7 @@ async function createConfigLoader({
|
|
|
534
526
|
});
|
|
535
527
|
};
|
|
536
528
|
updateReactRouterConfigFile();
|
|
537
|
-
let getConfig = () => resolveConfig({
|
|
538
|
-
root,
|
|
539
|
-
viteNodeContext,
|
|
540
|
-
reactRouterConfigFile,
|
|
541
|
-
skipRoutes,
|
|
542
|
-
validateConfig
|
|
543
|
-
});
|
|
529
|
+
let getConfig = () => resolveConfig({ root, viteNodeContext, reactRouterConfigFile, skipRoutes });
|
|
544
530
|
let appDirectory;
|
|
545
531
|
let initialConfigResult = await getConfig();
|
|
546
532
|
if (!initialConfigResult.ok) {
|
|
@@ -562,11 +548,11 @@ async function createConfigLoader({
|
|
|
562
548
|
if (!fsWatcher) {
|
|
563
549
|
fsWatcher = import_chokidar.default.watch([root, appDirectory], {
|
|
564
550
|
ignoreInitial: true,
|
|
565
|
-
ignored: (
|
|
566
|
-
let dirname5 = import_pathe3.default.dirname(
|
|
551
|
+
ignored: (path8) => {
|
|
552
|
+
let dirname5 = import_pathe3.default.dirname(path8);
|
|
567
553
|
return !dirname5.startsWith(appDirectory) && // Ensure we're only watching files outside of the app directory
|
|
568
554
|
// that are at the root level, not nested in subdirectories
|
|
569
|
-
|
|
555
|
+
path8 !== root && // Watch the root directory itself
|
|
570
556
|
dirname5 !== root;
|
|
571
557
|
}
|
|
572
558
|
});
|
|
@@ -890,7 +876,7 @@ function fullpath(lineage2) {
|
|
|
890
876
|
if (lineage2.length === 1 && route?.id === "root") return "/";
|
|
891
877
|
const isLayout = route && route.index !== true && route.path === void 0;
|
|
892
878
|
if (isLayout) return void 0;
|
|
893
|
-
return "/" + lineage2.map((route2) => route2.path?.replace(/^\//, "")?.replace(/\/$/, "")).filter((
|
|
879
|
+
return "/" + lineage2.map((route2) => route2.path?.replace(/^\//, "")?.replace(/\/$/, "")).filter((path8) => path8 !== void 0 && path8 !== "").join("/");
|
|
894
880
|
}
|
|
895
881
|
var init_route = __esm({
|
|
896
882
|
"typegen/route.ts"() {
|
|
@@ -911,7 +897,7 @@ function generateFuture(ctx) {
|
|
|
911
897
|
|
|
912
898
|
declare module "react-router" {
|
|
913
899
|
interface Future {
|
|
914
|
-
|
|
900
|
+
unstable_middleware: ${ctx.config.future.unstable_middleware}
|
|
915
901
|
}
|
|
916
902
|
}
|
|
917
903
|
`;
|
|
@@ -1050,8 +1036,8 @@ function routeFilesType({
|
|
|
1050
1036
|
);
|
|
1051
1037
|
}
|
|
1052
1038
|
function isInAppDirectory(ctx, routeFile) {
|
|
1053
|
-
const
|
|
1054
|
-
return
|
|
1039
|
+
const path8 = Path3.resolve(ctx.config.appDirectory, routeFile);
|
|
1040
|
+
return path8.startsWith(ctx.config.appDirectory);
|
|
1055
1041
|
}
|
|
1056
1042
|
function getRouteAnnotations({
|
|
1057
1043
|
ctx,
|
|
@@ -1132,11 +1118,11 @@ function getRouteAnnotations({
|
|
|
1132
1118
|
export type HeadersArgs = Annotations["HeadersArgs"];
|
|
1133
1119
|
export type HeadersFunction = Annotations["HeadersFunction"];
|
|
1134
1120
|
|
|
1135
|
-
//
|
|
1136
|
-
export type
|
|
1121
|
+
// unstable_middleware
|
|
1122
|
+
export type unstable_MiddlewareFunction = Annotations["unstable_MiddlewareFunction"];
|
|
1137
1123
|
|
|
1138
|
-
//
|
|
1139
|
-
export type
|
|
1124
|
+
// unstable_clientMiddleware
|
|
1125
|
+
export type unstable_ClientMiddlewareFunction = Annotations["unstable_ClientMiddlewareFunction"];
|
|
1140
1126
|
|
|
1141
1127
|
// loader
|
|
1142
1128
|
export type LoaderArgs = Annotations["LoaderArgs"];
|
|
@@ -1163,21 +1149,21 @@ function getRouteAnnotations({
|
|
|
1163
1149
|
return { filename: filename2, content };
|
|
1164
1150
|
}
|
|
1165
1151
|
function relativeImportSource(from, to) {
|
|
1166
|
-
let
|
|
1167
|
-
let extension = Path3.extname(
|
|
1168
|
-
|
|
1169
|
-
if (!
|
|
1152
|
+
let path8 = Path3.relative(Path3.dirname(from), to);
|
|
1153
|
+
let extension = Path3.extname(path8);
|
|
1154
|
+
path8 = Path3.join(Path3.dirname(path8), Pathe.filename(path8));
|
|
1155
|
+
if (!path8.startsWith("../")) path8 = "./" + path8;
|
|
1170
1156
|
if (!extension || /\.(js|ts)x?$/.test(extension)) {
|
|
1171
1157
|
extension = ".js";
|
|
1172
1158
|
}
|
|
1173
|
-
return
|
|
1159
|
+
return path8 + extension;
|
|
1174
1160
|
}
|
|
1175
1161
|
function rootDirsPath(ctx, typesPath) {
|
|
1176
1162
|
const rel = Path3.relative(typesDirectory(ctx), typesPath);
|
|
1177
1163
|
return Path3.join(ctx.rootDirectory, rel);
|
|
1178
1164
|
}
|
|
1179
|
-
function paramsType(
|
|
1180
|
-
const params = parse2(
|
|
1165
|
+
function paramsType(path8) {
|
|
1166
|
+
const params = parse2(path8);
|
|
1181
1167
|
return t2.tsTypeLiteral(
|
|
1182
1168
|
Object.entries(params).map(([param, isRequired]) => {
|
|
1183
1169
|
const property = t2.tsPropertySignature(
|
|
@@ -1298,36 +1284,6 @@ var init_typegen = __esm({
|
|
|
1298
1284
|
}
|
|
1299
1285
|
});
|
|
1300
1286
|
|
|
1301
|
-
// vite/has-rsc-plugin.ts
|
|
1302
|
-
async function hasReactRouterRscPlugin({
|
|
1303
|
-
root,
|
|
1304
|
-
viteBuildOptions: { config, logLevel, mode }
|
|
1305
|
-
}) {
|
|
1306
|
-
const vite2 = await import("vite");
|
|
1307
|
-
const viteConfig = await vite2.resolveConfig(
|
|
1308
|
-
{
|
|
1309
|
-
configFile: config,
|
|
1310
|
-
logLevel,
|
|
1311
|
-
mode: mode ?? "production",
|
|
1312
|
-
root
|
|
1313
|
-
},
|
|
1314
|
-
"build",
|
|
1315
|
-
// command
|
|
1316
|
-
"production",
|
|
1317
|
-
// default mode
|
|
1318
|
-
"production"
|
|
1319
|
-
// default NODE_ENV
|
|
1320
|
-
);
|
|
1321
|
-
return viteConfig.plugins.some(
|
|
1322
|
-
(plugin) => plugin?.name === "react-router/rsc"
|
|
1323
|
-
);
|
|
1324
|
-
}
|
|
1325
|
-
var init_has_rsc_plugin = __esm({
|
|
1326
|
-
"vite/has-rsc-plugin.ts"() {
|
|
1327
|
-
"use strict";
|
|
1328
|
-
}
|
|
1329
|
-
});
|
|
1330
|
-
|
|
1331
1287
|
// vite/node-adapter.ts
|
|
1332
1288
|
var import_node_events, import_node_tls, import_node_stream, import_set_cookie_parser, import_node;
|
|
1333
1289
|
var init_node_adapter = __esm({
|
|
@@ -1381,16 +1337,6 @@ var init_virtual_module = __esm({
|
|
|
1381
1337
|
}
|
|
1382
1338
|
});
|
|
1383
1339
|
|
|
1384
|
-
// vite/resolve-relative-route-file-path.ts
|
|
1385
|
-
var import_pathe4;
|
|
1386
|
-
var init_resolve_relative_route_file_path = __esm({
|
|
1387
|
-
"vite/resolve-relative-route-file-path.ts"() {
|
|
1388
|
-
"use strict";
|
|
1389
|
-
import_pathe4 = __toESM(require("pathe"));
|
|
1390
|
-
init_vite();
|
|
1391
|
-
}
|
|
1392
|
-
});
|
|
1393
|
-
|
|
1394
1340
|
// vite/combine-urls.ts
|
|
1395
1341
|
var init_combine_urls = __esm({
|
|
1396
1342
|
"vite/combine-urls.ts"() {
|
|
@@ -1408,13 +1354,6 @@ var init_remove_exports = __esm({
|
|
|
1408
1354
|
}
|
|
1409
1355
|
});
|
|
1410
1356
|
|
|
1411
|
-
// vite/has-dependency.ts
|
|
1412
|
-
var init_has_dependency = __esm({
|
|
1413
|
-
"vite/has-dependency.ts"() {
|
|
1414
|
-
"use strict";
|
|
1415
|
-
}
|
|
1416
|
-
});
|
|
1417
|
-
|
|
1418
1357
|
// vite/cache.ts
|
|
1419
1358
|
var init_cache = __esm({
|
|
1420
1359
|
"vite/cache.ts"() {
|
|
@@ -1454,7 +1393,7 @@ var init_route_chunks = __esm({
|
|
|
1454
1393
|
routeChunkExportNames = [
|
|
1455
1394
|
"clientAction",
|
|
1456
1395
|
"clientLoader",
|
|
1457
|
-
"
|
|
1396
|
+
"unstable_clientMiddleware",
|
|
1458
1397
|
"HydrateFallback"
|
|
1459
1398
|
];
|
|
1460
1399
|
mainChunkName = "main";
|
|
@@ -1464,23 +1403,12 @@ var init_route_chunks = __esm({
|
|
|
1464
1403
|
main: `${routeChunkQueryStringPrefix}main`,
|
|
1465
1404
|
clientAction: `${routeChunkQueryStringPrefix}clientAction`,
|
|
1466
1405
|
clientLoader: `${routeChunkQueryStringPrefix}clientLoader`,
|
|
1467
|
-
|
|
1406
|
+
unstable_clientMiddleware: `${routeChunkQueryStringPrefix}unstable_clientMiddleware`,
|
|
1468
1407
|
HydrateFallback: `${routeChunkQueryStringPrefix}HydrateFallback`
|
|
1469
1408
|
};
|
|
1470
1409
|
}
|
|
1471
1410
|
});
|
|
1472
1411
|
|
|
1473
|
-
// vite/optimize-deps-entries.ts
|
|
1474
|
-
var import_tinyglobby;
|
|
1475
|
-
var init_optimize_deps_entries = __esm({
|
|
1476
|
-
"vite/optimize-deps-entries.ts"() {
|
|
1477
|
-
"use strict";
|
|
1478
|
-
import_tinyglobby = require("tinyglobby");
|
|
1479
|
-
init_resolve_relative_route_file_path();
|
|
1480
|
-
init_vite();
|
|
1481
|
-
}
|
|
1482
|
-
});
|
|
1483
|
-
|
|
1484
1412
|
// vite/with-props.ts
|
|
1485
1413
|
var init_with_props = __esm({
|
|
1486
1414
|
"vite/with-props.ts"() {
|
|
@@ -1538,8 +1466,8 @@ function getServerBundleIds(ctx) {
|
|
|
1538
1466
|
async function cleanBuildDirectory(viteConfig, ctx) {
|
|
1539
1467
|
let buildDirectory = ctx.reactRouterConfig.buildDirectory;
|
|
1540
1468
|
let isWithinRoot = () => {
|
|
1541
|
-
let relativePath =
|
|
1542
|
-
return !relativePath.startsWith("..") && !
|
|
1469
|
+
let relativePath = path6.relative(ctx.rootDirectory, buildDirectory);
|
|
1470
|
+
return !relativePath.startsWith("..") && !path6.isAbsolute(relativePath);
|
|
1543
1471
|
};
|
|
1544
1472
|
if (viteConfig.build.emptyOutDir ?? isWithinRoot()) {
|
|
1545
1473
|
await (0, import_promises2.rm)(buildDirectory, { force: true, recursive: true });
|
|
@@ -1550,7 +1478,7 @@ async function cleanViteManifests(environmentsOptions, ctx) {
|
|
|
1550
1478
|
([environmentName, options]) => {
|
|
1551
1479
|
let outDir = options.build?.outDir;
|
|
1552
1480
|
invariant(outDir, `Expected build.outDir for ${environmentName}`);
|
|
1553
|
-
return
|
|
1481
|
+
return path6.join(outDir, ".vite/manifest.json");
|
|
1554
1482
|
}
|
|
1555
1483
|
);
|
|
1556
1484
|
await Promise.all(
|
|
@@ -1560,7 +1488,7 @@ async function cleanViteManifests(environmentsOptions, ctx) {
|
|
|
1560
1488
|
if (!ctx.viteManifestEnabled) {
|
|
1561
1489
|
await (0, import_promises2.rm)(viteManifestPath, { force: true, recursive: true });
|
|
1562
1490
|
}
|
|
1563
|
-
let viteDir =
|
|
1491
|
+
let viteDir = path6.dirname(viteManifestPath);
|
|
1564
1492
|
let viteDirFiles = await (0, import_promises2.readdir)(viteDir, { recursive: true });
|
|
1565
1493
|
if (viteDirFiles.length === 0) {
|
|
1566
1494
|
await (0, import_promises2.rm)(viteDir, { force: true, recursive: true });
|
|
@@ -1577,10 +1505,10 @@ function mergeEnvironmentOptions(base, ...overrides) {
|
|
|
1577
1505
|
}
|
|
1578
1506
|
async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
|
|
1579
1507
|
let { serverBuildFile, serverModuleFormat } = ctx.reactRouterConfig;
|
|
1580
|
-
let packageRoot =
|
|
1508
|
+
let packageRoot = path6.dirname(
|
|
1581
1509
|
require.resolve("@react-router/dev/package.json")
|
|
1582
1510
|
);
|
|
1583
|
-
let { moduleSyncEnabled } = await import(`file:///${
|
|
1511
|
+
let { moduleSyncEnabled } = await import(`file:///${path6.join(packageRoot, "module-sync-enabled/index.mjs")}`);
|
|
1584
1512
|
let vite2 = getVite();
|
|
1585
1513
|
function getBaseOptions({
|
|
1586
1514
|
viteUserConfig
|
|
@@ -1659,7 +1587,7 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
|
|
|
1659
1587
|
ctx.entryClientFilePath,
|
|
1660
1588
|
...Object.values(ctx.reactRouterConfig.routes).flatMap(
|
|
1661
1589
|
(route) => {
|
|
1662
|
-
let routeFilePath =
|
|
1590
|
+
let routeFilePath = path6.resolve(
|
|
1663
1591
|
ctx.reactRouterConfig.appDirectory,
|
|
1664
1592
|
route.file
|
|
1665
1593
|
);
|
|
@@ -1683,7 +1611,7 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
|
|
|
1683
1611
|
) : null;
|
|
1684
1612
|
let routeChunkSuffix = routeChunkName ? `-${(0, import_kebabCase.default)(routeChunkName)}` : "";
|
|
1685
1613
|
let assetsDir = (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi ? viteUserConfig?.environments?.client?.build?.assetsDir : null) ?? viteUserConfig?.build?.assetsDir ?? "assets";
|
|
1686
|
-
return
|
|
1614
|
+
return path6.posix.join(
|
|
1687
1615
|
assetsDir,
|
|
1688
1616
|
`[name]${routeChunkSuffix}-[hash].js`
|
|
1689
1617
|
);
|
|
@@ -1733,18 +1661,19 @@ function resolveEnvironmentsOptions(environmentResolvers, resolverOptions) {
|
|
|
1733
1661
|
function isNonNullable(x) {
|
|
1734
1662
|
return x != null;
|
|
1735
1663
|
}
|
|
1736
|
-
var import_node_crypto, import_node_fs3, import_promises2,
|
|
1664
|
+
var import_node_crypto, import_node_fs3, import_promises2, path6, url, babel2, import_react_router2, import_es_module_lexer, import_tinyglobby, import_pick3, import_jsesc, import_picocolors4, 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;
|
|
1737
1665
|
var init_plugin = __esm({
|
|
1738
1666
|
"vite/plugin.ts"() {
|
|
1739
1667
|
"use strict";
|
|
1740
1668
|
import_node_crypto = require("crypto");
|
|
1741
1669
|
import_node_fs3 = require("fs");
|
|
1742
1670
|
import_promises2 = require("fs/promises");
|
|
1743
|
-
|
|
1671
|
+
path6 = __toESM(require("path"));
|
|
1744
1672
|
url = __toESM(require("url"));
|
|
1745
1673
|
babel2 = __toESM(require("@babel/core"));
|
|
1746
1674
|
import_react_router2 = require("react-router");
|
|
1747
1675
|
import_es_module_lexer = require("es-module-lexer");
|
|
1676
|
+
import_tinyglobby = require("tinyglobby");
|
|
1748
1677
|
import_pick3 = __toESM(require("lodash/pick"));
|
|
1749
1678
|
import_jsesc = __toESM(require("jsesc"));
|
|
1750
1679
|
import_picocolors4 = __toESM(require("picocolors"));
|
|
@@ -1756,21 +1685,18 @@ var init_plugin = __esm({
|
|
|
1756
1685
|
init_styles();
|
|
1757
1686
|
init_virtual_module();
|
|
1758
1687
|
init_resolve_file_url();
|
|
1759
|
-
init_resolve_relative_route_file_path();
|
|
1760
1688
|
init_combine_urls();
|
|
1761
1689
|
init_remove_exports();
|
|
1762
1690
|
init_ssr_externals();
|
|
1763
|
-
init_has_dependency();
|
|
1764
1691
|
init_route_chunks();
|
|
1765
1692
|
init_vite();
|
|
1766
1693
|
init_config();
|
|
1767
|
-
init_optimize_deps_entries();
|
|
1768
1694
|
init_with_props();
|
|
1769
1695
|
init_validate_plugin_order();
|
|
1770
1696
|
CLIENT_NON_COMPONENT_EXPORTS = [
|
|
1771
1697
|
"clientAction",
|
|
1772
1698
|
"clientLoader",
|
|
1773
|
-
"
|
|
1699
|
+
"unstable_clientMiddleware",
|
|
1774
1700
|
"handle",
|
|
1775
1701
|
"meta",
|
|
1776
1702
|
"links",
|
|
@@ -1792,20 +1718,20 @@ var init_plugin = __esm({
|
|
|
1792
1718
|
serverManifest: create("server-manifest"),
|
|
1793
1719
|
browserManifest: create("browser-manifest")
|
|
1794
1720
|
};
|
|
1795
|
-
getServerBuildDirectory = (reactRouterConfig, { serverBundleId } = {}) =>
|
|
1721
|
+
getServerBuildDirectory = (reactRouterConfig, { serverBundleId } = {}) => path6.join(
|
|
1796
1722
|
reactRouterConfig.buildDirectory,
|
|
1797
1723
|
"server",
|
|
1798
1724
|
...serverBundleId ? [serverBundleId] : []
|
|
1799
1725
|
);
|
|
1800
|
-
getClientBuildDirectory = (reactRouterConfig) =>
|
|
1801
|
-
defaultEntriesDir =
|
|
1802
|
-
|
|
1726
|
+
getClientBuildDirectory = (reactRouterConfig) => path6.join(reactRouterConfig.buildDirectory, "client");
|
|
1727
|
+
defaultEntriesDir = path6.resolve(
|
|
1728
|
+
path6.dirname(require.resolve("@react-router/dev/package.json")),
|
|
1803
1729
|
"dist",
|
|
1804
1730
|
"config",
|
|
1805
1731
|
"defaults"
|
|
1806
1732
|
);
|
|
1807
1733
|
defaultEntries = (0, import_node_fs3.readdirSync)(defaultEntriesDir).map(
|
|
1808
|
-
(filename2) =>
|
|
1734
|
+
(filename2) => path6.join(defaultEntriesDir, filename2)
|
|
1809
1735
|
);
|
|
1810
1736
|
invariant(defaultEntries.length > 0, "No default entries found");
|
|
1811
1737
|
REACT_REFRESH_HEADER = `
|
|
@@ -1851,14 +1777,14 @@ async function build(root, viteBuildOptions) {
|
|
|
1851
1777
|
throw new Error(configResult.error);
|
|
1852
1778
|
}
|
|
1853
1779
|
let config = configResult.value;
|
|
1780
|
+
let unstable_viteEnvironmentApi = config.future.unstable_viteEnvironmentApi;
|
|
1854
1781
|
let viteMajor = parseInt(vite2.version.split(".")[0], 10);
|
|
1855
|
-
if (
|
|
1782
|
+
if (unstable_viteEnvironmentApi && viteMajor === 5) {
|
|
1856
1783
|
throw new Error(
|
|
1857
1784
|
"The future.unstable_viteEnvironmentApi option is not supported in Vite 5"
|
|
1858
1785
|
);
|
|
1859
1786
|
}
|
|
1860
|
-
|
|
1861
|
-
return await (useViteEnvironmentApi ? viteAppBuild(root, viteBuildOptions) : viteBuild(root, viteBuildOptions));
|
|
1787
|
+
return await (unstable_viteEnvironmentApi ? viteAppBuild(root, viteBuildOptions) : viteBuild(root, viteBuildOptions));
|
|
1862
1788
|
}
|
|
1863
1789
|
async function viteAppBuild(root, {
|
|
1864
1790
|
assetsInlineLimit,
|
|
@@ -2014,7 +1940,6 @@ var init_build = __esm({
|
|
|
2014
1940
|
init_plugin();
|
|
2015
1941
|
init_invariant();
|
|
2016
1942
|
init_vite();
|
|
2017
|
-
init_has_rsc_plugin();
|
|
2018
1943
|
}
|
|
2019
1944
|
});
|
|
2020
1945
|
|
|
@@ -2091,7 +2016,7 @@ var import_picocolors8 = __toESM(require("picocolors"));
|
|
|
2091
2016
|
// cli/commands.ts
|
|
2092
2017
|
var import_node_fs4 = require("fs");
|
|
2093
2018
|
var import_promises3 = require("fs/promises");
|
|
2094
|
-
var
|
|
2019
|
+
var path7 = __toESM(require("path"));
|
|
2095
2020
|
var import_package_json2 = __toESM(require("@npmcli/package-json"));
|
|
2096
2021
|
var import_exit_hook = __toESM(require("exit-hook"));
|
|
2097
2022
|
var import_picocolors7 = __toESM(require("picocolors"));
|
|
@@ -2176,7 +2101,6 @@ async function transpile(tsx, options = {}) {
|
|
|
2176
2101
|
init_profiler();
|
|
2177
2102
|
init_typegen();
|
|
2178
2103
|
init_vite();
|
|
2179
|
-
init_has_rsc_plugin();
|
|
2180
2104
|
async function routes(rootDirectory, flags = {}) {
|
|
2181
2105
|
rootDirectory = resolveRootDirectory(rootDirectory, flags);
|
|
2182
2106
|
let configResult = await loadConfig({
|
|
@@ -2221,26 +2145,12 @@ var conjunctionListFormat = new Intl.ListFormat("en", {
|
|
|
2221
2145
|
type: "conjunction"
|
|
2222
2146
|
});
|
|
2223
2147
|
async function generateEntry(entry, rootDirectory, flags = {}) {
|
|
2224
|
-
rootDirectory = resolveRootDirectory(rootDirectory, flags);
|
|
2225
|
-
if (await hasReactRouterRscPlugin({
|
|
2226
|
-
root: rootDirectory,
|
|
2227
|
-
viteBuildOptions: {
|
|
2228
|
-
config: flags.config,
|
|
2229
|
-
mode: flags.mode
|
|
2230
|
-
}
|
|
2231
|
-
})) {
|
|
2232
|
-
console.error(
|
|
2233
|
-
import_picocolors7.default.red(
|
|
2234
|
-
`The reveal command is currently not supported in RSC Framework Mode.`
|
|
2235
|
-
)
|
|
2236
|
-
);
|
|
2237
|
-
process.exit(1);
|
|
2238
|
-
}
|
|
2239
2148
|
if (!entry) {
|
|
2240
2149
|
await generateEntry("entry.client", rootDirectory, flags);
|
|
2241
2150
|
await generateEntry("entry.server", rootDirectory, flags);
|
|
2242
2151
|
return;
|
|
2243
2152
|
}
|
|
2153
|
+
rootDirectory = resolveRootDirectory(rootDirectory, flags);
|
|
2244
2154
|
let configResult = await loadConfig({
|
|
2245
2155
|
rootDirectory,
|
|
2246
2156
|
mode: flags.mode ?? "production"
|
|
@@ -2264,14 +2174,14 @@ async function generateEntry(entry, rootDirectory, flags = {}) {
|
|
|
2264
2174
|
console.error(import_picocolors7.default.red(`No default server entry detected.`));
|
|
2265
2175
|
return;
|
|
2266
2176
|
}
|
|
2267
|
-
let defaultsDirectory =
|
|
2268
|
-
|
|
2177
|
+
let defaultsDirectory = path7.resolve(
|
|
2178
|
+
path7.dirname(require.resolve("@react-router/dev/package.json")),
|
|
2269
2179
|
"dist",
|
|
2270
2180
|
"config",
|
|
2271
2181
|
"defaults"
|
|
2272
2182
|
);
|
|
2273
|
-
let defaultEntryClient =
|
|
2274
|
-
let defaultEntryServer =
|
|
2183
|
+
let defaultEntryClient = path7.resolve(defaultsDirectory, "entry.client.tsx");
|
|
2184
|
+
let defaultEntryServer = path7.resolve(
|
|
2275
2185
|
defaultsDirectory,
|
|
2276
2186
|
`entry.server.node.tsx`
|
|
2277
2187
|
);
|
|
@@ -2280,7 +2190,7 @@ async function generateEntry(entry, rootDirectory, flags = {}) {
|
|
|
2280
2190
|
let useTypeScript = flags.typescript ?? true;
|
|
2281
2191
|
let outputExtension = useTypeScript ? "tsx" : "jsx";
|
|
2282
2192
|
let outputEntry = `${entry}.${outputExtension}`;
|
|
2283
|
-
let outputFile =
|
|
2193
|
+
let outputFile = path7.resolve(appDirectory, outputEntry);
|
|
2284
2194
|
if (!useTypeScript) {
|
|
2285
2195
|
let javascript = await transpile(contents, {
|
|
2286
2196
|
cwd: rootDirectory,
|
|
@@ -2292,7 +2202,7 @@ async function generateEntry(entry, rootDirectory, flags = {}) {
|
|
|
2292
2202
|
}
|
|
2293
2203
|
console.log(
|
|
2294
2204
|
import_picocolors7.default.blue(
|
|
2295
|
-
`Entry file ${entry} created at ${
|
|
2205
|
+
`Entry file ${entry} created at ${path7.relative(
|
|
2296
2206
|
rootDirectory,
|
|
2297
2207
|
outputFile
|
|
2298
2208
|
)}.`
|
|
@@ -2301,16 +2211,16 @@ async function generateEntry(entry, rootDirectory, flags = {}) {
|
|
|
2301
2211
|
}
|
|
2302
2212
|
function resolveRootDirectory(root, flags) {
|
|
2303
2213
|
if (root) {
|
|
2304
|
-
return
|
|
2214
|
+
return path7.resolve(root);
|
|
2305
2215
|
}
|
|
2306
|
-
return process.env.REACT_ROUTER_ROOT || (flags?.config ?
|
|
2216
|
+
return process.env.REACT_ROUTER_ROOT || (flags?.config ? path7.dirname(path7.resolve(flags.config)) : process.cwd());
|
|
2307
2217
|
}
|
|
2308
2218
|
async function checkForEntry(rootDirectory, appDirectory, entries2) {
|
|
2309
2219
|
for (let entry of entries2) {
|
|
2310
|
-
let entryPath =
|
|
2220
|
+
let entryPath = path7.resolve(appDirectory, entry);
|
|
2311
2221
|
let exists = (0, import_node_fs4.existsSync)(entryPath);
|
|
2312
2222
|
if (exists) {
|
|
2313
|
-
let relative7 =
|
|
2223
|
+
let relative7 = path7.relative(rootDirectory, entryPath);
|
|
2314
2224
|
console.error(import_picocolors7.default.red(`Entry file ${relative7} already exists.`));
|
|
2315
2225
|
return process.exit(1);
|
|
2316
2226
|
}
|
|
@@ -24,11 +24,7 @@ setServerCallback(
|
|
|
24
24
|
);
|
|
25
25
|
|
|
26
26
|
createFromReadableStream<RSCPayload>(getRSCStream()).then((payload) => {
|
|
27
|
-
|
|
28
|
-
startTransition(async () => {
|
|
29
|
-
const formState =
|
|
30
|
-
payload.type === "render" ? await payload.formState : undefined;
|
|
31
|
-
|
|
27
|
+
startTransition(() => {
|
|
32
28
|
hydrateRoot(
|
|
33
29
|
document,
|
|
34
30
|
<StrictMode>
|
|
@@ -37,10 +33,6 @@ createFromReadableStream<RSCPayload>(getRSCStream()).then((payload) => {
|
|
|
37
33
|
createFromReadableStream={createFromReadableStream}
|
|
38
34
|
/>
|
|
39
35
|
</StrictMode>,
|
|
40
|
-
{
|
|
41
|
-
// @ts-expect-error - no types for this yet
|
|
42
|
-
formState,
|
|
43
|
-
},
|
|
44
36
|
);
|
|
45
37
|
});
|
|
46
38
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createTemporaryReferenceSet,
|
|
3
3
|
decodeAction,
|
|
4
|
-
decodeFormState,
|
|
5
4
|
decodeReply,
|
|
6
5
|
loadServerAction,
|
|
7
6
|
renderToReadableStream,
|
|
@@ -9,18 +8,15 @@ import {
|
|
|
9
8
|
import { unstable_matchRSCServerRequest as matchRSCServerRequest } from "react-router";
|
|
10
9
|
|
|
11
10
|
import routes from "virtual:react-router/unstable_rsc/routes";
|
|
12
|
-
import basename from "virtual:react-router/unstable_rsc/basename";
|
|
13
11
|
|
|
14
12
|
export async function fetchServer(request: Request) {
|
|
15
13
|
return await matchRSCServerRequest({
|
|
16
14
|
createTemporaryReferenceSet,
|
|
17
|
-
decodeAction,
|
|
18
|
-
decodeFormState,
|
|
19
15
|
decodeReply,
|
|
16
|
+
decodeAction,
|
|
20
17
|
loadServerAction,
|
|
21
18
|
request,
|
|
22
19
|
routes,
|
|
23
|
-
basename,
|
|
24
20
|
generateResponse(match, options) {
|
|
25
21
|
return new Response(renderToReadableStream(match.payload, options), {
|
|
26
22
|
status: match.statusCode,
|
|
@@ -36,7 +32,3 @@ export default async function handler(request: Request) {
|
|
|
36
32
|
>("ssr", "index");
|
|
37
33
|
return ssr.default(request, fetchServer);
|
|
38
34
|
}
|
|
39
|
-
|
|
40
|
-
if (import.meta.hot) {
|
|
41
|
-
import.meta.hot.accept();
|
|
42
|
-
}
|
|
@@ -12,22 +12,16 @@ export default async function handler(
|
|
|
12
12
|
) {
|
|
13
13
|
const bootstrapScriptContent =
|
|
14
14
|
await import.meta.viteRsc.loadBootstrapScriptContent("index");
|
|
15
|
-
|
|
16
15
|
return routeRSCServerRequest({
|
|
17
16
|
request,
|
|
18
17
|
fetchServer,
|
|
19
18
|
createFromReadableStream,
|
|
20
|
-
|
|
21
|
-
const payload = await getPayload();
|
|
22
|
-
const formState =
|
|
23
|
-
payload.type === "render" ? await payload.formState : undefined;
|
|
24
|
-
|
|
19
|
+
renderHTML(getPayload) {
|
|
25
20
|
return ReactDomServer.renderToReadableStream(
|
|
26
21
|
<RSCStaticRouter getPayload={getPayload} />,
|
|
27
22
|
{
|
|
28
23
|
bootstrapScriptContent,
|
|
29
24
|
signal: request.signal,
|
|
30
|
-
formState,
|
|
31
25
|
},
|
|
32
26
|
);
|
|
33
27
|
},
|
|
@@ -16,7 +16,7 @@ export default function handleRequest(
|
|
|
16
16
|
routerContext: EntryContext,
|
|
17
17
|
loadContext: AppLoadContext,
|
|
18
18
|
// If you have middleware enabled:
|
|
19
|
-
// loadContext:
|
|
19
|
+
// loadContext: unstable_RouterContextProvider
|
|
20
20
|
) {
|
|
21
21
|
return new Promise((resolve, reject) => {
|
|
22
22
|
let shellRendered = false;
|
package/dist/config.d.ts
CHANGED
package/dist/config.js
CHANGED