@c0va23/react-router-dev 7.8.3-alpha.1 → 7.8.3-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/internal.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @c0va23/react-router-dev v7.8.3-alpha.1
2
+ * @c0va23/react-router-dev v7.8.3-alpha.2
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -45,9 +45,9 @@ __export(internal_exports, {
45
45
  module.exports = __toCommonJS(internal_exports);
46
46
 
47
47
  // vite/rsc/plugin.ts
48
+ var import_plugin_rsc = __toESM(require("@vitejs/plugin-rsc"));
48
49
  var import_es_module_lexer2 = require("es-module-lexer");
49
50
  var babel = __toESM(require("@babel/core"));
50
- var import_picocolors3 = __toESM(require("picocolors"));
51
51
 
52
52
  // vite/virtual-module.ts
53
53
  function create(name) {
@@ -247,7 +247,7 @@ function validateRouteConfig({
247
247
  `Route config in "${routeConfigFile}" is invalid.`,
248
248
  root ? `${root}` : [],
249
249
  nested ? Object.entries(nested).map(
250
- ([path6, message]) => `Path: routes.${path6}
250
+ ([path5, message]) => `Path: routes.${path5}
251
251
  ${message}`
252
252
  ) : []
253
253
  ].flat().join("\n\n")
@@ -344,8 +344,7 @@ async function resolveConfig({
344
344
  root,
345
345
  viteNodeContext,
346
346
  reactRouterConfigFile,
347
- skipRoutes,
348
- validateConfig
347
+ skipRoutes
349
348
  }) {
350
349
  let reactRouterUserConfig = {};
351
350
  if (reactRouterConfigFile) {
@@ -363,12 +362,6 @@ async function resolveConfig({
363
362
  return err(`${reactRouterConfigFile} must export a config`);
364
363
  }
365
364
  reactRouterUserConfig = configModule.default;
366
- if (validateConfig) {
367
- const error = validateConfig(reactRouterUserConfig);
368
- if (error) {
369
- return err(error);
370
- }
371
- }
372
365
  } catch (error) {
373
366
  return err(`Error loading ${reactRouterConfigFile}: ${error}`);
374
367
  }
@@ -517,7 +510,7 @@ async function resolveConfig({
517
510
  }
518
511
  }
519
512
  let future = {
520
- v8_middleware: reactRouterUserConfig.future?.v8_middleware ?? false,
513
+ unstable_middleware: reactRouterUserConfig.future?.unstable_middleware ?? false,
521
514
  unstable_optimizeDeps: reactRouterUserConfig.future?.unstable_optimizeDeps ?? false,
522
515
  unstable_splitRouteModules: reactRouterUserConfig.future?.unstable_splitRouteModules ?? false,
523
516
  unstable_subResourceIntegrity: reactRouterUserConfig.future?.unstable_subResourceIntegrity ?? false,
@@ -547,8 +540,7 @@ async function createConfigLoader({
547
540
  rootDirectory: root,
548
541
  watch: watch2,
549
542
  mode,
550
- skipRoutes,
551
- validateConfig
543
+ skipRoutes
552
544
  }) {
553
545
  root = import_pathe3.default.normalize(root ?? process.env.REACT_ROUTER_ROOT ?? process.cwd());
554
546
  let vite2 = await import("vite");
@@ -567,13 +559,7 @@ async function createConfigLoader({
567
559
  });
568
560
  };
569
561
  updateReactRouterConfigFile();
570
- let getConfig = () => resolveConfig({
571
- root,
572
- viteNodeContext,
573
- reactRouterConfigFile,
574
- skipRoutes,
575
- validateConfig
576
- });
562
+ let getConfig = () => resolveConfig({ root, viteNodeContext, reactRouterConfigFile, skipRoutes });
577
563
  let appDirectory;
578
564
  let initialConfigResult = await getConfig();
579
565
  if (!initialConfigResult.ok) {
@@ -595,11 +581,11 @@ async function createConfigLoader({
595
581
  if (!fsWatcher) {
596
582
  fsWatcher = import_chokidar.default.watch([root, appDirectory], {
597
583
  ignoreInitial: true,
598
- ignored: (path6) => {
599
- let dirname4 = import_pathe3.default.dirname(path6);
584
+ ignored: (path5) => {
585
+ let dirname4 = import_pathe3.default.dirname(path5);
600
586
  return !dirname4.startsWith(appDirectory) && // Ensure we're only watching files outside of the app directory
601
587
  // that are at the root level, not nested in subdirectories
602
- path6 !== root && // Watch the root directory itself
588
+ path5 !== root && // Watch the root directory itself
603
589
  dirname4 !== root;
604
590
  }
605
591
  });
@@ -799,7 +785,7 @@ function fullpath(lineage2) {
799
785
  if (lineage2.length === 1 && route?.id === "root") return "/";
800
786
  const isLayout = route && route.index !== true && route.path === void 0;
801
787
  if (isLayout) return void 0;
802
- return "/" + lineage2.map((route2) => route2.path?.replace(/^\//, "")?.replace(/\/$/, "")).filter((path6) => path6 !== void 0 && path6 !== "").join("/");
788
+ return "/" + lineage2.map((route2) => route2.path?.replace(/^\//, "")?.replace(/\/$/, "")).filter((path5) => path5 !== void 0 && path5 !== "").join("/");
803
789
  }
804
790
 
805
791
  // typegen/generate.ts
@@ -815,7 +801,7 @@ function generateFuture(ctx) {
815
801
 
816
802
  declare module "react-router" {
817
803
  interface Future {
818
- middleware: ${ctx.config.future.v8_middleware}
804
+ unstable_middleware: ${ctx.config.future.unstable_middleware}
819
805
  }
820
806
  }
821
807
  `;
@@ -955,8 +941,8 @@ function routeFilesType({
955
941
  );
956
942
  }
957
943
  function isInAppDirectory(ctx, routeFile) {
958
- const path6 = Path3.resolve(ctx.config.appDirectory, routeFile);
959
- return path6.startsWith(ctx.config.appDirectory);
944
+ const path5 = Path3.resolve(ctx.config.appDirectory, routeFile);
945
+ return path5.startsWith(ctx.config.appDirectory);
960
946
  }
961
947
  function getRouteAnnotations({
962
948
  ctx,
@@ -1037,11 +1023,11 @@ function getRouteAnnotations({
1037
1023
  export type HeadersArgs = Annotations["HeadersArgs"];
1038
1024
  export type HeadersFunction = Annotations["HeadersFunction"];
1039
1025
 
1040
- // middleware
1041
- export type MiddlewareFunction = Annotations["MiddlewareFunction"];
1026
+ // unstable_middleware
1027
+ export type unstable_MiddlewareFunction = Annotations["unstable_MiddlewareFunction"];
1042
1028
 
1043
- // clientMiddleware
1044
- export type ClientMiddlewareFunction = Annotations["ClientMiddlewareFunction"];
1029
+ // unstable_clientMiddleware
1030
+ export type unstable_ClientMiddlewareFunction = Annotations["unstable_ClientMiddlewareFunction"];
1045
1031
 
1046
1032
  // loader
1047
1033
  export type LoaderArgs = Annotations["LoaderArgs"];
@@ -1068,21 +1054,21 @@ function getRouteAnnotations({
1068
1054
  return { filename: filename2, content };
1069
1055
  }
1070
1056
  function relativeImportSource(from, to) {
1071
- let path6 = Path3.relative(Path3.dirname(from), to);
1072
- let extension = Path3.extname(path6);
1073
- path6 = Path3.join(Path3.dirname(path6), Pathe.filename(path6));
1074
- if (!path6.startsWith("../")) path6 = "./" + path6;
1057
+ let path5 = Path3.relative(Path3.dirname(from), to);
1058
+ let extension = Path3.extname(path5);
1059
+ path5 = Path3.join(Path3.dirname(path5), Pathe.filename(path5));
1060
+ if (!path5.startsWith("../")) path5 = "./" + path5;
1075
1061
  if (!extension || /\.(js|ts)x?$/.test(extension)) {
1076
1062
  extension = ".js";
1077
1063
  }
1078
- return path6 + extension;
1064
+ return path5 + extension;
1079
1065
  }
1080
1066
  function rootDirsPath(ctx, typesPath) {
1081
1067
  const rel = Path3.relative(typesDirectory(ctx), typesPath);
1082
1068
  return Path3.join(ctx.rootDirectory, rel);
1083
1069
  }
1084
- function paramsType(path6) {
1085
- const params = parse2(path6);
1070
+ function paramsType(path5) {
1071
+ const params = parse2(path5);
1086
1072
  return t2.tsTypeLiteral(
1087
1073
  Object.entries(params).map(([param, isRequired]) => {
1088
1074
  const property = t2.tsPropertySignature(
@@ -1173,58 +1159,10 @@ async function watch(rootDirectory, { mode, logger }) {
1173
1159
  // vite/rsc/plugin.ts
1174
1160
  var import_fs = require("fs");
1175
1161
  var import_promises2 = require("fs/promises");
1176
- var import_pathe6 = __toESM(require("pathe"));
1177
-
1178
- // vite/has-dependency.ts
1179
- function hasDependency({
1180
- name,
1181
- rootDirectory
1182
- }) {
1183
- try {
1184
- return Boolean(require.resolve(name, { paths: [rootDirectory] }));
1185
- } catch (err2) {
1186
- return false;
1187
- }
1188
- }
1189
-
1190
- // vite/optimize-deps-entries.ts
1191
- var import_tinyglobby = require("tinyglobby");
1192
-
1193
- // vite/resolve-relative-route-file-path.ts
1194
- var import_pathe4 = __toESM(require("pathe"));
1195
- function resolveRelativeRouteFilePath(route, reactRouterConfig) {
1196
- let vite2 = getVite();
1197
- let file = route.file;
1198
- let fullPath = import_pathe4.default.resolve(reactRouterConfig.appDirectory, file);
1199
- return vite2.normalizePath(fullPath);
1200
- }
1201
-
1202
- // vite/optimize-deps-entries.ts
1203
- function getOptimizeDepsEntries({
1204
- entryClientFilePath,
1205
- reactRouterConfig
1206
- }) {
1207
- if (!reactRouterConfig.future.unstable_optimizeDeps) {
1208
- return [];
1209
- }
1210
- const vite2 = getVite();
1211
- const viteMajorVersion = parseInt(vite2.version.split(".")[0], 10);
1212
- return [
1213
- vite2.normalizePath(entryClientFilePath),
1214
- ...Object.values(reactRouterConfig.routes).map(
1215
- (route) => resolveRelativeRouteFilePath(route, reactRouterConfig)
1216
- )
1217
- ].map(
1218
- (entry) => (
1219
- // In Vite 7, the `optimizeDeps.entries` option only accepts glob patterns.
1220
- // In prior versions, absolute file paths were treated differently.
1221
- viteMajorVersion >= 7 ? (0, import_tinyglobby.escapePath)(entry) : entry
1222
- )
1223
- );
1224
- }
1162
+ var import_pathe5 = __toESM(require("pathe"));
1225
1163
 
1226
1164
  // vite/rsc/virtual-route-config.ts
1227
- var import_pathe5 = __toESM(require("pathe"));
1165
+ var import_pathe4 = __toESM(require("pathe"));
1228
1166
  function createVirtualRouteConfig({
1229
1167
  appDirectory,
1230
1168
  routeConfig
@@ -1243,7 +1181,7 @@ function createVirtualRouteConfig({
1243
1181
  continue;
1244
1182
  }
1245
1183
  code += "{";
1246
- const routeFile = import_pathe5.default.resolve(appDirectory, route.file);
1184
+ const routeFile = import_pathe4.default.resolve(appDirectory, route.file);
1247
1185
  const routeId = route.id || createRouteId2(route.file, appDirectory);
1248
1186
  routeIdByFile.set(routeFile, routeId);
1249
1187
  code += `lazy: () => import(${JSON.stringify(
@@ -1271,7 +1209,7 @@ function createVirtualRouteConfig({
1271
1209
  return { code, routeIdByFile };
1272
1210
  }
1273
1211
  function createRouteId2(file, appDirectory) {
1274
- return import_pathe5.default.relative(appDirectory, file).replace(/\\+/, "/").slice(0, -import_pathe5.default.extname(file).length);
1212
+ return import_pathe4.default.relative(appDirectory, file).replace(/\\+/, "/").slice(0, -import_pathe4.default.extname(file).length);
1275
1213
  }
1276
1214
 
1277
1215
  // vite/rsc/virtual-route-modules.ts
@@ -1285,10 +1223,10 @@ var removeExports = (ast, exportsToRemove) => {
1285
1223
  let markedForRemoval = /* @__PURE__ */ new Set();
1286
1224
  let removedExportLocalNames = /* @__PURE__ */ new Set();
1287
1225
  traverse(ast, {
1288
- ExportDeclaration(path6) {
1289
- if (path6.node.type === "ExportNamedDeclaration") {
1290
- if (path6.node.specifiers.length) {
1291
- path6.node.specifiers = path6.node.specifiers.filter((specifier) => {
1226
+ ExportDeclaration(path5) {
1227
+ if (path5.node.type === "ExportNamedDeclaration") {
1228
+ if (path5.node.specifiers.length) {
1229
+ path5.node.specifiers = path5.node.specifiers.filter((specifier) => {
1292
1230
  if (specifier.type === "ExportSpecifier" && specifier.exported.type === "Identifier") {
1293
1231
  if (exportsToRemove.includes(specifier.exported.name)) {
1294
1232
  exportsFiltered = true;
@@ -1300,12 +1238,12 @@ var removeExports = (ast, exportsToRemove) => {
1300
1238
  }
1301
1239
  return true;
1302
1240
  });
1303
- if (path6.node.specifiers.length === 0) {
1304
- markedForRemoval.add(path6);
1241
+ if (path5.node.specifiers.length === 0) {
1242
+ markedForRemoval.add(path5);
1305
1243
  }
1306
1244
  }
1307
- if (path6.node.declaration?.type === "VariableDeclaration") {
1308
- let declaration = path6.node.declaration;
1245
+ if (path5.node.declaration?.type === "VariableDeclaration") {
1246
+ let declaration = path5.node.declaration;
1309
1247
  declaration.declarations = declaration.declarations.filter(
1310
1248
  (declaration2) => {
1311
1249
  if (declaration2.id.type === "Identifier" && exportsToRemove.includes(declaration2.id.name)) {
@@ -1319,30 +1257,30 @@ var removeExports = (ast, exportsToRemove) => {
1319
1257
  }
1320
1258
  );
1321
1259
  if (declaration.declarations.length === 0) {
1322
- markedForRemoval.add(path6);
1260
+ markedForRemoval.add(path5);
1323
1261
  }
1324
1262
  }
1325
- if (path6.node.declaration?.type === "FunctionDeclaration") {
1326
- let id = path6.node.declaration.id;
1263
+ if (path5.node.declaration?.type === "FunctionDeclaration") {
1264
+ let id = path5.node.declaration.id;
1327
1265
  if (id && exportsToRemove.includes(id.name)) {
1328
- markedForRemoval.add(path6);
1266
+ markedForRemoval.add(path5);
1329
1267
  }
1330
1268
  }
1331
- if (path6.node.declaration?.type === "ClassDeclaration") {
1332
- let id = path6.node.declaration.id;
1269
+ if (path5.node.declaration?.type === "ClassDeclaration") {
1270
+ let id = path5.node.declaration.id;
1333
1271
  if (id && exportsToRemove.includes(id.name)) {
1334
- markedForRemoval.add(path6);
1272
+ markedForRemoval.add(path5);
1335
1273
  }
1336
1274
  }
1337
1275
  }
1338
- if (path6.node.type === "ExportDefaultDeclaration") {
1276
+ if (path5.node.type === "ExportDefaultDeclaration") {
1339
1277
  if (exportsToRemove.includes("default")) {
1340
- markedForRemoval.add(path6);
1341
- if (path6.node.declaration) {
1342
- if (path6.node.declaration.type === "Identifier") {
1343
- removedExportLocalNames.add(path6.node.declaration.name);
1344
- } else if ((path6.node.declaration.type === "FunctionDeclaration" || path6.node.declaration.type === "ClassDeclaration") && path6.node.declaration.id) {
1345
- removedExportLocalNames.add(path6.node.declaration.id.name);
1278
+ markedForRemoval.add(path5);
1279
+ if (path5.node.declaration) {
1280
+ if (path5.node.declaration.type === "Identifier") {
1281
+ removedExportLocalNames.add(path5.node.declaration.name);
1282
+ } else if ((path5.node.declaration.type === "FunctionDeclaration" || path5.node.declaration.type === "ClassDeclaration") && path5.node.declaration.id) {
1283
+ removedExportLocalNames.add(path5.node.declaration.id.name);
1346
1284
  }
1347
1285
  }
1348
1286
  }
@@ -1350,21 +1288,21 @@ var removeExports = (ast, exportsToRemove) => {
1350
1288
  }
1351
1289
  });
1352
1290
  traverse(ast, {
1353
- ExpressionStatement(path6) {
1354
- if (!path6.parentPath.isProgram()) {
1291
+ ExpressionStatement(path5) {
1292
+ if (!path5.parentPath.isProgram()) {
1355
1293
  return;
1356
1294
  }
1357
- if (path6.node.expression.type === "AssignmentExpression") {
1358
- const left = path6.node.expression.left;
1295
+ if (path5.node.expression.type === "AssignmentExpression") {
1296
+ const left = path5.node.expression.left;
1359
1297
  if (left.type === "MemberExpression" && left.object.type === "Identifier" && (exportsToRemove.includes(left.object.name) || removedExportLocalNames.has(left.object.name))) {
1360
- markedForRemoval.add(path6);
1298
+ markedForRemoval.add(path5);
1361
1299
  }
1362
1300
  }
1363
1301
  }
1364
1302
  });
1365
1303
  if (markedForRemoval.size > 0 || exportsFiltered) {
1366
- for (let path6 of markedForRemoval) {
1367
- path6.remove();
1304
+ for (let path5 of markedForRemoval) {
1305
+ path5.remove();
1368
1306
  }
1369
1307
  (0, import_babel_dead_code_elimination.deadCodeElimination)(ast, previouslyReferencedIdentifiers);
1370
1308
  }
@@ -1415,7 +1353,7 @@ var SERVER_ONLY_ROUTE_EXPORTS = [
1415
1353
  ...SERVER_ONLY_COMPONENT_EXPORTS,
1416
1354
  "loader",
1417
1355
  "action",
1418
- "middleware",
1356
+ "unstable_middleware",
1419
1357
  "headers"
1420
1358
  ];
1421
1359
  var SERVER_ONLY_ROUTE_EXPORTS_SET = new Set(SERVER_ONLY_ROUTE_EXPORTS);
@@ -1446,7 +1384,7 @@ var CLIENT_COMPONENT_EXPORTS = [
1446
1384
  var CLIENT_NON_COMPONENT_EXPORTS = [
1447
1385
  "clientAction",
1448
1386
  "clientLoader",
1449
- "clientMiddleware",
1387
+ "unstable_clientMiddleware",
1450
1388
  "handle",
1451
1389
  "meta",
1452
1390
  "links",
@@ -1680,22 +1618,16 @@ function validatePluginOrder() {
1680
1618
  (plugin) => pluginName.includes(plugin.name)
1681
1619
  );
1682
1620
  };
1683
- let reactRouterRscPluginIndex = pluginIndex("react-router/rsc");
1684
- let viteRscPluginIndex = pluginIndex("rsc");
1685
- if (reactRouterRscPluginIndex >= 0 && viteRscPluginIndex >= 0 && reactRouterRscPluginIndex > viteRscPluginIndex) {
1686
- throw new Error(
1687
- `The "@vitejs/plugin-rsc" plugin should be placed after the React Router RSC plugin in your Vite config`
1688
- );
1689
- }
1690
- let reactRouterPluginIndex = pluginIndex([
1691
- "react-router",
1692
- "react-router/rsc"
1693
- ]);
1694
- let mdxPluginIndex = pluginIndex("@mdx-js/rollup");
1695
- if (mdxPluginIndex >= 0 && mdxPluginIndex > reactRouterPluginIndex) {
1696
- throw new Error(
1697
- `The "@mdx-js/rollup" plugin should be placed before the React Router plugin in your Vite config`
1698
- );
1621
+ let rollupPrePlugins = [
1622
+ { pluginName: "@mdx-js/rollup", displayName: "@mdx-js/rollup" }
1623
+ ];
1624
+ for (let prePlugin of rollupPrePlugins) {
1625
+ let prePluginIndex = pluginIndex(prePlugin.pluginName);
1626
+ if (prePluginIndex >= 0 && prePluginIndex > pluginIndex(["react-router", "react-router/rsc"])) {
1627
+ throw new Error(
1628
+ `The "${prePlugin.displayName}" plugin should be placed before the React Router plugin in your Vite config file`
1629
+ );
1630
+ }
1699
1631
  }
1700
1632
  }
1701
1633
  };
@@ -1708,56 +1640,18 @@ function reactRouterRSCVitePlugin() {
1708
1640
  let typegenWatcherPromise;
1709
1641
  let viteCommand;
1710
1642
  let routeIdByFile;
1711
- let logger;
1712
- const defaultEntries = getDefaultEntries();
1713
1643
  return [
1714
1644
  {
1715
1645
  name: "react-router/rsc",
1716
1646
  async config(viteUserConfig, { command, mode }) {
1717
1647
  await import_es_module_lexer2.init;
1718
- await preloadVite();
1719
1648
  viteCommand = command;
1720
1649
  const rootDirectory = getRootDirectory(viteUserConfig);
1721
1650
  const watch2 = command === "serve";
1722
- configLoader = await createConfigLoader({
1723
- rootDirectory,
1724
- mode,
1725
- watch: watch2,
1726
- validateConfig: (userConfig) => {
1727
- let errors = [];
1728
- if (userConfig.buildEnd) errors.push("buildEnd");
1729
- if (userConfig.prerender) errors.push("prerender");
1730
- if (userConfig.presets?.length) errors.push("presets");
1731
- if (userConfig.routeDiscovery) errors.push("routeDiscovery");
1732
- if (userConfig.serverBundles) errors.push("serverBundles");
1733
- if (userConfig.ssr === false) errors.push("ssr: false");
1734
- if (userConfig.future?.unstable_splitRouteModules)
1735
- errors.push("future.unstable_splitRouteModules");
1736
- if (userConfig.future?.unstable_viteEnvironmentApi === false)
1737
- errors.push("future.unstable_viteEnvironmentApi: false");
1738
- if (userConfig.future?.v8_middleware === false)
1739
- errors.push("future.v8_middleware: false");
1740
- if (userConfig.future?.unstable_subResourceIntegrity)
1741
- errors.push("future.unstable_subResourceIntegrity");
1742
- if (errors.length) {
1743
- return `RSC Framework Mode does not currently support the following React Router config:
1744
- ${errors.map((x) => ` - ${x}`).join("\n")}
1745
- `;
1746
- }
1747
- }
1748
- });
1651
+ configLoader = await createConfigLoader({ rootDirectory, mode, watch: watch2 });
1749
1652
  const configResult = await configLoader.getConfig();
1750
1653
  if (!configResult.ok) throw new Error(configResult.error);
1751
1654
  config = configResult.value;
1752
- if (viteUserConfig.base && config.basename !== "/" && viteCommand === "serve" && !viteUserConfig.server?.middlewareMode && !config.basename.startsWith(viteUserConfig.base)) {
1753
- throw new Error(
1754
- "When using the React Router `basename` and the Vite `base` config, the `basename` config must begin with `base` for the default Vite dev server."
1755
- );
1756
- }
1757
- const vite2 = await import("vite");
1758
- logger = vite2.createLogger(viteUserConfig.logLevel, {
1759
- prefix: "[react-router]"
1760
- });
1761
1655
  return {
1762
1656
  resolve: {
1763
1657
  dedupe: [
@@ -1768,14 +1662,10 @@ ${errors.map((x) => ` - ${x}`).join("\n")}
1768
1662
  // You must render this element inside a <Remix> element`.
1769
1663
  "react-router",
1770
1664
  "react-router/dom",
1771
- ...hasDependency({ name: "react-router-dom", rootDirectory }) ? ["react-router-dom"] : []
1665
+ "react-router-dom"
1772
1666
  ]
1773
1667
  },
1774
1668
  optimizeDeps: {
1775
- entries: getOptimizeDepsEntries({
1776
- entryClientFilePath: defaultEntries.client,
1777
- reactRouterConfig: config
1778
- }),
1779
1669
  esbuildOptions: {
1780
1670
  jsx: "automatic"
1781
1671
  },
@@ -1787,8 +1677,7 @@ ${errors.map((x) => ` - ${x}`).join("\n")}
1787
1677
  "react/jsx-runtime",
1788
1678
  "react/jsx-dev-runtime",
1789
1679
  "react-dom",
1790
- "react-dom/client",
1791
- "react-router/internal/react-server-client"
1680
+ "react-dom/client"
1792
1681
  ]
1793
1682
  },
1794
1683
  esbuild: {
@@ -1798,47 +1687,17 @@ ${errors.map((x) => ` - ${x}`).join("\n")}
1798
1687
  environments: {
1799
1688
  client: {
1800
1689
  build: {
1801
- rollupOptions: {
1802
- input: {
1803
- index: defaultEntries.client
1804
- }
1805
- },
1806
- outDir: (0, import_pathe6.join)(config.buildDirectory, "client")
1690
+ outDir: (0, import_pathe5.join)(config.buildDirectory, "client")
1807
1691
  }
1808
1692
  },
1809
1693
  rsc: {
1810
1694
  build: {
1811
- rollupOptions: {
1812
- input: {
1813
- // We use a virtual entry here so that consumers can import
1814
- // it as `virtual:react-router/unstable_rsc/rsc-entry`
1815
- // without needing to know the actual file path, which is
1816
- // important when using the default entries.
1817
- index: defaultEntries.rsc
1818
- },
1819
- output: {
1820
- entryFileNames: config.serverBuildFile,
1821
- format: config.serverModuleFormat
1822
- }
1823
- },
1824
- outDir: (0, import_pathe6.join)(config.buildDirectory, "server")
1695
+ outDir: (0, import_pathe5.join)(config.buildDirectory, "server")
1825
1696
  }
1826
1697
  },
1827
1698
  ssr: {
1828
1699
  build: {
1829
- rollupOptions: {
1830
- input: {
1831
- index: defaultEntries.ssr
1832
- },
1833
- output: {
1834
- // Note: We don't set `entryFileNames` here because it's
1835
- // considered private to the RSC environment build, and
1836
- // @vitejs/plugin-rsc currently breaks if it's set to
1837
- // something other than `index.js`.
1838
- format: config.serverModuleFormat
1839
- }
1840
- },
1841
- outDir: (0, import_pathe6.join)(config.buildDirectory, "server/__ssr_build")
1700
+ outDir: (0, import_pathe5.join)(config.buildDirectory, "server/__ssr_build")
1842
1701
  }
1843
1702
  }
1844
1703
  },
@@ -1865,35 +1724,6 @@ ${errors.map((x) => ` - ${x}`).join("\n")}
1865
1724
  }
1866
1725
  };
1867
1726
  },
1868
- async configureServer(viteDevServer) {
1869
- configLoader.onChange(
1870
- async ({
1871
- result,
1872
- configCodeChanged,
1873
- routeConfigCodeChanged,
1874
- configChanged,
1875
- routeConfigChanged
1876
- }) => {
1877
- if (!result.ok) {
1878
- invalidateVirtualModules(viteDevServer);
1879
- logger.error(result.error, {
1880
- clear: true,
1881
- timestamp: true
1882
- });
1883
- return;
1884
- }
1885
- let message = configChanged ? "Config changed." : routeConfigChanged ? "Route config changed." : configCodeChanged ? "Config saved." : routeConfigCodeChanged ? " Route config saved." : "Config saved";
1886
- logger.info(import_picocolors3.default.green(message), {
1887
- clear: true,
1888
- timestamp: true
1889
- });
1890
- config = result.value;
1891
- if (configChanged || routeConfigChanged) {
1892
- invalidateVirtualModules(viteDevServer);
1893
- }
1894
- }
1895
- );
1896
- },
1897
1727
  async buildEnd() {
1898
1728
  await configLoader.close();
1899
1729
  }
@@ -1920,12 +1750,6 @@ ${errors.map((x) => ` - ${x}`).join("\n")}
1920
1750
  (await typegenWatcherPromise)?.close();
1921
1751
  }
1922
1752
  },
1923
- {
1924
- name: "react-router/rsc/virtual-rsc-entry",
1925
- resolveId(id) {
1926
- if (id === virtual.rscEntry.id) return defaultEntries.rsc;
1927
- }
1928
- },
1929
1753
  {
1930
1754
  name: "react-router/rsc/virtual-route-config",
1931
1755
  resolveId(id) {
@@ -1957,19 +1781,6 @@ ${errors.map((x) => ` - ${x}`).join("\n")}
1957
1781
  });
1958
1782
  }
1959
1783
  },
1960
- {
1961
- name: "react-router/rsc/virtual-basename",
1962
- resolveId(id) {
1963
- if (id === virtual.basename.id) {
1964
- return virtual.basename.resolvedId;
1965
- }
1966
- },
1967
- load(id) {
1968
- if (id === virtual.basename.resolvedId) {
1969
- return `export default ${JSON.stringify(config.basename)};`;
1970
- }
1971
- }
1972
- },
1973
1784
  {
1974
1785
  name: "react-router/rsc/hmr/inject-runtime",
1975
1786
  enforce: "pre",
@@ -1997,10 +1808,10 @@ ${errors.map((x) => ` - ${x}`).join("\n")}
1997
1808
  },
1998
1809
  async load(id) {
1999
1810
  if (id !== virtual.hmrRuntime.resolvedId) return;
2000
- const reactRefreshDir = import_pathe6.default.dirname(
1811
+ const reactRefreshDir = import_pathe5.default.dirname(
2001
1812
  require.resolve("react-refresh/package.json")
2002
1813
  );
2003
- const reactRefreshRuntimePath = import_pathe6.default.join(
1814
+ const reactRefreshRuntimePath = import_pathe5.default.join(
2004
1815
  reactRefreshDir,
2005
1816
  "cjs/react-refresh-runtime.development.js"
2006
1817
  );
@@ -2057,16 +1868,10 @@ ${errors.map((x) => ` - ${x}`).join("\n")}
2057
1868
  name: "react-router/rsc/hmr/updates",
2058
1869
  async hotUpdate({ server, file, modules }) {
2059
1870
  if (this.environment.name !== "rsc") return;
2060
- const clientModules = server.environments.client.moduleGraph.getModulesByFile(file);
2061
- const vite2 = await import("vite");
2062
- const isServerOnlyChange = !clientModules || clientModules.size === 0 || // Handle CSS injected from server-first routes (with ?direct query
2063
- // string) since the client graph has a reference to the CSS
2064
- vite2.isCSSRequest(file) && Array.from(clientModules).some(
2065
- (mod) => mod.id?.includes("?direct")
2066
- );
1871
+ const isServerOnlyChange = (server.environments.client.moduleGraph.getModulesByFile(file)?.size ?? 0) === 0;
2067
1872
  for (const mod of getModulesWithImporters(modules)) {
2068
1873
  if (!mod.file) continue;
2069
- const normalizedPath = import_pathe6.default.normalize(mod.file);
1874
+ const normalizedPath = import_pathe5.default.normalize(mod.file);
2070
1875
  const routeId = routeIdByFile?.get(normalizedPath);
2071
1876
  if (routeId !== void 0) {
2072
1877
  const routeSource = await (0, import_promises2.readFile)(normalizedPath, "utf8");
@@ -2096,56 +1901,45 @@ ${errors.map((x) => ` - ${x}`).join("\n")}
2096
1901
  return modules;
2097
1902
  }
2098
1903
  },
2099
- validatePluginOrder()
1904
+ validatePluginOrder(),
1905
+ (0, import_plugin_rsc.default)({ entries: getRscEntries() })
2100
1906
  ];
2101
1907
  }
2102
1908
  var virtual = {
2103
1909
  routeConfig: create("unstable_rsc/routes"),
2104
1910
  injectHmrRuntime: create("unstable_rsc/inject-hmr-runtime"),
2105
- hmrRuntime: create("unstable_rsc/runtime"),
2106
- basename: create("unstable_rsc/basename"),
2107
- rscEntry: create("unstable_rsc/rsc-entry")
1911
+ hmrRuntime: create("unstable_rsc/runtime")
2108
1912
  };
2109
- function invalidateVirtualModules(viteDevServer) {
2110
- for (const vmod of Object.values(virtual)) {
2111
- for (const env of Object.values(viteDevServer.environments)) {
2112
- const mod = env.moduleGraph.getModuleById(vmod.resolvedId);
2113
- if (mod) {
2114
- env.moduleGraph.invalidateModule(mod);
2115
- }
2116
- }
2117
- }
2118
- }
2119
1913
  function getRootDirectory(viteUserConfig) {
2120
1914
  return viteUserConfig.root ?? process.env.REACT_ROUTER_ROOT ?? process.cwd();
2121
1915
  }
1916
+ function getRscEntries() {
1917
+ const entriesDir = (0, import_pathe5.join)(
1918
+ getDevPackageRoot(),
1919
+ "dist",
1920
+ "config",
1921
+ "default-rsc-entries"
1922
+ );
1923
+ return {
1924
+ client: (0, import_pathe5.join)(entriesDir, "entry.client.tsx"),
1925
+ rsc: (0, import_pathe5.join)(entriesDir, "entry.rsc.tsx"),
1926
+ ssr: (0, import_pathe5.join)(entriesDir, "entry.ssr.tsx")
1927
+ };
1928
+ }
2122
1929
  function getDevPackageRoot() {
2123
- const currentDir = (0, import_pathe6.dirname)(__dirname);
1930
+ const currentDir = (0, import_pathe5.dirname)(__dirname);
2124
1931
  let dir = currentDir;
2125
- while (dir !== (0, import_pathe6.dirname)(dir)) {
1932
+ while (dir !== (0, import_pathe5.dirname)(dir)) {
2126
1933
  try {
2127
- const packageJsonPath = (0, import_pathe6.join)(dir, "package.json");
1934
+ const packageJsonPath = (0, import_pathe5.join)(dir, "package.json");
2128
1935
  (0, import_fs.readFileSync)(packageJsonPath, "utf-8");
2129
1936
  return dir;
2130
1937
  } catch {
2131
- dir = (0, import_pathe6.dirname)(dir);
1938
+ dir = (0, import_pathe5.dirname)(dir);
2132
1939
  }
2133
1940
  }
2134
1941
  throw new Error("Could not find package.json");
2135
1942
  }
2136
- function getDefaultEntries() {
2137
- const defaultEntriesDir = (0, import_pathe6.join)(
2138
- getDevPackageRoot(),
2139
- "dist",
2140
- "config",
2141
- "default-rsc-entries"
2142
- );
2143
- return {
2144
- rsc: (0, import_pathe6.join)(defaultEntriesDir, "entry.rsc.tsx"),
2145
- ssr: (0, import_pathe6.join)(defaultEntriesDir, "entry.ssr.tsx"),
2146
- client: (0, import_pathe6.join)(defaultEntriesDir, "entry.client.tsx")
2147
- };
2148
- }
2149
1943
  function getModulesWithImporters(modules) {
2150
1944
  const visited = /* @__PURE__ */ new Set();
2151
1945
  const result = /* @__PURE__ */ new Set();