@react-router/dev 7.8.2 → 7.9.0-pre.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * @react-router/dev v7.8.2
3
+ * @react-router/dev v7.9.0-pre.1
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
- ([path8, message]) => `Path: routes.${path8}
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
  }
@@ -477,7 +484,7 @@ async function resolveConfig({
477
484
  }
478
485
  }
479
486
  let future = {
480
- unstable_middleware: reactRouterUserConfig.future?.unstable_middleware ?? false,
487
+ v8_middleware: reactRouterUserConfig.future?.v8_middleware ?? false,
481
488
  unstable_optimizeDeps: reactRouterUserConfig.future?.unstable_optimizeDeps ?? false,
482
489
  unstable_splitRouteModules: reactRouterUserConfig.future?.unstable_splitRouteModules ?? false,
483
490
  unstable_subResourceIntegrity: reactRouterUserConfig.future?.unstable_subResourceIntegrity ?? false,
@@ -507,7 +514,8 @@ async function createConfigLoader({
507
514
  rootDirectory: root,
508
515
  watch: watch2,
509
516
  mode,
510
- skipRoutes
517
+ skipRoutes,
518
+ validateConfig
511
519
  }) {
512
520
  root = import_pathe3.default.normalize(root ?? process.env.REACT_ROUTER_ROOT ?? process.cwd());
513
521
  let vite2 = await import("vite");
@@ -526,7 +534,13 @@ async function createConfigLoader({
526
534
  });
527
535
  };
528
536
  updateReactRouterConfigFile();
529
- let getConfig = () => resolveConfig({ root, viteNodeContext, reactRouterConfigFile, skipRoutes });
537
+ let getConfig = () => resolveConfig({
538
+ root,
539
+ viteNodeContext,
540
+ reactRouterConfigFile,
541
+ skipRoutes,
542
+ validateConfig
543
+ });
530
544
  let appDirectory;
531
545
  let initialConfigResult = await getConfig();
532
546
  if (!initialConfigResult.ok) {
@@ -548,11 +562,11 @@ async function createConfigLoader({
548
562
  if (!fsWatcher) {
549
563
  fsWatcher = import_chokidar.default.watch([root, appDirectory], {
550
564
  ignoreInitial: true,
551
- ignored: (path8) => {
552
- let dirname5 = import_pathe3.default.dirname(path8);
565
+ ignored: (path9) => {
566
+ let dirname5 = import_pathe3.default.dirname(path9);
553
567
  return !dirname5.startsWith(appDirectory) && // Ensure we're only watching files outside of the app directory
554
568
  // that are at the root level, not nested in subdirectories
555
- path8 !== root && // Watch the root directory itself
569
+ path9 !== root && // Watch the root directory itself
556
570
  dirname5 !== root;
557
571
  }
558
572
  });
@@ -876,7 +890,7 @@ function fullpath(lineage2) {
876
890
  if (lineage2.length === 1 && route?.id === "root") return "/";
877
891
  const isLayout = route && route.index !== true && route.path === void 0;
878
892
  if (isLayout) return void 0;
879
- return "/" + lineage2.map((route2) => route2.path?.replace(/^\//, "")?.replace(/\/$/, "")).filter((path8) => path8 !== void 0 && path8 !== "").join("/");
893
+ return "/" + lineage2.map((route2) => route2.path?.replace(/^\//, "")?.replace(/\/$/, "")).filter((path9) => path9 !== void 0 && path9 !== "").join("/");
880
894
  }
881
895
  var init_route = __esm({
882
896
  "typegen/route.ts"() {
@@ -897,7 +911,7 @@ function generateFuture(ctx) {
897
911
 
898
912
  declare module "react-router" {
899
913
  interface Future {
900
- unstable_middleware: ${ctx.config.future.unstable_middleware}
914
+ middleware: ${ctx.config.future.v8_middleware}
901
915
  }
902
916
  }
903
917
  `;
@@ -1036,8 +1050,8 @@ function routeFilesType({
1036
1050
  );
1037
1051
  }
