@react-router/dev 0.0.0-experimental-795b50c5b → 0.0.0-experimental-4cf5bd08c

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 v0.0.0-experimental-795b50c5b
3
+ * @react-router/dev v0.0.0-experimental-4cf5bd08c
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
  }
@@ -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
  ];
@@ -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
  });
@@ -798,7 +812,8 @@ var init_profiler = __esm({
798
812
  async function createContext2({
799
813
  rootDirectory,
800
814
  watch: watch2,
801
- mode
815
+ mode,
816
+ rsc
802
817
  }) {
803
818
  const configLoader = await createConfigLoader({ rootDirectory, mode, watch: watch2 });
804
819
  const configResult = await configLoader.getConfig();
@@ -809,7 +824,8 @@ async function createContext2({
809
824
  return {
810
825
  configLoader,
811
826
  rootDirectory,
812
- config
827
+ config,
828
+ rsc
813
829
  };
814
830
  }
815
831
  var init_context = __esm({
@@ -876,7 +892,7 @@ function fullpath(lineage2) {
876
892
  if (lineage2.length === 1 && route?.id === "root") return "/";
877
893
  const isLayout = route && route.index !== true && route.path === void 0;
878
894
  if (isLayout) return void 0;
879
- return "/" + lineage2.map((route2) => route2.path?.replace(/^\//, "")?.replace(/\/$/, "")).filter((path8) => path8 !== void 0 && path8 !== "").join("/");
895
+ return "/" + lineage2.map((route2) => route2.path?.replace(/^\//, "")?.replace(/\/$/, "")).filter((path9) => path9 !== void 0 && path9 !== "").join("/");
880
896
  }
881
897
  var init_route = __esm({
882
898
  "typegen/route.ts"() {
@@ -897,7 +913,7 @@ function generateFuture(ctx) {
897
913
 
898
914
  declare module "react-router" {
899
915
  interface Future {
900
- middleware: ${ctx.config.future.v8_middleware}
916
+ v8_middleware: ${ctx.config.future.v8_middleware}
901
917
  }
902
918
  }
903
919
  `;
@@ -1036,8 +1052,8 @@ function routeFilesType({
1036
1052
  );
1037
1053
  }
1038
1054
  function isInAppDirectory(ctx, routeFile) {
1039
- const path8 = Path3.resolve(ctx.config.appDirectory, routeFile);
1040
- return path8.startsWith(ctx.config.appDirectory);
1055
+ const path9 = Path3.resolve(ctx.config.appDirectory, routeFile);
1056
+ return path9.startsWith(ctx.config.appDirectory);
1041
1057
  }
1042
1058
  function getRouteAnnotations({
1043
1059
  ctx,
@@ -1102,7 +1118,7 @@ function getRouteAnnotations({
1102
1118
  module: Module
1103
1119
  }>
1104
1120
  ` + "\n\n" + generate(matchesType).code + "\n\n" + import_dedent.default`
1105
- type Annotations = GetAnnotations<Info & { module: Module, matches: Matches }>;
1121
+ type Annotations = GetAnnotations<Info & { module: Module, matches: Matches }, ${ctx.rsc}>;
1106
1122
 
1107
1123
  export namespace Route {
1108
1124
  // links
@@ -1149,21 +1165,21 @@ function getRouteAnnotations({
1149
1165
  return { filename: filename2, content };
1150
1166
  }
1151
1167
  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;
1168
+ let path9 = Path3.relative(Path3.dirname(from), to);
1169
+ let extension = Path3.extname(path9);
1170
+ path9 = Path3.join(Path3.dirname(path9), Pathe.filename(path9));
1171
+ if (!path9.startsWith("../")) path9 = "./" + path9;
1156
1172
  if (!extension || /\.(js|ts)x?$/.test(extension)) {
1157
1173
  extension = ".js";
1158
1174
  }
1159
- return path8 + extension;
1175
+ return path9 + extension;
1160
1176
  }
1161
1177
  function rootDirsPath(ctx, typesPath) {
1162
1178
  const rel = Path3.relative(typesDirectory(ctx), typesPath);
1163
1179
  return Path3.join(ctx.rootDirectory, rel);
1164
1180
  }
1165
- function paramsType(path8) {
1166
- const params = parse2(path8);
1181
+ function paramsType(path9) {
1182
+ const params = parse2(path9);
1167
1183
  return t2.tsTypeLiteral(
1168
1184
  Object.entries(params).map(([param, isRequired]) => {
1169
1185
  const property = t2.tsPropertySignature(
@@ -1226,8 +1242,8 @@ async function write(...files) {
1226
1242
  })
1227
1243
  );
1228
1244
  }
1229
- async function run(rootDirectory, { mode }) {
1230
- const ctx = await createContext2({ rootDirectory, mode, watch: false });
1245
+ async function run(rootDirectory, { mode, rsc }) {
1246
+ const ctx = await createContext2({ rootDirectory, mode, rsc, watch: false });
1231
1247
  await import_promises.default.rm(typesDirectory(ctx), { recursive: true, force: true });
1232
1248
  await write(
1233
1249
  generateFuture(ctx),
@@ -1235,8 +1251,8 @@ async function run(rootDirectory, { mode }) {
1235
1251
  ...generateRoutes(ctx)
1236
1252
  );
1237
1253
  }
1238
- async function watch(rootDirectory, { mode, logger }) {
1239
- const ctx = await createContext2({ rootDirectory, mode, watch: true });
1254
+ async function watch(rootDirectory, { mode, logger, rsc }) {
1255
+ const ctx = await createContext2({ rootDirectory, mode, rsc, watch: true });
1240
1256
  await import_promises.default.rm(typesDirectory(ctx), { recursive: true, force: true });
1241
1257
  await write(
1242
1258
  generateFuture(ctx),
@@ -1284,6 +1300,36 @@ var init_typegen = __esm({
1284
1300
  }
1285
1301
  });
1286
1302
 
1303
+ // vite/has-rsc-plugin.ts
1304
+ async function hasReactRouterRscPlugin({
1305
+ root,
1306
+ viteBuildOptions: { config, logLevel, mode }
1307
+ }) {
1308
+ const vite2 = await import("vite");
1309
+ const viteConfig = await vite2.resolveConfig(
1310
+ {
1311
+ configFile: config,
1312
+ logLevel,
1313
+ mode: mode ?? "production",
1314
+ root
1315
+ },
1316
+ "build",
1317
+ // command
1318
+ "production",
1319
+ // default mode
1320
+ "production"
1321
+ // default NODE_ENV
1322
+ );
1323
+ return viteConfig.plugins.some(
1324
+ (plugin) => plugin?.name === "react-router/rsc"
1325
+ );
1326
+ }
1327
+ var init_has_rsc_plugin = __esm({
1328
+ "vite/has-rsc-plugin.ts"() {
1329
+ "use strict";
1330
+ }
1331
+ });
1332
+
1287
1333
  // vite/node-adapter.ts
1288
1334
  var import_node_events, import_node_tls, import_node_stream, import_set_cookie_parser, import_node;
1289
1335
  var init_node_adapter = __esm({
@@ -1337,6 +1383,16 @@ var init_virtual_module = __esm({
1337
1383
  }
1338
1384
  });
1339
1385
 
1386
+ // vite/resolve-relative-route-file-path.ts
1387
+ var import_pathe4;
1388
+ var init_resolve_relative_route_file_path = __esm({
1389
+ "vite/resolve-relative-route-file-path.ts"() {
1390
+ "use strict";
1391
+ import_pathe4 = __toESM(require("pathe"));
1392
+ init_vite();
1393
+ }
1394
+ });
1395
+
1340
1396
  // vite/combine-urls.ts
1341
1397
  var init_combine_urls = __esm({
1342
1398
  "vite/combine-urls.ts"() {
@@ -1354,6 +1410,13 @@ var init_remove_exports = __esm({
1354
1410
  }
1355
1411
  });
1356
1412
 
1413
+ // vite/has-dependency.ts
1414
+ var init_has_dependency = __esm({
1415
+ "vite/has-dependency.ts"() {
1416
+ "use strict";
1417
+ }
1418
+ });
1419
+
1357
1420
  // vite/cache.ts
1358
1421
  var init_cache = __esm({
1359
1422
  "vite/cache.ts"() {
@@ -1409,6 +1472,17 @@ var init_route_chunks = __esm({
1409
1472
  }
1410
1473
  });
1411
1474
 
1475
+ // vite/optimize-deps-entries.ts
1476
+ var import_tinyglobby;
1477
+ var init_optimize_deps_entries = __esm({
1478
+ "vite/optimize-deps-entries.ts"() {
1479
+ "use strict";
1480
+ import_tinyglobby = require("tinyglobby");
1481
+ init_resolve_relative_route_file_path();
1482
+ init_vite();
1483
+ }
1484
+ });
1485
+
1412
1486
  // vite/with-props.ts
1413
1487
  var init_with_props = __esm({
1414
1488
  "vite/with-props.ts"() {
@@ -1417,6 +1491,13 @@ var init_with_props = __esm({
1417
1491
  }
1418
1492
  });
1419
1493
 
1494
+ // vite/load-dotenv.ts
1495
+ var init_load_dotenv = __esm({
1496
+ "vite/load-dotenv.ts"() {
1497
+ "use strict";
1498
+ }
1499
+ });
1500
+
1420
1501
  // vite/plugins/validate-plugin-order.ts
1421
1502
  var init_validate_plugin_order = __esm({
1422
1503
  "vite/plugins/validate-plugin-order.ts"() {
@@ -1424,6 +1505,16 @@ var init_validate_plugin_order = __esm({
1424
1505
  }
1425
1506
  });
1426
1507
 
1508
+ // vite/plugins/warn-on-client-source-maps.ts
1509
+ var import_picocolors4;
1510
+ var init_warn_on_client_source_maps = __esm({
1511
+ "vite/plugins/warn-on-client-source-maps.ts"() {
1512
+ "use strict";
1513
+ import_picocolors4 = __toESM(require("picocolors"));
1514
+ init_invariant();
1515
+ }
1516
+ });
1517
+
1427
1518
  // vite/plugin.ts
1428
1519
  async function resolveViteConfig({
1429
1520
  configFile,
@@ -1466,8 +1557,8 @@ function getServerBundleIds(ctx) {
1466
1557
  async function cleanBuildDirectory(viteConfig, ctx) {
1467
1558
  let buildDirectory = ctx.reactRouterConfig.buildDirectory;
1468
1559
  let isWithinRoot = () => {
1469
- let relativePath = path6.relative(ctx.rootDirectory, buildDirectory);
1470
- return !relativePath.startsWith("..") && !path6.isAbsolute(relativePath);
1560
+ let relativePath = path7.relative(ctx.rootDirectory, buildDirectory);
1561
+ return !relativePath.startsWith("..") && !path7.isAbsolute(relativePath);
1471
1562
  };
1472
1563
  if (viteConfig.build.emptyOutDir ?? isWithinRoot()) {
1473
1564
  await (0, import_promises2.rm)(buildDirectory, { force: true, recursive: true });
@@ -1478,7 +1569,7 @@ async function cleanViteManifests(environmentsOptions, ctx) {
1478
1569
  ([environmentName, options]) => {
1479
1570
  let outDir = options.build?.outDir;
1480
1571
  invariant(outDir, `Expected build.outDir for ${environmentName}`);
1481
- return path6.join(outDir, ".vite/manifest.json");
1572
+ return path7.join(outDir, ".vite/manifest.json");
1482
1573
  }
1483
1574
  );
1484
1575
  await Promise.all(
@@ -1488,7 +1579,7 @@ async function cleanViteManifests(environmentsOptions, ctx) {
1488
1579
  if (!ctx.viteManifestEnabled) {
1489
1580
  await (0, import_promises2.rm)(viteManifestPath, { force: true, recursive: true });
1490
1581
  }
1491
- let viteDir = path6.dirname(viteManifestPath);
1582
+ let viteDir = path7.dirname(viteManifestPath);
1492
1583
  let viteDirFiles = await (0, import_promises2.readdir)(viteDir, { recursive: true });
1493
1584
  if (viteDirFiles.length === 0) {
1494
1585
  await (0, import_promises2.rm)(viteDir, { force: true, recursive: true });
@@ -1505,10 +1596,10 @@ function mergeEnvironmentOptions(base, ...overrides) {
1505
1596
  }
1506
1597
  async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
1507
1598
  let { serverBuildFile, serverModuleFormat } = ctx.reactRouterConfig;
1508
- let packageRoot = path6.dirname(
1599
+ let packageRoot = path7.dirname(
1509
1600
  require.resolve("@react-router/dev/package.json")
1510
1601
  );
1511
- let { moduleSyncEnabled } = await import(`file:///${path6.join(packageRoot, "module-sync-enabled/index.mjs")}`);
1602
+ let { moduleSyncEnabled } = await import(`file:///${path7.join(packageRoot, "module-sync-enabled/index.mjs")}`);
1512
1603
  let vite2 = getVite();
1513
1604
  function getBaseOptions({
1514
1605
  viteUserConfig
@@ -1587,7 +1678,7 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
1587
1678
  ctx.entryClientFilePath,
1588
1679
  ...Object.values(ctx.reactRouterConfig.routes).flatMap(
1589
1680
  (route) => {
1590
- let routeFilePath = path6.resolve(
1681
+ let routeFilePath = path7.resolve(
1591
1682
  ctx.reactRouterConfig.appDirectory,
1592
1683
  route.file
1593
1684
  );
@@ -1611,7 +1702,7 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
1611
1702
  ) : null;
1612
1703
  let routeChunkSuffix = routeChunkName ? `-${(0, import_kebabCase.default)(routeChunkName)}` : "";
1613
1704
  let assetsDir = (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi ? viteUserConfig?.environments?.client?.build?.assetsDir : null) ?? viteUserConfig?.build?.assetsDir ?? "assets";
1614
- return path6.posix.join(
1705
+ return path7.posix.join(
1615
1706
  assetsDir,
1616
1707
  `[name]${routeChunkSuffix}-[hash].js`
1617
1708
  );
@@ -1661,22 +1752,21 @@ function resolveEnvironmentsOptions(environmentResolvers, resolverOptions) {
1661
1752
  function isNonNullable(x) {
1662
1753
  return x != null;
1663
1754
  }
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;
1755
+ 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
1756
  var init_plugin = __esm({
1666
1757
  "vite/plugin.ts"() {
1667
1758
  "use strict";
1668
1759
  import_node_crypto = require("crypto");
1669
1760
  import_node_fs3 = require("fs");
1670
1761
  import_promises2 = require("fs/promises");
1671
- path6 = __toESM(require("path"));
1762
+ path7 = __toESM(require("path"));
1672
1763
  url = __toESM(require("url"));
1673
1764
  babel2 = __toESM(require("@babel/core"));
1674
1765
  import_react_router2 = require("react-router");
1675
1766
  import_es_module_lexer = require("es-module-lexer");
1676
- import_tinyglobby = require("tinyglobby");
1677
1767
  import_pick3 = __toESM(require("lodash/pick"));
1678
1768
  import_jsesc = __toESM(require("jsesc"));
1679
- import_picocolors4 = __toESM(require("picocolors"));
1769
+ import_picocolors5 = __toESM(require("picocolors"));
1680
1770
  import_kebabCase = __toESM(require("lodash/kebabCase"));
1681
1771
  init_typegen();
1682
1772
  init_invariant();
@@ -1685,14 +1775,19 @@ var init_plugin = __esm({
1685
1775
  init_styles();
1686
1776
  init_virtual_module();
1687
1777
  init_resolve_file_url();
1778
+ init_resolve_relative_route_file_path();
1688
1779
  init_combine_urls();
1689
1780
  init_remove_exports();
1690
1781
  init_ssr_externals();
1782
+ init_has_dependency();
1691
1783
  init_route_chunks();
1692
1784
  init_vite();
1693
1785
  init_config();
1786
+ init_optimize_deps_entries();
1694
1787
  init_with_props();
1788
+ init_load_dotenv();
1695
1789
  init_validate_plugin_order();
1790
+ init_warn_on_client_source_maps();
1696
1791
  CLIENT_NON_COMPONENT_EXPORTS = [
1697
1792
  "clientAction",
1698
1793
  "clientLoader",
@@ -1718,20 +1813,20 @@ var init_plugin = __esm({
1718
1813
  serverManifest: create("server-manifest"),
1719
1814
  browserManifest: create("browser-manifest")
1720
1815
  };
1721
- getServerBuildDirectory = (reactRouterConfig, { serverBundleId } = {}) => path6.join(
1816
+ getServerBuildDirectory = (reactRouterConfig, { serverBundleId } = {}) => path7.join(
1722
1817
  reactRouterConfig.buildDirectory,
1723
1818
  "server",
1724
1819
  ...serverBundleId ? [serverBundleId] : []
1725
1820
  );
1726
- getClientBuildDirectory = (reactRouterConfig) => path6.join(reactRouterConfig.buildDirectory, "client");
1727
- defaultEntriesDir = path6.resolve(
1728
- path6.dirname(require.resolve("@react-router/dev/package.json")),
1821
+ getClientBuildDirectory = (reactRouterConfig) => path7.join(reactRouterConfig.buildDirectory, "client");
1822
+ defaultEntriesDir = path7.resolve(
1823
+ path7.dirname(require.resolve("@react-router/dev/package.json")),
1729
1824
  "dist",
1730
1825
  "config",
1731
1826
  "defaults"
1732
1827
  );
1733
1828
  defaultEntries = (0, import_node_fs3.readdirSync)(defaultEntriesDir).map(
1734
- (filename2) => path6.join(defaultEntriesDir, filename2)
1829
+ (filename2) => path7.join(defaultEntriesDir, filename2)
1735
1830
  );
1736
1831
  invariant(defaultEntries.length > 0, "No default entries found");
1737
1832
  REACT_REFRESH_HEADER = `
@@ -1777,14 +1872,14 @@ async function build(root, viteBuildOptions) {
1777
1872
  throw new Error(configResult.error);
1778
1873
  }
1779
1874
  let config = configResult.value;
1780
- let unstable_viteEnvironmentApi = config.future.unstable_viteEnvironmentApi;
1781
1875
  let viteMajor = parseInt(vite2.version.split(".")[0], 10);
1782
- if (unstable_viteEnvironmentApi && viteMajor === 5) {
1876
+ if (config.future.unstable_viteEnvironmentApi && viteMajor === 5) {
1783
1877
  throw new Error(
1784
1878
  "The future.unstable_viteEnvironmentApi option is not supported in Vite 5"
1785
1879
  );
1786
1880
  }
1787
- return await (unstable_viteEnvironmentApi ? viteAppBuild(root, viteBuildOptions) : viteBuild(root, viteBuildOptions));
1881
+ const useViteEnvironmentApi = config.future.unstable_viteEnvironmentApi || await hasReactRouterRscPlugin({ root, viteBuildOptions });
1882
+ return await (useViteEnvironmentApi ? viteAppBuild(root, viteBuildOptions) : viteBuild(root, viteBuildOptions));
1788
1883
  }
1789
1884
  async function viteAppBuild(root, {
1790
1885
  assetsInlineLimit,
@@ -1874,7 +1969,7 @@ async function viteBuild(root, {
1874
1969
  let ctx = extractPluginContext(viteConfig);
1875
1970
  if (!ctx) {
1876
1971
  console.error(
1877
- import_picocolors5.default.red("React Router Vite plugin not found in Vite config")
1972
+ import_picocolors6.default.red("React Router Vite plugin not found in Vite config")
1878
1973
  );
1879
1974
  process.exit(1);
1880
1975
  }
@@ -1931,15 +2026,16 @@ async function viteBuild(root, {
1931
2026
  viteConfig
1932
2027
  });
1933
2028
  }
1934
- var import_picocolors5;
2029
+ var import_picocolors6;
1935
2030
  var init_build = __esm({
1936
2031
  "vite/build.ts"() {
1937
2032
  "use strict";
1938
- import_picocolors5 = __toESM(require("picocolors"));
2033
+ import_picocolors6 = __toESM(require("picocolors"));
1939
2034
  init_config();
1940
2035
  init_plugin();
1941
2036
  init_invariant();
1942
2037
  init_vite();
2038
+ init_has_rsc_plugin();
1943
2039
  }
1944
2040
  });
1945
2041
 
@@ -1975,7 +2071,7 @@ async function dev(root, {
1975
2071
  (plugin) => plugin.name === "react-router" || plugin.name === "react-router/rsc"
1976
2072
  )) {
1977
2073
  console.error(
1978
- import_picocolors6.default.red("React Router Vite plugin not found in Vite config")
2074
+ import_picocolors7.default.red("React Router Vite plugin not found in Vite config")
1979
2075
  );
1980
2076
  process.exit(1);
1981
2077
  }
@@ -1998,11 +2094,11 @@ async function dev(root, {
1998
2094
  ];
1999
2095
  server.bindCLIShortcuts({ print: true, customShortcuts });
2000
2096
  }
2001
- var import_picocolors6;
2097
+ var import_picocolors7;
2002
2098
  var init_dev = __esm({
2003
2099
  "vite/dev.ts"() {
2004
2100
  "use strict";
2005
- import_picocolors6 = __toESM(require("picocolors"));
2101
+ import_picocolors7 = __toESM(require("picocolors"));
2006
2102
  init_vite();
2007
2103
  init_profiler();
2008
2104
  }
@@ -2011,15 +2107,15 @@ var init_dev = __esm({
2011
2107
  // cli/run.ts
2012
2108
  var import_arg = __toESM(require("arg"));
2013
2109
  var import_semver = __toESM(require("semver"));
2014
- var import_picocolors8 = __toESM(require("picocolors"));
2110
+ var import_picocolors9 = __toESM(require("picocolors"));
2015
2111
 
2016
2112
  // cli/commands.ts
2017
2113
  var import_node_fs4 = require("fs");
2018
2114
  var import_promises3 = require("fs/promises");
2019
- var path7 = __toESM(require("path"));
2115
+ var path8 = __toESM(require("path"));
2020
2116
  var import_package_json2 = __toESM(require("@npmcli/package-json"));
2021
2117
  var import_exit_hook = __toESM(require("exit-hook"));
2022
- var import_picocolors7 = __toESM(require("picocolors"));
2118
+ var import_picocolors8 = __toESM(require("picocolors"));
2023
2119
  var import_react_router3 = require("react-router");
2024
2120
  init_config();
2025
2121
 
@@ -2101,6 +2197,7 @@ async function transpile(tsx, options = {}) {
2101
2197
  init_profiler();
2102
2198
  init_typegen();
2103
2199
  init_vite();
2200
+ init_has_rsc_plugin();
2104
2201
  async function routes(rootDirectory, flags = {}) {
2105
2202
  rootDirectory = resolveRootDirectory(rootDirectory, flags);
2106
2203
  let configResult = await loadConfig({
@@ -2108,7 +2205,7 @@ async function routes(rootDirectory, flags = {}) {
2108
2205
  mode: flags.mode ?? "production"
2109
2206
  });
2110
2207
  if (!configResult.ok) {
2111
- console.error(import_picocolors7.default.red(configResult.error));
2208
+ console.error(import_picocolors8.default.red(configResult.error));
2112
2209
  process.exit(1);
2113
2210
  }
2114
2211
  let format = flags.json ? "json" : "jsx";
@@ -2145,18 +2242,32 @@ var conjunctionListFormat = new Intl.ListFormat("en", {
2145
2242
  type: "conjunction"
2146
2243
  });
2147
2244
  async function generateEntry(entry, rootDirectory, flags = {}) {
2245
+ rootDirectory = resolveRootDirectory(rootDirectory, flags);
2246
+ if (await hasReactRouterRscPlugin({
2247
+ root: rootDirectory,
2248
+ viteBuildOptions: {
2249
+ config: flags.config,
2250
+ mode: flags.mode
2251
+ }
2252
+ })) {
2253
+ console.error(
2254
+ import_picocolors8.default.red(
2255
+ `The reveal command is currently not supported in RSC Framework Mode.`
2256
+ )
2257
+ );
2258
+ process.exit(1);
2259
+ }
2148
2260
  if (!entry) {
2149
2261
  await generateEntry("entry.client", rootDirectory, flags);
2150
2262
  await generateEntry("entry.server", rootDirectory, flags);
2151
2263
  return;
2152
2264
  }
2153
- rootDirectory = resolveRootDirectory(rootDirectory, flags);
2154
2265
  let configResult = await loadConfig({
2155
2266
  rootDirectory,
2156
2267
  mode: flags.mode ?? "production"
2157
2268
  });
2158
2269
  if (!configResult.ok) {
2159
- console.error(import_picocolors7.default.red(configResult.error));
2270
+ console.error(import_picocolors8.default.red(configResult.error));
2160
2271
  return;
2161
2272
  }
2162
2273
  let appDirectory = configResult.value.appDirectory;
@@ -2164,24 +2275,24 @@ async function generateEntry(entry, rootDirectory, flags = {}) {
2164
2275
  let entriesArray = Array.from(entries);
2165
2276
  let list = conjunctionListFormat.format(entriesArray);
2166
2277
  console.error(
2167
- import_picocolors7.default.red(`Invalid entry file. Valid entry files are ${list}`)
2278
+ import_picocolors8.default.red(`Invalid entry file. Valid entry files are ${list}`)
2168
2279
  );
2169
2280
  return;
2170
2281
  }
2171
2282
  let pkgJson = await import_package_json2.default.load(rootDirectory);
2172
2283
  let deps = pkgJson.content.dependencies ?? {};
2173
2284
  if (!deps["@react-router/node"]) {
2174
- console.error(import_picocolors7.default.red(`No default server entry detected.`));
2285
+ console.error(import_picocolors8.default.red(`No default server entry detected.`));
2175
2286
  return;
2176
2287
  }
2177
- let defaultsDirectory = path7.resolve(
2178
- path7.dirname(require.resolve("@react-router/dev/package.json")),
2288
+ let defaultsDirectory = path8.resolve(
2289
+ path8.dirname(require.resolve("@react-router/dev/package.json")),
2179
2290
  "dist",
2180
2291
  "config",
2181
2292
  "defaults"
2182
2293
  );
2183
- let defaultEntryClient = path7.resolve(defaultsDirectory, "entry.client.tsx");
2184
- let defaultEntryServer = path7.resolve(
2294
+ let defaultEntryClient = path8.resolve(defaultsDirectory, "entry.client.tsx");
2295
+ let defaultEntryServer = path8.resolve(
2185
2296
  defaultsDirectory,
2186
2297
  `entry.server.node.tsx`
2187
2298
  );
@@ -2190,7 +2301,7 @@ async function generateEntry(entry, rootDirectory, flags = {}) {
2190
2301
  let useTypeScript = flags.typescript ?? true;
2191
2302
  let outputExtension = useTypeScript ? "tsx" : "jsx";
2192
2303
  let outputEntry = `${entry}.${outputExtension}`;
2193
- let outputFile = path7.resolve(appDirectory, outputEntry);
2304
+ let outputFile = path8.resolve(appDirectory, outputEntry);
2194
2305
  if (!useTypeScript) {
2195
2306
  let javascript = await transpile(contents, {
2196
2307
  cwd: rootDirectory,
@@ -2201,8 +2312,8 @@ async function generateEntry(entry, rootDirectory, flags = {}) {
2201
2312
  await (0, import_promises3.writeFile)(outputFile, contents, "utf-8");
2202
2313
  }
2203
2314
  console.log(
2204
- import_picocolors7.default.blue(
2205
- `Entry file ${entry} created at ${path7.relative(
2315
+ import_picocolors8.default.blue(
2316
+ `Entry file ${entry} created at ${path8.relative(
2206
2317
  rootDirectory,
2207
2318
  outputFile
2208
2319
  )}.`
@@ -2211,17 +2322,17 @@ async function generateEntry(entry, rootDirectory, flags = {}) {
2211
2322
  }
2212
2323
  function resolveRootDirectory(root, flags) {
2213
2324
  if (root) {
2214
- return path7.resolve(root);
2325
+ return path8.resolve(root);
2215
2326
  }
2216
- return process.env.REACT_ROUTER_ROOT || (flags?.config ? path7.dirname(path7.resolve(flags.config)) : process.cwd());
2327
+ return process.env.REACT_ROUTER_ROOT || (flags?.config ? path8.dirname(path8.resolve(flags.config)) : process.cwd());
2217
2328
  }
2218
2329
  async function checkForEntry(rootDirectory, appDirectory, entries2) {
2219
2330
  for (let entry of entries2) {
2220
- let entryPath = path7.resolve(appDirectory, entry);
2331
+ let entryPath = path8.resolve(appDirectory, entry);
2221
2332
  let exists = (0, import_node_fs4.existsSync)(entryPath);
2222
2333
  if (exists) {
2223
- let relative7 = path7.relative(rootDirectory, entryPath);
2224
- console.error(import_picocolors7.default.red(`Entry file ${relative7} already exists.`));
2334
+ let relative7 = path8.relative(rootDirectory, entryPath);
2335
+ console.error(import_picocolors8.default.red(`Entry file ${relative7} already exists.`));
2225
2336
  return process.exit(1);
2226
2337
  }
2227
2338
  }
@@ -2238,12 +2349,20 @@ async function createClientEntry(rootDirectory, appDirectory, inputFile) {
2238
2349
  }
2239
2350
  async function typegen(root, flags) {
2240
2351
  root = resolveRootDirectory(root, flags);
2352
+ const rsc = await hasReactRouterRscPlugin({
2353
+ root,
2354
+ viteBuildOptions: {
2355
+ config: flags.config,
2356
+ mode: flags.mode
2357
+ }
2358
+ });
2241
2359
  if (flags.watch) {
2242
2360
  await preloadVite();
2243
2361
  const vite2 = getVite();
2244
2362
  const logger = vite2.createLogger("info", { prefix: "[react-router]" });
2245
2363
  await watch(root, {
2246
2364
  mode: flags.mode ?? "development",
2365
+ rsc,
2247
2366
  logger
2248
2367
  });
2249
2368
  await new Promise(() => {
@@ -2251,20 +2370,21 @@ async function typegen(root, flags) {
2251
2370
  return;
2252
2371
  }
2253
2372
  await run(root, {
2254
- mode: flags.mode ?? "production"
2373
+ mode: flags.mode ?? "production",
2374
+ rsc
2255
2375
  });
2256
2376
  }
2257
2377
 
2258
2378
  // cli/run.ts
2259
2379
  var helpText = `
2260
- ${import_picocolors8.default.blueBright("react-router")}
2380
+ ${import_picocolors9.default.blueBright("react-router")}
2261
2381
 
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")}]
2382
+ ${import_picocolors9.default.underline("Usage")}:
2383
+ $ react-router build [${import_picocolors9.default.yellowBright("projectDir")}]
2384
+ $ react-router dev [${import_picocolors9.default.yellowBright("projectDir")}]
2385
+ $ react-router routes [${import_picocolors9.default.yellowBright("projectDir")}]
2266
2386
 
2267
- ${import_picocolors8.default.underline("Options")}:
2387
+ ${import_picocolors9.default.underline("Options")}:
2268
2388
  --help, -h Print this help message and exit
2269
2389
  --version, -v Print the CLI version and exit
2270
2390
  --no-color Disable ANSI colors in console output
@@ -2300,22 +2420,22 @@ ${import_picocolors8.default.blueBright("react-router")}
2300
2420
  \`typegen\` Options:
2301
2421
  --watch Automatically regenerate types whenever route config (\`routes.ts\`) or route modules change
2302
2422
 
2303
- ${import_picocolors8.default.underline("Build your project")}:
2423
+ ${import_picocolors9.default.underline("Build your project")}:
2304
2424
 
2305
2425
  $ react-router build
2306
2426
 
2307
- ${import_picocolors8.default.underline("Run your project locally in development")}:
2427
+ ${import_picocolors9.default.underline("Run your project locally in development")}:
2308
2428
 
2309
2429
  $ react-router dev
2310
2430
 
2311
- ${import_picocolors8.default.underline("Show all routes in your app")}:
2431
+ ${import_picocolors9.default.underline("Show all routes in your app")}:
2312
2432
 
2313
2433
  $ react-router routes
2314
2434
  $ react-router routes my-app
2315
2435
  $ react-router routes --json
2316
2436
  $ react-router routes --config vite.react-router.config.ts
2317
2437
 
2318
- ${import_picocolors8.default.underline("Reveal the used entry point")}:
2438
+ ${import_picocolors9.default.underline("Reveal the used entry point")}:
2319
2439
 
2320
2440
  $ react-router reveal entry.client
2321
2441
  $ react-router reveal entry.server
@@ -2323,7 +2443,7 @@ ${import_picocolors8.default.blueBright("react-router")}
2323
2443
  $ react-router reveal entry.server --no-typescript
2324
2444
  $ react-router reveal entry.server --config vite.react-router.config.ts
2325
2445
 
2326
- ${import_picocolors8.default.underline("Generate types for route modules")}:
2446
+ ${import_picocolors9.default.underline("Generate types for route modules")}:
2327
2447
 
2328
2448
  $ react-router typegen
2329
2449
  $ react-router typegen --watch