@react-router/dev 0.0.0-experimental-4a4201184 → 0.0.0-experimental-ae6d61df4
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 +198 -85
- package/dist/config/default-rsc-entries/entry.client.tsx +9 -1
- package/dist/config/default-rsc-entries/entry.rsc.tsx +9 -1
- package/dist/config/default-rsc-entries/entry.ssr.tsx +7 -1
- package/dist/config.d.ts +4 -0
- package/dist/config.js +1 -1
- package/dist/internal.js +372 -108
- package/dist/routes.js +1 -1
- package/dist/vite/cloudflare.js +21 -6
- package/dist/vite.js +309 -240
- package/package.json +11 -7
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-ae6d61df4
|
|
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
|
+
([path9, message]) => `Path: routes.${path9}
|
|
221
221
|
${message}`
|
|
222
222
|
) : []
|
|
223
223
|
].flat().join("\n\n")
|
|
@@ -311,7 +311,8 @@ async function resolveConfig({
|
|
|
311
311
|
root,
|
|
312
312
|
viteNodeContext,
|
|
313
313
|
reactRouterConfigFile,
|
|
314
|
-
skipRoutes
|
|
314
|
+
skipRoutes,
|
|
315
|
+
validateConfig
|
|
315
316
|
}) {
|
|
316
317
|
let reactRouterUserConfig = {};
|
|
317
318
|
if (reactRouterConfigFile) {
|
|
@@ -329,6 +330,12 @@ async function resolveConfig({
|
|
|
329
330
|
return err(`${reactRouterConfigFile} must export a config`);
|
|
330
331
|
}
|
|
331
332
|
reactRouterUserConfig = configModule.default;
|
|
333
|
+
if (validateConfig) {
|
|
334
|
+
const error = validateConfig(reactRouterUserConfig);
|
|
335
|
+
if (error) {
|
|
336
|
+
return err(error);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
332
339
|
} catch (error) {
|
|
333
340
|
return err(`Error loading ${reactRouterConfigFile}: ${error}`);
|
|
334
341
|
}
|
|
@@ -417,7 +424,7 @@ async function resolveConfig({
|
|
|
417
424
|
}
|
|
418
425
|
let appDirectory = import_pathe3.default.resolve(root, userAppDirectory || "app");
|
|
419
426
|
let buildDirectory = import_pathe3.default.resolve(root, userBuildDirectory);
|
|
420
|
-
let rootRouteFile = findEntry(appDirectory, "root");
|
|
427
|
+
let rootRouteFile = findEntry(appDirectory, "root", { absolute: true });
|
|
421
428
|
if (!rootRouteFile) {
|
|
422
429
|
let rootRouteDisplayPath = import_pathe3.default.relative(
|
|
423
430
|
root,
|
|
@@ -458,7 +465,7 @@ async function resolveConfig({
|
|
|
458
465
|
{
|
|
459
466
|
id: "root",
|
|
460
467
|
path: "",
|
|
461
|
-
file: rootRouteFile,
|
|
468
|
+
file: import_pathe3.default.relative(appDirectory, rootRouteFile),
|
|
462
469
|
children: result.routeConfig
|
|
463
470
|
}
|
|
464
471
|
];
|
|
@@ -496,6 +503,7 @@ async function resolveConfig({
|
|
|
496
503
|
serverBundles,
|
|
497
504
|
serverModuleFormat,
|
|
498
505
|
ssr,
|
|
506
|
+
unstable_rootRouteFile: rootRouteFile,
|
|
499
507
|
unstable_routeConfig: routeConfig
|
|
500
508
|
});
|
|
501
509
|
for (let preset of reactRouterUserConfig.presets ?? []) {
|
|
@@ -507,7 +515,8 @@ async function createConfigLoader({
|
|
|
507
515
|
rootDirectory: root,
|
|
508
516
|
watch: watch2,
|
|
509
517
|
mode,
|
|
510
|
-
skipRoutes
|
|
518
|
+
skipRoutes,
|
|
519
|
+
validateConfig
|
|
511
520
|
}) {
|
|
512
521
|
root = import_pathe3.default.normalize(root ?? process.env.REACT_ROUTER_ROOT ?? process.cwd());
|
|
513
522
|
let vite2 = await import("vite");
|
|
@@ -526,7 +535,13 @@ async function createConfigLoader({
|
|
|
526
535
|
});
|
|
527
536
|
};
|
|
528
537
|
updateReactRouterConfigFile();
|
|
529
|
-
let getConfig = () => resolveConfig({
|
|
538
|
+
let getConfig = () => resolveConfig({
|
|
539
|
+
root,
|
|
540
|
+
viteNodeContext,
|
|
541
|
+
reactRouterConfigFile,
|
|
542
|
+
skipRoutes,
|
|
543
|
+
validateConfig
|
|
544
|
+
});
|
|
530
545
|
let appDirectory;
|
|
531
546
|
let initialConfigResult = await getConfig();
|
|
532
547
|
if (!initialConfigResult.ok) {
|
|
@@ -548,11 +563,11 @@ async function createConfigLoader({
|
|
|
548
563
|
if (!fsWatcher) {
|
|
549
564
|
fsWatcher = import_chokidar.default.watch([root, appDirectory], {
|
|
550
565
|
ignoreInitial: true,
|
|
551
|
-
ignored: (
|
|
552
|
-
let dirname5 = import_pathe3.default.dirname(
|
|
566
|
+
ignored: (path9) => {
|
|
567
|
+
let dirname5 = import_pathe3.default.dirname(path9);
|
|
553
568
|
return !dirname5.startsWith(appDirectory) && // Ensure we're only watching files outside of the app directory
|
|
554
569
|
// that are at the root level, not nested in subdirectories
|
|
555
|
-
|
|
570
|
+
path9 !== root && // Watch the root directory itself
|
|
556
571
|
dirname5 !== root;
|
|
557
572
|
}
|
|
558
573
|
});
|
|
@@ -798,7 +813,8 @@ var init_profiler = __esm({
|
|
|
798
813
|
async function createContext2({
|
|
799
814
|
rootDirectory,
|
|
800
815
|
watch: watch2,
|
|
801
|
-
mode
|
|
816
|
+
mode,
|
|
817
|
+
rsc
|
|
802
818
|
}) {
|
|
803
819
|
const configLoader = await createConfigLoader({ rootDirectory, mode, watch: watch2 });
|
|
804
820
|
const configResult = await configLoader.getConfig();
|
|
@@ -809,7 +825,8 @@ async function createContext2({
|
|
|
809
825
|
return {
|
|
810
826
|
configLoader,
|
|
811
827
|
rootDirectory,
|
|
812
|
-
config
|
|
828
|
+
config,
|
|
829
|
+
rsc
|
|
813
830
|
};
|
|
814
831
|
}
|
|
815
832
|
var init_context = __esm({
|
|
@@ -876,7 +893,7 @@ function fullpath(lineage2) {
|
|
|
876
893
|
if (lineage2.length === 1 && route?.id === "root") return "/";
|
|
877
894
|
const isLayout = route && route.index !== true && route.path === void 0;
|
|
878
895
|
if (isLayout) return void 0;
|
|
879
|
-
return "/" + lineage2.map((route2) => route2.path?.replace(/^\//, "")?.replace(/\/$/, "")).filter((
|
|
896
|
+
return "/" + lineage2.map((route2) => route2.path?.replace(/^\//, "")?.replace(/\/$/, "")).filter((path9) => path9 !== void 0 && path9 !== "").join("/");
|
|
880
897
|
}
|
|
881
898
|
var init_route = __esm({
|
|
882
899
|
"typegen/route.ts"() {
|
|
@@ -1036,8 +1053,8 @@ function routeFilesType({
|
|
|
1036
1053
|
);
|
|
1037
1054
|
}
|
|
1038
1055
|
function isInAppDirectory(ctx, routeFile) {
|
|
1039
|
-
const
|
|
1040
|
-
return
|
|
1056
|
+
const path9 = Path3.resolve(ctx.config.appDirectory, routeFile);
|
|
1057
|
+
return path9.startsWith(ctx.config.appDirectory);
|
|
1041
1058
|
}
|
|
1042
1059
|
function getRouteAnnotations({
|
|
1043
1060
|
ctx,
|
|
@@ -1102,7 +1119,7 @@ function getRouteAnnotations({
|
|
|
1102
1119
|
module: Module
|
|
1103
1120
|
}>
|
|
1104
1121
|
` + "\n\n" + generate(matchesType).code + "\n\n" + import_dedent.default`
|
|
1105
|
-
type Annotations = GetAnnotations<Info & { module: Module, matches: Matches }>;
|
|
1122
|
+
type Annotations = GetAnnotations<Info & { module: Module, matches: Matches }, ${ctx.rsc}>;
|
|
1106
1123
|
|
|
1107
1124
|
export namespace Route {
|
|
1108
1125
|
// links
|
|
@@ -1149,21 +1166,21 @@ function getRouteAnnotations({
|
|
|
1149
1166
|
return { filename: filename2, content };
|
|
1150
1167
|
}
|
|
1151
1168
|
function relativeImportSource(from, to) {
|
|
1152
|
-
let
|
|
1153
|
-
let extension = Path3.extname(
|
|
1154
|
-
|
|
1155
|
-
if (!
|
|
1169
|
+
let path9 = Path3.relative(Path3.dirname(from), to);
|
|
1170
|
+
let extension = Path3.extname(path9);
|
|
1171
|
+
path9 = Path3.join(Path3.dirname(path9), Pathe.filename(path9));
|
|
1172
|
+
if (!path9.startsWith("../")) path9 = "./" + path9;
|
|
1156
1173
|
if (!extension || /\.(js|ts)x?$/.test(extension)) {
|
|
1157
1174
|
extension = ".js";
|
|
1158
1175
|
}
|
|
1159
|
-
return
|
|
1176
|
+
return path9 + extension;
|
|
1160
1177
|
}
|
|
1161
1178
|
function rootDirsPath(ctx, typesPath) {
|
|
1162
1179
|
const rel = Path3.relative(typesDirectory(ctx), typesPath);
|
|
1163
1180
|
return Path3.join(ctx.rootDirectory, rel);
|
|
1164
1181
|
}
|
|
1165
|
-
function paramsType(
|
|
1166
|
-
const params = parse2(
|
|
1182
|
+
function paramsType(path9) {
|
|
1183
|
+
const params = parse2(path9);
|
|
1167
1184
|
return t2.tsTypeLiteral(
|
|
1168
1185
|
Object.entries(params).map(([param, isRequired]) => {
|
|
1169
1186
|
const property = t2.tsPropertySignature(
|
|
@@ -1226,8 +1243,8 @@ async function write(...files) {
|
|
|
1226
1243
|
})
|
|
1227
1244
|
);
|
|
1228
1245
|
}
|
|
1229
|
-
async function run(rootDirectory, { mode }) {
|
|
1230
|
-
const ctx = await createContext2({ rootDirectory, mode, watch: false });
|
|
1246
|
+
async function run(rootDirectory, { mode, rsc }) {
|
|
1247
|
+
const ctx = await createContext2({ rootDirectory, mode, rsc, watch: false });
|
|
1231
1248
|
await import_promises.default.rm(typesDirectory(ctx), { recursive: true, force: true });
|
|
1232
1249
|
await write(
|
|
1233
1250
|
generateFuture(ctx),
|
|
@@ -1235,8 +1252,8 @@ async function run(rootDirectory, { mode }) {
|
|
|
1235
1252
|
...generateRoutes(ctx)
|
|
1236
1253
|
);
|
|
1237
1254
|
}
|
|
1238
|
-
async function watch(rootDirectory, { mode, logger }) {
|
|
1239
|
-
const ctx = await createContext2({ rootDirectory, mode, watch: true });
|
|
1255
|
+
async function watch(rootDirectory, { mode, logger, rsc }) {
|
|
1256
|
+
const ctx = await createContext2({ rootDirectory, mode, rsc, watch: true });
|
|
1240
1257
|
await import_promises.default.rm(typesDirectory(ctx), { recursive: true, force: true });
|
|
1241
1258
|
await write(
|
|
1242
1259
|
generateFuture(ctx),
|
|
@@ -1284,6 +1301,36 @@ var init_typegen = __esm({
|
|
|
1284
1301
|
}
|
|
1285
1302
|
});
|
|
1286
1303
|
|
|
1304
|
+
// vite/has-rsc-plugin.ts
|
|
1305
|
+
async function hasReactRouterRscPlugin({
|
|
1306
|
+
root,
|
|
1307
|
+
viteBuildOptions: { config, logLevel, mode }
|
|
1308
|
+
}) {
|
|
1309
|
+
const vite2 = await import("vite");
|
|
1310
|
+
const viteConfig = await vite2.resolveConfig(
|
|
1311
|
+
{
|
|
1312
|
+
configFile: config,
|
|
1313
|
+
logLevel,
|
|
1314
|
+
mode: mode ?? "production",
|
|
1315
|
+
root
|
|
1316
|
+
},
|
|
1317
|
+
"build",
|
|
1318
|
+
// command
|
|
1319
|
+
"production",
|
|
1320
|
+
// default mode
|
|
1321
|
+
"production"
|
|
1322
|
+
// default NODE_ENV
|
|
1323
|
+
);
|
|
1324
|
+
return viteConfig.plugins.some(
|
|
1325
|
+
(plugin) => plugin?.name === "react-router/rsc"
|
|
1326
|
+
);
|
|
1327
|
+
}
|
|
1328
|
+
var init_has_rsc_plugin = __esm({
|
|
1329
|
+
"vite/has-rsc-plugin.ts"() {
|
|
1330
|
+
"use strict";
|
|
1331
|
+
}
|
|
1332
|
+
});
|
|
1333
|
+
|
|
1287
1334
|
// vite/node-adapter.ts
|
|
1288
1335
|
var import_node_events, import_node_tls, import_node_stream, import_set_cookie_parser, import_node;
|
|
1289
1336
|
var init_node_adapter = __esm({
|
|
@@ -1337,6 +1384,16 @@ var init_virtual_module = __esm({
|
|
|
1337
1384
|
}
|
|
1338
1385
|
});
|
|
1339
1386
|
|
|
1387
|
+
// vite/resolve-relative-route-file-path.ts
|
|
1388
|
+
var import_pathe4;
|
|
1389
|
+
var init_resolve_relative_route_file_path = __esm({
|
|
1390
|
+
"vite/resolve-relative-route-file-path.ts"() {
|
|
1391
|
+
"use strict";
|
|
1392
|
+
import_pathe4 = __toESM(require("pathe"));
|
|
1393
|
+
init_vite();
|
|
1394
|
+
}
|
|
1395
|
+
});
|
|
1396
|
+
|
|
1340
1397
|
// vite/combine-urls.ts
|
|
1341
1398
|
var init_combine_urls = __esm({
|
|
1342
1399
|
"vite/combine-urls.ts"() {
|
|
@@ -1354,6 +1411,13 @@ var init_remove_exports = __esm({
|
|
|
1354
1411
|
}
|
|
1355
1412
|
});
|
|
1356
1413
|
|
|
1414
|
+
// vite/has-dependency.ts
|
|
1415
|
+
var init_has_dependency = __esm({
|
|
1416
|
+
"vite/has-dependency.ts"() {
|
|
1417
|
+
"use strict";
|
|
1418
|
+
}
|
|
1419
|
+
});
|
|
1420
|
+
|
|
1357
1421
|
// vite/cache.ts
|
|
1358
1422
|
var init_cache = __esm({
|
|
1359
1423
|
"vite/cache.ts"() {
|
|
@@ -1409,6 +1473,17 @@ var init_route_chunks = __esm({
|
|
|
1409
1473
|
}
|
|
1410
1474
|
});
|
|
1411
1475
|
|
|
1476
|
+
// vite/optimize-deps-entries.ts
|
|
1477
|
+
var import_tinyglobby;
|
|
1478
|
+
var init_optimize_deps_entries = __esm({
|
|
1479
|
+
"vite/optimize-deps-entries.ts"() {
|
|
1480
|
+
"use strict";
|
|
1481
|
+
import_tinyglobby = require("tinyglobby");
|
|
1482
|
+
init_resolve_relative_route_file_path();
|
|
1483
|
+
init_vite();
|
|
1484
|
+
}
|
|
1485
|
+
});
|
|
1486
|
+
|
|
1412
1487
|
// vite/with-props.ts
|
|
1413
1488
|
var init_with_props = __esm({
|
|
1414
1489
|
"vite/with-props.ts"() {
|
|
@@ -1424,6 +1499,16 @@ var init_validate_plugin_order = __esm({
|
|
|
1424
1499
|
}
|
|
1425
1500
|
});
|
|
1426
1501
|
|
|
1502
|
+
// vite/plugins/warn-on-client-source-maps.ts
|
|
1503
|
+
var import_picocolors4;
|
|
1504
|
+
var init_warn_on_client_source_maps = __esm({
|
|
1505
|
+
"vite/plugins/warn-on-client-source-maps.ts"() {
|
|
1506
|
+
"use strict";
|
|
1507
|
+
import_picocolors4 = __toESM(require("picocolors"));
|
|
1508
|
+
init_invariant();
|
|
1509
|
+
}
|
|
1510
|
+
});
|
|
1511
|
+
|
|
1427
1512
|
// vite/plugin.ts
|
|
1428
1513
|
async function resolveViteConfig({
|
|
1429
1514
|
configFile,
|
|
@@ -1466,8 +1551,8 @@ function getServerBundleIds(ctx) {
|
|
|
1466
1551
|
async function cleanBuildDirectory(viteConfig, ctx) {
|
|
1467
1552
|
let buildDirectory = ctx.reactRouterConfig.buildDirectory;
|
|
1468
1553
|
let isWithinRoot = () => {
|
|
1469
|
-
let relativePath =
|
|
1470
|
-
return !relativePath.startsWith("..") && !
|
|
1554
|
+
let relativePath = path7.relative(ctx.rootDirectory, buildDirectory);
|
|
1555
|
+
return !relativePath.startsWith("..") && !path7.isAbsolute(relativePath);
|
|
1471
1556
|
};
|
|
1472
1557
|
if (viteConfig.build.emptyOutDir ?? isWithinRoot()) {
|
|
1473
1558
|
await (0, import_promises2.rm)(buildDirectory, { force: true, recursive: true });
|
|
@@ -1478,7 +1563,7 @@ async function cleanViteManifests(environmentsOptions, ctx) {
|
|
|
1478
1563
|
([environmentName, options]) => {
|
|
1479
1564
|
let outDir = options.build?.outDir;
|
|
1480
1565
|
invariant(outDir, `Expected build.outDir for ${environmentName}`);
|
|
1481
|
-
return
|
|
1566
|
+
return path7.join(outDir, ".vite/manifest.json");
|
|
1482
1567
|
}
|
|
1483
1568
|
);
|
|
1484
1569
|
await Promise.all(
|
|
@@ -1488,7 +1573,7 @@ async function cleanViteManifests(environmentsOptions, ctx) {
|
|
|
1488
1573
|
if (!ctx.viteManifestEnabled) {
|
|
1489
1574
|
await (0, import_promises2.rm)(viteManifestPath, { force: true, recursive: true });
|
|
1490
1575
|
}
|
|
1491
|
-
let viteDir =
|
|
1576
|
+
let viteDir = path7.dirname(viteManifestPath);
|
|
1492
1577
|
let viteDirFiles = await (0, import_promises2.readdir)(viteDir, { recursive: true });
|
|
1493
1578
|
if (viteDirFiles.length === 0) {
|
|
1494
1579
|
await (0, import_promises2.rm)(viteDir, { force: true, recursive: true });
|
|
@@ -1505,10 +1590,10 @@ function mergeEnvironmentOptions(base, ...overrides) {
|
|
|
1505
1590
|
}
|
|
1506
1591
|
async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
|
|
1507
1592
|
let { serverBuildFile, serverModuleFormat } = ctx.reactRouterConfig;
|
|
1508
|
-
let packageRoot =
|
|
1593
|
+
let packageRoot = path7.dirname(
|
|
1509
1594
|
require.resolve("@react-router/dev/package.json")
|
|
1510
1595
|
);
|
|
1511
|
-
let { moduleSyncEnabled } = await import(`file:///${
|
|
1596
|
+
let { moduleSyncEnabled } = await import(`file:///${path7.join(packageRoot, "module-sync-enabled/index.mjs")}`);
|
|
1512
1597
|
let vite2 = getVite();
|
|
1513
1598
|
function getBaseOptions({
|
|
1514
1599
|
viteUserConfig
|
|
@@ -1587,7 +1672,7 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
|
|
|
1587
1672
|
ctx.entryClientFilePath,
|
|
1588
1673
|
...Object.values(ctx.reactRouterConfig.routes).flatMap(
|
|
1589
1674
|
(route) => {
|
|
1590
|
-
let routeFilePath =
|
|
1675
|
+
let routeFilePath = path7.resolve(
|
|
1591
1676
|
ctx.reactRouterConfig.appDirectory,
|
|
1592
1677
|
route.file
|
|
1593
1678
|
);
|
|
@@ -1611,7 +1696,7 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
|
|
|
1611
1696
|
) : null;
|
|
1612
1697
|
let routeChunkSuffix = routeChunkName ? `-${(0, import_kebabCase.default)(routeChunkName)}` : "";
|
|
1613
1698
|
let assetsDir = (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi ? viteUserConfig?.environments?.client?.build?.assetsDir : null) ?? viteUserConfig?.build?.assetsDir ?? "assets";
|
|
1614
|
-
return
|
|
1699
|
+
return path7.posix.join(
|
|
1615
1700
|
assetsDir,
|
|
1616
1701
|
`[name]${routeChunkSuffix}-[hash].js`
|
|
1617
1702
|
);
|
|
@@ -1661,22 +1746,21 @@ function resolveEnvironmentsOptions(environmentResolvers, resolverOptions) {
|
|
|
1661
1746
|
function isNonNullable(x) {
|
|
1662
1747
|
return x != null;
|
|
1663
1748
|
}
|
|
1664
|
-
var import_node_crypto, import_node_fs3, import_promises2,
|
|
1749
|
+
var import_node_crypto, import_node_fs3, import_promises2, path7, url, babel2, 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;
|
|
1665
1750
|
var init_plugin = __esm({
|
|
1666
1751
|
"vite/plugin.ts"() {
|
|
1667
1752
|
"use strict";
|
|
1668
1753
|
import_node_crypto = require("crypto");
|
|
1669
1754
|
import_node_fs3 = require("fs");
|
|
1670
1755
|
import_promises2 = require("fs/promises");
|
|
1671
|
-
|
|
1756
|
+
path7 = __toESM(require("path"));
|
|
1672
1757
|
url = __toESM(require("url"));
|
|
1673
1758
|
babel2 = __toESM(require("@babel/core"));
|
|
1674
1759
|
import_react_router2 = require("react-router");
|
|
1675
1760
|
import_es_module_lexer = require("es-module-lexer");
|
|
1676
|
-
import_tinyglobby = require("tinyglobby");
|
|
1677
1761
|
import_pick3 = __toESM(require("lodash/pick"));
|
|
1678
1762
|
import_jsesc = __toESM(require("jsesc"));
|
|
1679
|
-
|
|
1763
|
+
import_picocolors5 = __toESM(require("picocolors"));
|
|
1680
1764
|
import_kebabCase = __toESM(require("lodash/kebabCase"));
|
|
1681
1765
|
init_typegen();
|
|
1682
1766
|
init_invariant();
|
|
@@ -1685,14 +1769,18 @@ var init_plugin = __esm({
|
|
|
1685
1769
|
init_styles();
|
|
1686
1770
|
init_virtual_module();
|
|
1687
1771
|
init_resolve_file_url();
|
|
1772
|
+
init_resolve_relative_route_file_path();
|
|
1688
1773
|
init_combine_urls();
|
|
1689
1774
|
init_remove_exports();
|
|
1690
1775
|
init_ssr_externals();
|
|
1776
|
+
init_has_dependency();
|
|
1691
1777
|
init_route_chunks();
|
|
1692
1778
|
init_vite();
|
|
1693
1779
|
init_config();
|
|
1780
|
+
init_optimize_deps_entries();
|
|
1694
1781
|
init_with_props();
|
|
1695
1782
|
init_validate_plugin_order();
|
|
1783
|
+
init_warn_on_client_source_maps();
|
|
1696
1784
|
CLIENT_NON_COMPONENT_EXPORTS = [
|
|
1697
1785
|
"clientAction",
|
|
1698
1786
|
"clientLoader",
|
|
@@ -1718,20 +1806,20 @@ var init_plugin = __esm({
|
|
|
1718
1806
|
serverManifest: create("server-manifest"),
|
|
1719
1807
|
browserManifest: create("browser-manifest")
|
|
1720
1808
|
};
|
|
1721
|
-
getServerBuildDirectory = (reactRouterConfig, { serverBundleId } = {}) =>
|
|
1809
|
+
getServerBuildDirectory = (reactRouterConfig, { serverBundleId } = {}) => path7.join(
|
|
1722
1810
|
reactRouterConfig.buildDirectory,
|
|
1723
1811
|
"server",
|
|
1724
1812
|
...serverBundleId ? [serverBundleId] : []
|
|
1725
1813
|
);
|
|
1726
|
-
getClientBuildDirectory = (reactRouterConfig) =>
|
|
1727
|
-
defaultEntriesDir =
|
|
1728
|
-
|
|
1814
|
+
getClientBuildDirectory = (reactRouterConfig) => path7.join(reactRouterConfig.buildDirectory, "client");
|
|
1815
|
+
defaultEntriesDir = path7.resolve(
|
|
1816
|
+
path7.dirname(require.resolve("@react-router/dev/package.json")),
|
|
1729
1817
|
"dist",
|
|
1730
1818
|
"config",
|
|
1731
1819
|
"defaults"
|
|
1732
1820
|
);
|
|
1733
1821
|
defaultEntries = (0, import_node_fs3.readdirSync)(defaultEntriesDir).map(
|
|
1734
|
-
(filename2) =>
|
|
1822
|
+
(filename2) => path7.join(defaultEntriesDir, filename2)
|
|
1735
1823
|
);
|
|
1736
1824
|
invariant(defaultEntries.length > 0, "No default entries found");
|
|
1737
1825
|
REACT_REFRESH_HEADER = `
|
|
@@ -1777,14 +1865,14 @@ async function build(root, viteBuildOptions) {
|
|
|
1777
1865
|
throw new Error(configResult.error);
|
|
1778
1866
|
}
|
|
1779
1867
|
let config = configResult.value;
|
|
1780
|
-
let unstable_viteEnvironmentApi = config.future.unstable_viteEnvironmentApi;
|
|
1781
1868
|
let viteMajor = parseInt(vite2.version.split(".")[0], 10);
|
|
1782
|
-
if (unstable_viteEnvironmentApi && viteMajor === 5) {
|
|
1869
|
+
if (config.future.unstable_viteEnvironmentApi && viteMajor === 5) {
|
|
1783
1870
|
throw new Error(
|
|
1784
1871
|
"The future.unstable_viteEnvironmentApi option is not supported in Vite 5"
|
|
1785
1872
|
);
|
|
1786
1873
|
}
|
|
1787
|
-
|
|
1874
|
+
const useViteEnvironmentApi = config.future.unstable_viteEnvironmentApi || await hasReactRouterRscPlugin({ root, viteBuildOptions });
|
|
1875
|
+
return await (useViteEnvironmentApi ? viteAppBuild(root, viteBuildOptions) : viteBuild(root, viteBuildOptions));
|
|
1788
1876
|
}
|
|
1789
1877
|
async function viteAppBuild(root, {
|
|
1790
1878
|
assetsInlineLimit,
|
|
@@ -1874,7 +1962,7 @@ async function viteBuild(root, {
|
|
|
1874
1962
|
let ctx = extractPluginContext(viteConfig);
|
|
1875
1963
|
if (!ctx) {
|
|
1876
1964
|
console.error(
|
|
1877
|
-
|
|
1965
|
+
import_picocolors6.default.red("React Router Vite plugin not found in Vite config")
|
|
1878
1966
|
);
|
|
1879
1967
|
process.exit(1);
|
|
1880
1968
|
}
|
|
@@ -1931,15 +2019,16 @@ async function viteBuild(root, {
|
|
|
1931
2019
|
viteConfig
|
|
1932
2020
|
});
|
|
1933
2021
|
}
|
|
1934
|
-
var
|
|
2022
|
+
var import_picocolors6;
|
|
1935
2023
|
var init_build = __esm({
|
|
1936
2024
|
"vite/build.ts"() {
|
|
1937
2025
|
"use strict";
|
|
1938
|
-
|
|
2026
|
+
import_picocolors6 = __toESM(require("picocolors"));
|
|
1939
2027
|
init_config();
|
|
1940
2028
|
init_plugin();
|
|
1941
2029
|
init_invariant();
|
|
1942
2030
|
init_vite();
|
|
2031
|
+
init_has_rsc_plugin();
|
|
1943
2032
|
}
|
|
1944
2033
|
});
|
|
1945
2034
|
|
|
@@ -1975,7 +2064,7 @@ async function dev(root, {
|
|
|
1975
2064
|
(plugin) => plugin.name === "react-router" || plugin.name === "react-router/rsc"
|
|
1976
2065
|
)) {
|
|
1977
2066
|
console.error(
|
|
1978
|
-
|
|
2067
|
+
import_picocolors7.default.red("React Router Vite plugin not found in Vite config")
|
|
1979
2068
|
);
|
|
1980
2069
|
process.exit(1);
|
|
1981
2070
|
}
|
|
@@ -1998,11 +2087,11 @@ async function dev(root, {
|
|
|
1998
2087
|
];
|
|
1999
2088
|
server.bindCLIShortcuts({ print: true, customShortcuts });
|
|
2000
2089
|
}
|
|
2001
|
-
var
|
|
2090
|
+
var import_picocolors7;
|
|
2002
2091
|
var init_dev = __esm({
|
|
2003
2092
|
"vite/dev.ts"() {
|
|
2004
2093
|
"use strict";
|
|
2005
|
-
|
|
2094
|
+
import_picocolors7 = __toESM(require("picocolors"));
|
|
2006
2095
|
init_vite();
|
|
2007
2096
|
init_profiler();
|
|
2008
2097
|
}
|
|
@@ -2011,15 +2100,15 @@ var init_dev = __esm({
|
|
|
2011
2100
|
// cli/run.ts
|
|
2012
2101
|
var import_arg = __toESM(require("arg"));
|
|
2013
2102
|
var import_semver = __toESM(require("semver"));
|
|
2014
|
-
var
|
|
2103
|
+
var import_picocolors9 = __toESM(require("picocolors"));
|
|
2015
2104
|
|
|
2016
2105
|
// cli/commands.ts
|
|
2017
2106
|
var import_node_fs4 = require("fs");
|
|
2018
2107
|
var import_promises3 = require("fs/promises");
|
|
2019
|
-
var
|
|
2108
|
+
var path8 = __toESM(require("path"));
|
|
2020
2109
|
var import_package_json2 = __toESM(require("@npmcli/package-json"));
|
|
2021
2110
|
var import_exit_hook = __toESM(require("exit-hook"));
|
|
2022
|
-
var
|
|
2111
|
+
var import_picocolors8 = __toESM(require("picocolors"));
|
|
2023
2112
|
var import_react_router3 = require("react-router");
|
|
2024
2113
|
init_config();
|
|
2025
2114
|
|
|
@@ -2101,6 +2190,7 @@ async function transpile(tsx, options = {}) {
|
|
|
2101
2190
|
init_profiler();
|
|
2102
2191
|
init_typegen();
|
|
2103
2192
|
init_vite();
|
|
2193
|
+
init_has_rsc_plugin();
|
|
2104
2194
|
async function routes(rootDirectory, flags = {}) {
|
|
2105
2195
|
rootDirectory = resolveRootDirectory(rootDirectory, flags);
|
|
2106
2196
|
let configResult = await loadConfig({
|
|
@@ -2108,7 +2198,7 @@ async function routes(rootDirectory, flags = {}) {
|
|
|
2108
2198
|
mode: flags.mode ?? "production"
|
|
2109
2199
|
});
|
|
2110
2200
|
if (!configResult.ok) {
|
|
2111
|
-
console.error(
|
|
2201
|
+
console.error(import_picocolors8.default.red(configResult.error));
|
|
2112
2202
|
process.exit(1);
|
|
2113
2203
|
}
|
|
2114
2204
|
let format = flags.json ? "json" : "jsx";
|
|
@@ -2145,18 +2235,32 @@ var conjunctionListFormat = new Intl.ListFormat("en", {
|
|
|
2145
2235
|
type: "conjunction"
|
|
2146
2236
|
});
|
|
2147
2237
|
async function generateEntry(entry, rootDirectory, flags = {}) {
|
|
2238
|
+
rootDirectory = resolveRootDirectory(rootDirectory, flags);
|
|
2239
|
+
if (await hasReactRouterRscPlugin({
|
|
2240
|
+
root: rootDirectory,
|
|
2241
|
+
viteBuildOptions: {
|
|
2242
|
+
config: flags.config,
|
|
2243
|
+
mode: flags.mode
|
|
2244
|
+
}
|
|
2245
|
+
})) {
|
|
2246
|
+
console.error(
|
|
2247
|
+
import_picocolors8.default.red(
|
|
2248
|
+
`The reveal command is currently not supported in RSC Framework Mode.`
|
|
2249
|
+
)
|
|
2250
|
+
);
|
|
2251
|
+
process.exit(1);
|
|
2252
|
+
}
|
|
2148
2253
|
if (!entry) {
|
|
2149
2254
|
await generateEntry("entry.client", rootDirectory, flags);
|
|
2150
2255
|
await generateEntry("entry.server", rootDirectory, flags);
|
|
2151
2256
|
return;
|
|
2152
2257
|
}
|
|
2153
|
-
rootDirectory = resolveRootDirectory(rootDirectory, flags);
|
|
2154
2258
|
let configResult = await loadConfig({
|
|
2155
2259
|
rootDirectory,
|
|
2156
2260
|
mode: flags.mode ?? "production"
|
|
2157
2261
|
});
|
|
2158
2262
|
if (!configResult.ok) {
|
|
2159
|
-
console.error(
|
|
2263
|
+
console.error(import_picocolors8.default.red(configResult.error));
|
|
2160
2264
|
return;
|
|
2161
2265
|
}
|
|
2162
2266
|
let appDirectory = configResult.value.appDirectory;
|
|
@@ -2164,24 +2268,24 @@ async function generateEntry(entry, rootDirectory, flags = {}) {
|
|
|
2164
2268
|
let entriesArray = Array.from(entries);
|
|
2165
2269
|
let list = conjunctionListFormat.format(entriesArray);
|
|
2166
2270
|
console.error(
|
|
2167
|
-
|
|
2271
|
+
import_picocolors8.default.red(`Invalid entry file. Valid entry files are ${list}`)
|
|
2168
2272
|
);
|
|
2169
2273
|
return;
|
|
2170
2274
|
}
|
|
2171
2275
|
let pkgJson = await import_package_json2.default.load(rootDirectory);
|
|
2172
2276
|
let deps = pkgJson.content.dependencies ?? {};
|
|
2173
2277
|
if (!deps["@react-router/node"]) {
|
|
2174
|
-
console.error(
|
|
2278
|
+
console.error(import_picocolors8.default.red(`No default server entry detected.`));
|
|
2175
2279
|
return;
|
|
2176
2280
|
}
|
|
2177
|
-
let defaultsDirectory =
|
|
2178
|
-
|
|
2281
|
+
let defaultsDirectory = path8.resolve(
|
|
2282
|
+
path8.dirname(require.resolve("@react-router/dev/package.json")),
|
|
2179
2283
|
"dist",
|
|
2180
2284
|
"config",
|
|
2181
2285
|
"defaults"
|
|
2182
2286
|
);
|
|
2183
|
-
let defaultEntryClient =
|
|
2184
|
-
let defaultEntryServer =
|
|
2287
|
+
let defaultEntryClient = path8.resolve(defaultsDirectory, "entry.client.tsx");
|
|
2288
|
+
let defaultEntryServer = path8.resolve(
|
|
2185
2289
|
defaultsDirectory,
|
|
2186
2290
|
`entry.server.node.tsx`
|
|
2187
2291
|
);
|
|
@@ -2190,7 +2294,7 @@ async function generateEntry(entry, rootDirectory, flags = {}) {
|
|
|
2190
2294
|
let useTypeScript = flags.typescript ?? true;
|
|
2191
2295
|
let outputExtension = useTypeScript ? "tsx" : "jsx";
|
|
2192
2296
|
let outputEntry = `${entry}.${outputExtension}`;
|
|
2193
|
-
let outputFile =
|
|
2297
|
+
let outputFile = path8.resolve(appDirectory, outputEntry);
|
|
2194
2298
|
if (!useTypeScript) {
|
|
2195
2299
|
let javascript = await transpile(contents, {
|
|
2196
2300
|
cwd: rootDirectory,
|
|
@@ -2201,8 +2305,8 @@ async function generateEntry(entry, rootDirectory, flags = {}) {
|
|
|
2201
2305
|
await (0, import_promises3.writeFile)(outputFile, contents, "utf-8");
|
|
2202
2306
|
}
|
|
2203
2307
|
console.log(
|
|
2204
|
-
|
|
2205
|
-
`Entry file ${entry} created at ${
|
|
2308
|
+
import_picocolors8.default.blue(
|
|
2309
|
+
`Entry file ${entry} created at ${path8.relative(
|
|
2206
2310
|
rootDirectory,
|
|
2207
2311
|
outputFile
|
|
2208
2312
|
)}.`
|
|
@@ -2211,17 +2315,17 @@ async function generateEntry(entry, rootDirectory, flags = {}) {
|
|
|
2211
2315
|
}
|
|
2212
2316
|
function resolveRootDirectory(root, flags) {
|
|
2213
2317
|
if (root) {
|
|
2214
|
-
return
|
|
2318
|
+
return path8.resolve(root);
|
|
2215
2319
|
}
|
|
2216
|
-
return process.env.REACT_ROUTER_ROOT || (flags?.config ?
|
|
2320
|
+
return process.env.REACT_ROUTER_ROOT || (flags?.config ? path8.dirname(path8.resolve(flags.config)) : process.cwd());
|
|
2217
2321
|
}
|
|
2218
2322
|
async function checkForEntry(rootDirectory, appDirectory, entries2) {
|
|
2219
2323
|
for (let entry of entries2) {
|
|
2220
|
-
let entryPath =
|
|
2324
|
+
let entryPath = path8.resolve(appDirectory, entry);
|
|
2221
2325
|
let exists = (0, import_node_fs4.existsSync)(entryPath);
|
|
2222
2326
|
if (exists) {
|
|
2223
|
-
let relative7 =
|
|
2224
|
-
console.error(
|
|
2327
|
+
let relative7 = path8.relative(rootDirectory, entryPath);
|
|
2328
|
+
console.error(import_picocolors8.default.red(`Entry file ${relative7} already exists.`));
|
|
2225
2329
|
return process.exit(1);
|
|
2226
2330
|
}
|
|
2227
2331
|
}
|
|
@@ -2238,12 +2342,20 @@ async function createClientEntry(rootDirectory, appDirectory, inputFile) {
|
|
|
2238
2342
|
}
|
|
2239
2343
|
async function typegen(root, flags) {
|
|
2240
2344
|
root = resolveRootDirectory(root, flags);
|
|
2345
|
+
const rsc = await hasReactRouterRscPlugin({
|
|
2346
|
+
root,
|
|
2347
|
+
viteBuildOptions: {
|
|
2348
|
+
config: flags.config,
|
|
2349
|
+
mode: flags.mode
|
|
2350
|
+
}
|
|
2351
|
+
});
|
|
2241
2352
|
if (flags.watch) {
|
|
2242
2353
|
await preloadVite();
|
|
2243
2354
|
const vite2 = getVite();
|
|
2244
2355
|
const logger = vite2.createLogger("info", { prefix: "[react-router]" });
|
|
2245
2356
|
await watch(root, {
|
|
2246
2357
|
mode: flags.mode ?? "development",
|
|
2358
|
+
rsc,
|
|
2247
2359
|
logger
|
|
2248
2360
|
});
|
|
2249
2361
|
await new Promise(() => {
|
|
@@ -2251,20 +2363,21 @@ async function typegen(root, flags) {
|
|
|
2251
2363
|
return;
|
|
2252
2364
|
}
|
|
2253
2365
|
await run(root, {
|
|
2254
|
-
mode: flags.mode ?? "production"
|
|
2366
|
+
mode: flags.mode ?? "production",
|
|
2367
|
+
rsc
|
|
2255
2368
|
});
|
|
2256
2369
|
}
|
|
2257
2370
|
|
|
2258
2371
|
// cli/run.ts
|
|
2259
2372
|
var helpText = `
|
|
2260
|
-
${
|
|
2373
|
+
${import_picocolors9.default.blueBright("react-router")}
|
|
2261
2374
|
|
|
2262
|
-
${
|
|
2263
|
-
$ react-router build [${
|
|
2264
|
-
$ react-router dev [${
|
|
2265
|
-
$ react-router routes [${
|
|
2375
|
+
${import_picocolors9.default.underline("Usage")}:
|
|
2376
|
+
$ react-router build [${import_picocolors9.default.yellowBright("projectDir")}]
|
|
2377
|
+
$ react-router dev [${import_picocolors9.default.yellowBright("projectDir")}]
|
|
2378
|
+
$ react-router routes [${import_picocolors9.default.yellowBright("projectDir")}]
|
|
2266
2379
|
|
|
2267
|
-
${
|
|
2380
|
+
${import_picocolors9.default.underline("Options")}:
|
|
2268
2381
|
--help, -h Print this help message and exit
|
|
2269
2382
|
--version, -v Print the CLI version and exit
|
|
2270
2383
|
--no-color Disable ANSI colors in console output
|
|
@@ -2300,22 +2413,22 @@ ${import_picocolors8.default.blueBright("react-router")}
|
|
|
2300
2413
|
\`typegen\` Options:
|
|
2301
2414
|
--watch Automatically regenerate types whenever route config (\`routes.ts\`) or route modules change
|
|
2302
2415
|
|
|
2303
|
-
${
|
|
2416
|
+
${import_picocolors9.default.underline("Build your project")}:
|
|
2304
2417
|
|
|
2305
2418
|
$ react-router build
|
|
2306
2419
|
|
|
2307
|
-
${
|
|
2420
|
+
${import_picocolors9.default.underline("Run your project locally in development")}:
|
|
2308
2421
|
|
|
2309
2422
|
$ react-router dev
|
|
2310
2423
|
|
|
2311
|
-
${
|
|
2424
|
+
${import_picocolors9.default.underline("Show all routes in your app")}:
|
|
2312
2425
|
|
|
2313
2426
|
$ react-router routes
|
|
2314
2427
|
$ react-router routes my-app
|
|
2315
2428
|
$ react-router routes --json
|
|
2316
2429
|
$ react-router routes --config vite.react-router.config.ts
|
|
2317
2430
|
|
|
2318
|
-
${
|
|
2431
|
+
${import_picocolors9.default.underline("Reveal the used entry point")}:
|
|
2319
2432
|
|
|
2320
2433
|
$ react-router reveal entry.client
|
|
2321
2434
|
$ react-router reveal entry.server
|
|
@@ -2323,7 +2436,7 @@ ${import_picocolors8.default.blueBright("react-router")}
|
|
|
2323
2436
|
$ react-router reveal entry.server --no-typescript
|
|
2324
2437
|
$ react-router reveal entry.server --config vite.react-router.config.ts
|
|
2325
2438
|
|
|
2326
|
-
${
|
|
2439
|
+
${import_picocolors9.default.underline("Generate types for route modules")}:
|
|
2327
2440
|
|
|
2328
2441
|
$ react-router typegen
|
|
2329
2442
|
$ react-router typegen --watch
|