1038
1052
  function isInAppDirectory(ctx, routeFile) {
1039
- const path8 = Path3.resolve(ctx.config.appDirectory, routeFile);
1040
- return path8.startsWith(ctx.config.appDirectory);
1053
+ const path9 = Path3.resolve(ctx.config.appDirectory, routeFile);
1054
+ return path9.startsWith(ctx.config.appDirectory);
1041
1055
  }
1042
1056
  function getRouteAnnotations({
1043
1057
  ctx,
@@ -1118,11 +1132,11 @@ function getRouteAnnotations({
1118
1132
  export type HeadersArgs = Annotations["HeadersArgs"];
1119
1133
  export type HeadersFunction = Annotations["HeadersFunction"];
1120
1134
 
1121
- // unstable_middleware
1122
- export type unstable_MiddlewareFunction = Annotations["unstable_MiddlewareFunction"];
1135
+ // middleware
1136
+ export type MiddlewareFunction = Annotations["MiddlewareFunction"];
1123
1137
 
1124
- // unstable_clientMiddleware
1125
- export type unstable_ClientMiddlewareFunction = Annotations["unstable_ClientMiddlewareFunction"];
1138
+ // clientMiddleware
1139
+ export type ClientMiddlewareFunction = Annotations["ClientMiddlewareFunction"];
1126
1140
 
1127
1141
  // loader
1128
1142
  export type LoaderArgs = Annotations["LoaderArgs"];
@@ -1149,21 +1163,21 @@ function getRouteAnnotations({
1149
1163
  return { filename: filename2, content };
1150
1164
  }
1151
1165
  function relativeImportSource(from, to) {
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;
1166
+ let path9 = Path3.relative(Path3.dirname(from), to);
1167
+ let extension = Path3.extname(path9);
1168
+ path9 = Path3.join(Path3.dirname(path9), Pathe.filename(path9));
1169
+ if (!path9.startsWith("../")) path9 = "./" + path9;
1156
1170
  if (!extension || /\.(js|ts)x?$/.test(extension)) {
1157
1171
  extension = ".js";
1158
1172
  }
1159
- return path8 + extension;
1173
+ return path9 + extension;
1160
1174
  }
1161
1175
  function rootDirsPath(ctx, typesPath) {
1162
1176
  const rel = Path3.relative(typesDirectory(ctx), typesPath);
1163
1177
  return Path3.join(ctx.rootDirectory, rel);
1164
1178
  }
1165
- function paramsType(path8) {
1166
- const params = parse2(path8);
1179
+ function paramsType(path9) {
1180
+ const params = parse2(path9);
1167
1181
  return t2.tsTypeLiteral(
1168
1182
  Object.entries(params).map(([param, isRequired]) => {
1169
1183
  const property = t2.tsPropertySignature(
@@ -1284,6 +1298,36 @@ var init_typegen = __esm({
1284
1298
  }
1285
1299
  });
1286
1300
 
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
+
1287
1331
  // vite/node-adapter.ts
1288
1332
  var import_node_events, import_node_tls, import_node_stream, import_set_cookie_parser, import_node;
1289
1333
  var init_node_adapter = __esm({
@@ -1337,6 +1381,16 @@ var init_virtual_module = __esm({
1337
1381
  }
1338
1382
  });
1339
1383
 
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
+
1340
1394
  // vite/combine-urls.ts
1341
1395
  var init_combine_urls = __esm({
1342
1396
  "vite/combine-urls.ts"() {
@@ -1354,6 +1408,13 @@ var init_remove_exports = __esm({
1354
1408
  }
1355
1409
  });
1356
1410
 
1411
+ // vite/has-dependency.ts
1412
+ var init_has_dependency = __esm({
1413
+ "vite/has-dependency.ts"() {
1414
+ "use strict";
1415
+ }
1416
+ });
1417
+
1357
1418
  // vite/cache.ts
1358
1419
  var init_cache = __esm({
1359
1420
  "vite/cache.ts"() {
@@ -1393,7 +1454,7 @@ var init_route_chunks = __esm({
1393
1454
  routeChunkExportNames = [
1394
1455
  "clientAction",
1395
1456
  "clientLoader",
1396
- "unstable_clientMiddleware",
1457
+ "clientMiddleware",
1397
1458
  "HydrateFallback"
1398
1459
  ];
1399
1460
  mainChunkName = "main";
@@ -1403,12 +1464,23 @@ var init_route_chunks = __esm({
1403
1464
  main: `${routeChunkQueryStringPrefix}main`,
1404
1465
  clientAction: `${routeChunkQueryStringPrefix}clientAction`,
1405
1466
  clientLoader: `${routeChunkQueryStringPrefix}clientLoader`,
1406
- unstable_clientMiddleware: `${routeChunkQueryStringPrefix}unstable_clientMiddleware`,
1467
+ clientMiddleware: `${routeChunkQueryStringPrefix}clientMiddleware`,
1407
1468
  HydrateFallback: `${routeChunkQueryStringPrefix}HydrateFallback`
1408
1469
  };
1409
1470
  }
1410
1471
  });
1411
1472
 
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
+
1412
1484
  // vite/with-props.ts
1413
1485
  var init_with_props = __esm({
1414
1486
  "vite/with-props.ts"() {
@@ -1424,6 +1496,16 @@ var init_validate_plugin_order = __esm({
1424
1496
  }
1425
1497
  });
1426
1498
 
1499
+ // vite/plugins/warn-on-client-source-maps.ts
1500
+ var import_picocolors4;
1501
+ var init_warn_on_client_source_maps = __esm({
1502
+ "vite/plugins/warn-on-client-source-maps.ts"() {
1503
+ "use strict";
1504
+ import_picocolors4 = __toESM(require("picocolors"));
1505
+ init_invariant();
1506
+ }
1507
+ });
1508
+
1427
1509
  // vite/plugin.ts
1428
1510
  async function resolveViteConfig({
1429
1511
  configFile,
@@ -1466,8 +1548,8 @@ function getServerBundleIds(ctx) {
1466
1548
  async function cleanBuildDirectory(viteConfig, ctx) {
1467
1549
  let buildDirectory = ctx.reactRouterConfig.buildDirectory;
1468
1550
  let isWithinRoot = () => {
1469
- let relativePath = path6.relative(ctx.rootDirectory, buildDirectory);
1470
- return !relativePath.startsWith("..") && !path6.isAbsolute(relativePath);
1551
+ let relativePath = path7.relative(ctx.rootDirectory, buildDirectory);
1552
+ return !relativePath.startsWith("..") && !path7.isAbsolute(relativePath);
1471
1553
  };
1472
1554
  if (viteConfig.build.emptyOutDir ?? isWithinRoot()) {
1473
1555
  await (0, import_promises2.rm)(buildDirectory, { force: true, recursive: true });
@@ -1478,7 +1560,7 @@ async function cleanViteManifests(environmentsOptions, ctx) {
1478
1560
  ([environmentName, options]) => {
1479
1561
  let outDir = options.build?.outDir;
1480
1562
  invariant(outDir, `Expected build.outDir for ${environmentName}`);
1481
- return path6.join(outDir, ".vite/manifest.json");
1563
+ return path7.join(outDir, ".vite/manifest.json");
1482
1564
  }
1483
1565
  );
1484
1566
  await Promise.all(
@@ -1488,7 +1570,7 @@ async function cleanViteManifests(environmentsOptions, ctx) {
1488
1570
  if (!ctx.viteManifestEnabled) {
1489
1571
  await (0, import_promises2.rm)(viteManifestPath, { force: true, recursive: true });
1490
1572
  }
1491
- let viteDir = path6.dirname(viteManifestPath);
1573
+ let viteDir = path7.dirname(viteManifestPath);
1492
1574
  let viteDirFiles = await (0, import_promises2.readdir)(viteDir, { recursive: true });
1493
1575
  if (viteDirFiles.length === 0) {
1494
1576
  await (0, import_promises2.rm)(viteDir, { force: true, recursive: true });
@@ -1505,10 +1587,10 @@ function mergeEnvironmentOptions(base, ...overrides) {
1505
1587
  }
1506
1588
  async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
1507
1589
  let { serverBuildFile, serverModuleFormat } = ctx.reactRouterConfig;
1508
- let packageRoot = path6.dirname(
1590
+ let packageRoot = path7.dirname(
1509
1591
  require.resolve("@react-router/dev/package.json")
1510
1592
  );
1511
- let { moduleSyncEnabled } = await import(`file:///${path6.join(packageRoot, "module-sync-enabled/index.mjs")}`);
1593
+ let { moduleSyncEnabled } = await import(`file:///${path7.join(packageRoot, "module-sync-enabled/index.mjs")}`);
1512
1594
  let vite2 = getVite();
1513
1595
  function getBaseOptions({
1514
1596
  viteUserConfig
@@ -1587,7 +1669,7 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
1587
1669
  ctx.entryClientFilePath,
1588
1670
  ...Object.values(ctx.reactRouterConfig.routes).flatMap(
1589
1671
  (route) => {
1590
- let routeFilePath = path6.resolve(
1672
+ let routeFilePath = path7.resolve(
1591
1673
  ctx.reactRouterConfig.appDirectory,
1592
1674
  route.file
1593
1675
  );
@@ -1611,7 +1693,7 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
1611
1693
  ) : null;
1612
1694
  let routeChunkSuffix = routeChunkName ? `-${(0, import_kebabCase.default)(routeChunkName)}` : "";
1613
1695
  let assetsDir = (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi ? viteUserConfig?.environments?.client?.build?.assetsDir : null) ?? viteUserConfig?.build?.assetsDir ?? "assets";
1614
- return path6.posix.join(
1696
+ return path7.posix.join(
1615
1697
  assetsDir,
1616
1698
  `[name]${routeChunkSuffix}-[hash].js`
1617
1699
  );
@@ -1661,22 +1743,21 @@ function resolveEnvironmentsOptions(environmentResolvers, resolverOptions) {
1661
1743
  function isNonNullable(x) {
1662
1744
  return x != null;
1663
1745
  }
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;
1746
+ 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
1747
  var init_plugin = __esm({
1666
1748
  "vite/plugin.ts"() {
1667
1749
  "use strict";
1668
1750
  import_node_crypto = require("crypto");
1669
1751
  import_node_fs3 = require("fs");
1670
1752
  import_promises2 = require("fs/promises");
1671
- path6 = __toESM(require("path"));
1753
+ path7 = __toESM(require("path"));
1672
1754
  url = __toESM(require("url"));
1673
1755
  babel2 = __toESM(require("@babel/core"));
1674
1756
  import_react_router2 = require("react-router");
1675
1757
  import_es_module_lexer = require("es-module-lexer");
1676
- import_tinyglobby = require("tinyglobby");
1677
1758
  import_pick3 = __toESM(require("lodash/pick"));
1678
1759
  import_jsesc = __toESM(require("jsesc"));
1679
- import_picocolors4 = __toESM(require("picocolors"));
1760
+ import_picocolors5 = __toESM(require("picocolors"));
1680
1761
  import_kebabCase = __toESM(require("lodash/kebabCase"));
1681
1762
  init_typegen();
1682
1763
  init_invariant();
@@ -1685,18 +1766,22 @@ var init_plugin = __esm({
1685
1766
  init_styles();
1686
1767
  init_virtual_module();
1687
1768
  init_resolve_file_url();
1769
+ init_resolve_relative_route_file_path();
1688
1770
  init_combine_urls();
1689
1771
  init_remove_exports();
1690
1772
  init_ssr_externals();
1773
+ init_has_dependency();
1691
1774
  init_route_chunks();
1692
1775
  init_vite();
1693
1776
  init_config();
1777
+ init_optimize_deps_entries();
1694
1778
  init_with_props();
1695
1779
  init_validate_plugin_order();
1780
+ init_warn_on_client_source_maps();
1696
1781
  CLIENT_NON_COMPONENT_EXPORTS = [
1697
1782
  "clientAction",
1698
1783
  "clientLoader",
1699
- "unstable_clientMiddleware",
1784
+ "clientMiddleware",
1700
1785
  "handle",
1701
1786
  "meta",
1702
1787
  "links",
@@ -1718,20 +1803,20 @@ var init_plugin = __esm({
1718
1803
  serverManifest: create("server-manifest"),
1719
1804
  browserManifest: create("browser-manifest")
1720
1805
  };
1721
- getServerBuildDirectory = (reactRouterConfig, { serverBundleId } = {}) => path6.join(
1806
+ getServerBuildDirectory = (reactRouterConfig, { serverBundleId } = {}) => path7.join(
1722
1807
  reactRouterConfig.buildDirectory,
1723
1808
  "server",
1724
1809
  ...serverBundleId ? [serverBundleId] : []
1725
1810
  );
1726
- getClientBuildDirectory = (reactRouterConfig) => path6.join(reactRouterConfig.buildDirectory, "client");
1727
- defaultEntriesDir = path6.resolve(
1728
- path6.dirname(require.resolve("@react-router/dev/package.json")),
1811
+ getClientBuildDirectory = (reactRouterConfig) => path7.join(reactRouterConfig.buildDirectory, "client");
1812
+ defaultEntriesDir = path7.resolve(
1813
+ path7.dirname(require.resolve("@react-router/dev/package.json")),
1729
1814
  "dist",
1730
1815
  "config",
1731
1816
  "defaults"
1732
1817
  );
1733
1818
  defaultEntries = (0, import_node_fs3.readdirSync)(defaultEntriesDir).map(
1734
- (filename2) => path6.join(defaultEntriesDir, filename2)
1819
+ (filename2) => path7.join(defaultEntriesDir, filename2)
1735
1820
  );
1736
1821
  invariant(defaultEntries.length > 0, "No default entries found");
1737
1822
  REACT_REFRESH_HEADER = `
@@ -1777,14 +1862,14 @@ async function build(root, viteBuildOptions) {
1777
1862
  throw new Error(configResult.error);
1778
1863
  }
1779
1864
  let config = configResult.value;
1780
- let unstable_viteEnvironmentApi = config.future.unstable_viteEnvironmentApi;
1781
1865
  let viteMajor = parseInt(vite2.version.split(".")[0], 10);
1782
- if (unstable_viteEnvironmentApi && viteMajor === 5) {
1866
+ if (config.future.unstable_viteEnvironmentApi && viteMajor === 5) {
1783
1867
  throw new Error(
1784
1868
  "The future.unstable_viteEnvironmentApi option is not supported in Vite 5"
1785
1869
  );
1786
1870
  }
1787
- return await (unstable_viteEnvironmentApi ? viteAppBuild(root, viteBuildOptions) : viteBuild(root, viteBuildOptions));
1871
+ const useViteEnvironmentApi = config.future.unstable_viteEnvironmentApi || await hasReactRouterRscPlugin({ root, viteBuildOptions });
1872
+ return await (useViteEnvironmentApi ? viteAppBuild(root, viteBuildOptions) : viteBuild(root, viteBuildOptions));
1788
1873
  }
1789
1874
  async function viteAppBuild(root, {
1790
1875
  assetsInlineLimit,
@@ -1874,7 +1959,7 @@ async function viteBuild(root, {
1874
1959
  let ctx = extractPluginContext(viteConfig);
1875
1960
  if (!ctx) {
1876
1961
  console.error(
1877
- import_picocolors5.default.red("React Router Vite plugin not found in Vite config")
1962
+ import_picocolors6.default.red("React Router Vite plugin not found in Vite config")
1878
1963
  );
1879
1964
  process.exit(1);
1880
1965
  }
@@ -1931,15 +2016,16 @@ async function viteBuild(root, {
1931
2016
  viteConfig
1932
2017
  });
1933
2018
  }
1934
- var import_picocolors5;
2019
+ var import_picocolors6;
1935
2020
  var init_build = __esm({
1936
2021
  "vite/build.ts"() {
1937
2022
  "use strict";
1938
- import_picocolors5 = __toESM(require("picocolors"));
2023
+ import_picocolors6 = __toESM(require("picocolors"));
1939
2024
  init_config();
1940
2025
  init_plugin();
1941
2026
  init_invariant();
1942
2027
  init_vite();
2028
+ init_has_rsc_plugin();
1943
2029
  }
1944
2030
  });
1945
2031
 
@@ -1975,7 +2061,7 @@ async function dev(root, {
1975
2061
  (plugin) => plugin.name === "react-router" || plugin.name === "react-router/rsc"
1976
2062
  )) {
1977
2063
  console.error(
1978
- import_picocolors6.default.red("React Router Vite plugin not found in Vite config")
2064
+ import_picocolors7.default.red("React Router Vite plugin not found in Vite config")
1979
2065
  );
1980
2066
  process.exit(1);
1981
2067
  }
@@ -1998,11 +2084,11 @@ async function dev(root, {
1998
2084
  ];
1999
2085
  server.bindCLIShortcuts({ print: true, customShortcuts });
2000
2086
  }
2001
- var import_picocolors6;
2087
+ var import_picocolors7;
2002
2088
  var init_dev = __esm({
2003
2089
  "vite/dev.ts"() {
2004
2090
  "use strict";
2005
- import_picocolors6 = __toESM(require("picocolors"));
2091
+ import_picocolors7 = __toESM(require("picocolors"));
2006
2092
  init_vite();
2007
2093
  init_profiler();
2008
2094
  }
@@ -2011,15 +2097,15 @@ var init_dev = __esm({
2011
2097
  // cli/run.ts
2012
2098
  var import_arg = __toESM(require("arg"));
2013
2099
  var import_semver = __toESM(require("semver"));
2014
- var import_picocolors8 = __toESM(require("picocolors"));
2100
+ var import_picocolors9 = __toESM(require("picocolors"));
2015
2101
 
2016
2102
  // cli/commands.ts
2017
2103
  var import_node_fs4 = require("fs");
2018
2104
  var import_promises3 = require("fs/promises");
2019
- var path7 = __toESM(require("path"));
2105
+ var path8 = __toESM(require("path"));
2020
2106
  var import_package_json2 = __toESM(require("@npmcli/package-json"));
2021
2107
  var import_exit_hook = __toESM(require("exit-hook"));
2022
- var import_picocolors7 = __toESM(require("picocolors"));
2108
+ var import_picocolors8 = __toESM(require("picocolors"));
2023
2109
  var import_react_router3 = require("react-router");
2024
2110
  init_config();
2025
2111
 
@@ -2101,6 +2187,7 @@ async function transpile(tsx, options = {}) {
2101
2187
  init_profiler();
2102
2188
  init_typegen();
2103
2189
  init_vite();
2190
+ init_has_rsc_plugin();
2104
2191
  async function routes(rootDirectory, flags = {}) {
2105
2192
  rootDirectory = resolveRootDirectory(rootDirectory, flags);
2106
2193
  let configResult = await loadConfig({
@@ -2108,7 +2195,7 @@ async function routes(rootDirectory, flags = {}) {
2108
2195
  mode: flags.mode ?? "production"
2109
2196
  });
2110
2197
  if (!configResult.ok) {
2111
- console.error(import_picocolors7.default.red(configResult.error));
2198
+ console.error(import_picocolors8.default.red(configResult.error));
2112
2199
  process.exit(1);
2113
2200
  }
2114
2201
  let format = flags.json ? "json" : "jsx";
@@ -2145,18 +2232,32 @@ var conjunctionListFormat = new Intl.ListFormat("en", {
2145
2232
  type: "conjunction"
2146
2233
  });
2147
2234
  async function generateEntry(entry, rootDirectory, flags = {}) {
2235
+ rootDirectory = resolveRootDirectory(rootDirectory, flags);
2236
+ if (await hasReactRouterRscPlugin({
2237
+ root: rootDirectory,
2238
+ viteBuildOptions: {
2239
+ config: flags.config,
2240
+ mode: flags.mode
2241
+ }
2242
+ })) {
2243
+ console.error(
2244
+ import_picocolors8.default.red(
2245
+ `The reveal command is currently not supported in RSC Framework Mode.`
2246
+ )
2247
+ );
2248
+ process.exit(1);
2249
+ }
2148
2250
  if (!entry) {
2149
2251
  await generateEntry("entry.client", rootDirectory, flags);
2150
2252
  await generateEntry("entry.server", rootDirectory, flags);
2151
2253
  return;
2152
2254
  }
2153
- rootDirectory = resolveRootDirectory(rootDirectory, flags);
2154
2255
  let configResult = await loadConfig({
2155
2256
  rootDirectory,
2156
2257
  mode: flags.mode ?? "production"
2157
2258
  });
2158
2259
  if (!configResult.ok) {
2159
- console.error(import_picocolors7.default.red(configResult.error));
2260
+ console.error(import_picocolors8.default.red(configResult.error));
2160
2261
  return;
2161
2262
  }
2162
2263
  let appDirectory = configResult.value.appDirectory;
@@ -2164,24 +2265,24 @@ async function generateEntry(entry, rootDirectory, flags = {}) {
2164
2265
  let entriesArray = Array.from(entries);
2165
2266
  let list = conjunctionListFormat.format(entriesArray);
2166
2267
  console.error(
2167
- import_picocolors7.default.red(`Invalid entry file. Valid entry files are ${list}`)
2268
+ import_picocolors8.default.red(`Invalid entry file. Valid entry files are ${list}`)
2168
2269
  );
2169
2270
  return;
2170
2271
  }
2171
2272
  let pkgJson = await import_package_json2.default.load(rootDirectory);
2172
2273
  let deps = pkgJson.content.dependencies ?? {};
2173
2274
  if (!deps["@react-router/node"]) {
2174
- console.error(import_picocolors7.default.red(`No default server entry detected.`));
2275
+ console.error(import_picocolors8.default.red(`No default server entry detected.`));
2175
2276
  return;
2176
2277
  }
2177
- let defaultsDirectory = path7.resolve(
2178
- path7.dirname(require.resolve("@react-router/dev/package.json")),
2278
+ let defaultsDirectory = path8.resolve(
2279
+ path8.dirname(require.resolve("@react-router/dev/package.json")),
2179
2280
  "dist",
2180
2281
  "config",
2181
2282
  "defaults"
2182
2283
  );
2183
- let defaultEntryClient = path7.resolve(defaultsDirectory, "entry.client.tsx");
2184
- let defaultEntryServer = path7.resolve(
2284
+ let defaultEntryClient = path8.resolve(defaultsDirectory, "entry.client.tsx");
2285
+ let defaultEntryServer = path8.resolve(
2185
2286
  defaultsDirectory,
2186
2287
  `entry.server.node.tsx`
2187
2288
  );
@@ -2190,7 +2291,7 @@ async function generateEntry(entry, rootDirectory, flags = {}) {
2190
2291
  let useTypeScript = flags.typescript ?? true;
2191
2292
  let outputExtension = useTypeScript ? "tsx" : "jsx";
2192
2293
  let outputEntry = `${entry}.${outputExtension}`;
2193
- let outputFile = path7.resolve(appDirectory, outputEntry);
2294
+ let outputFile = path8.resolve(appDirectory, outputEntry);
2194
2295
  if (!useTypeScript) {
2195
2296
  let javascript = await transpile(contents, {
2196
2297
  cwd: rootDirectory,
@@ -2201,8 +2302,8 @@ async function generateEntry(entry, rootDirectory, flags = {}) {
2201
2302
  await (0, import_promises3.writeFile)(outputFile, contents, "utf-8");
2202
2303
  }
2203
2304
  console.log(
2204
- import_picocolors7.default.blue(
2205
- `Entry file ${entry} created at ${path7.relative(
2305
+ import_picocolors8.default.blue(
2306
+ `Entry file ${entry} created at ${path8.relative(
2206
2307
  rootDirectory,
2207
2308
  outputFile
2208
2309
  )}.`
@@ -2211,17 +2312,17 @@ async function generateEntry(entry, rootDirectory, flags = {}) {
2211
2312
  }
2212
2313
  function resolveRootDirectory(root, flags) {
2213
2314
  if (root) {
2214
- return path7.resolve(root);
2315
+ return path8.resolve(root);
2215
2316
  }
2216
- return process.env.REACT_ROUTER_ROOT || (flags?.config ? path7.dirname(path7.resolve(flags.config)) : process.cwd());
2317
+ return process.env.REACT_ROUTER_ROOT || (flags?.config ? path8.dirname(path8.resolve(flags.config)) : process.cwd());
2217
2318
  }
2218
2319
  async function checkForEntry(rootDirectory, appDirectory, entries2) {
2219
2320
  for (let entry of entries2) {
2220
- let entryPath = path7.resolve(appDirectory, entry);
2321
+ let entryPath = path8.resolve(appDirectory, entry);
2221
2322
  let exists = (0, import_node_fs4.existsSync)(entryPath);
2222
2323
  if (exists) {
2223
- let relative7 = path7.relative(rootDirectory, entryPath);
2224
- console.error(import_picocolors7.default.red(`Entry file ${relative7} already exists.`));
2324
+ let relative7 = path8.relative(rootDirectory, entryPath);
2325
+ console.error(import_picocolors8.default.red(`Entry file ${relative7} already exists.`));
2225
2326
  return process.exit(1);
2226
2327
  }
2227
2328
  }
@@ -2257,14 +2358,14 @@ async function typegen(root, flags) {
2257
2358
 
2258
2359
  // cli/run.ts
2259
2360
  var helpText = `
2260
- ${import_picocolors8.default.blueBright("react-router")}
2361
+ ${import_picocolors9.default.blueBright("react-router")}
2261
2362
 
2262
- ${import_picocolors8.default.underline("Usage")}:
2263
- $ react-router build [${import_picocolors8.default.yellowBright("projectDir")}]
2264
- $ react-router dev [${import_picocolors8.default.yellowBright("projectDir")}]
2265
- $ react-router routes [${import_picocolors8.default.yellowBright("projectDir")}]
2363
+ ${import_picocolors9.default.underline("Usage")}:
2364
+ $ react-router build [${import_picocolors9.default.yellowBright("projectDir")}]
2365
+ $ react-router dev [${import_picocolors9.default.yellowBright("projectDir")}]
2366
+ $ react-router routes [${import_picocolors9.default.yellowBright("projectDir")}]
2266
2367
 
2267
- ${import_picocolors8.default.underline("Options")}:
2368
+ ${import_picocolors9.default.underline("Options")}:
2268
2369
  --help, -h Print this help message and exit
2269
2370
  --version, -v Print the CLI version and exit
2270
2371
  --no-color Disable ANSI colors in console output
@@ -2300,22 +2401,22 @@ ${import_picocolors8.default.blueBright("react-router")}
2300
2401
  \`typegen\` Options:
2301
2402
  --watch Automatically regenerate types whenever route config (\`routes.ts\`) or route modules change
2302
2403
 
2303
- ${import_picocolors8.default.underline("Build your project")}:
2404
+ ${import_picocolors9.default.underline("Build your project")}:
2304
2405
 
2305
2406
  $ react-router build
2306
2407
 
2307
- ${import_picocolors8.default.underline("Run your project locally in development")}:
2408
+ ${import_picocolors9.default.underline("Run your project locally in development")}:
2308
2409
 
2309
2410
  $ react-router dev
2310
2411
 
2311
- ${import_picocolors8.default.underline("Show all routes in your app")}:
2412
+ ${import_picocolors9.default.underline("Show all routes in your app")}:
2312
2413
 
2313
2414
  $ react-router routes
2314
2415
  $ react-router routes my-app
2315
2416
  $ react-router routes --json
2316
2417
  $ react-router routes --config vite.react-router.config.ts
2317
2418
 
2318
- ${import_picocolors8.default.underline("Reveal the used entry point")}:
2419
+ ${import_picocolors9.default.underline("Reveal the used entry point")}:
2319
2420
 
2320
2421
  $ react-router reveal entry.client
2321
2422
  $ react-router reveal entry.server
@@ -2323,7 +2424,7 @@ ${import_picocolors8.default.blueBright("react-router")}
2323
2424
  $ react-router reveal entry.server --no-typescript
2324
2425
  $ react-router reveal entry.server --config vite.react-router.config.ts
2325
2426
 
2326
- ${import_picocolors8.default.underline("Generate types for route modules")}:
2427
+ ${import_picocolors9.default.underline("Generate types for route modules")}:
2327
2428
 
2328
2429
  $ react-router typegen
2329
2430
  $ react-router typegen --watch