@react-router/dev 0.0.0-experimental-795b50c5b → 0.0.0-experimental-ae6d61df4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/vite.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-795b50c5b
2
+ * @react-router/dev v0.0.0-experimental-ae6d61df4
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -48,15 +48,14 @@ module.exports = __toCommonJS(vite_exports);
48
48
  var import_node_crypto = require("crypto");
49
49
  var import_node_fs2 = require("fs");
50
50
  var import_promises2 = require("fs/promises");
51
- var path5 = __toESM(require("path"));
51
+ var path6 = __toESM(require("path"));
52
52
  var url = __toESM(require("url"));
53
53
  var babel = __toESM(require("@babel/core"));
54
54
  var import_react_router2 = require("react-router");
55
55
  var import_es_module_lexer = require("es-module-lexer");
56
- var import_tinyglobby = require("tinyglobby");
57
56
  var import_pick3 = __toESM(require("lodash/pick"));
58
57
  var import_jsesc = __toESM(require("jsesc"));
59
- var import_picocolors3 = __toESM(require("picocolors"));
58
+ var import_picocolors4 = __toESM(require("picocolors"));
60
59
  var import_kebabCase = __toESM(require("lodash/kebabCase"));
61
60
 
62
61
  // typegen/index.ts
@@ -247,7 +246,7 @@ function validateRouteConfig({
247
246
  `Route config in "${routeConfigFile}" is invalid.`,
248
247
  root ? `${root}` : [],
249
248
  nested ? Object.entries(nested).map(
250
- ([path6, message]) => `Path: routes.${path6}
249
+ ([path7, message]) => `Path: routes.${path7}
251
250
  ${message}`
252
251
  ) : []
253
252
  ].flat().join("\n\n")
@@ -367,7 +366,8 @@ async function resolveConfig({
367
366
  root,
368
367
  viteNodeContext,
369
368
  reactRouterConfigFile,
370
- skipRoutes
369
+ skipRoutes,
370
+ validateConfig
371
371
  }) {
372
372
  let reactRouterUserConfig = {};
373
373
  if (reactRouterConfigFile) {
@@ -385,6 +385,12 @@ async function resolveConfig({
385
385
  return err(`${reactRouterConfigFile} must export a config`);
386
386
  }
387
387
  reactRouterUserConfig = configModule.default;
388
+ if (validateConfig) {
389
+ const error = validateConfig(reactRouterUserConfig);
390
+ if (error) {
391
+ return err(error);
392
+ }
393
+ }
388
394
  } catch (error) {
389
395
  return err(`Error loading ${reactRouterConfigFile}: ${error}`);
390
396
  }
@@ -473,7 +479,7 @@ async function resolveConfig({
473
479
  }
474
480
  let appDirectory = import_pathe3.default.resolve(root, userAppDirectory || "app");
475
481
  let buildDirectory = import_pathe3.default.resolve(root, userBuildDirectory);
476
- let rootRouteFile = findEntry(appDirectory, "root");
482
+ let rootRouteFile = findEntry(appDirectory, "root", { absolute: true });
477
483
  if (!rootRouteFile) {
478
484
  let rootRouteDisplayPath = import_pathe3.default.relative(
479
485
  root,
@@ -514,7 +520,7 @@ async function resolveConfig({
514
520
  {
515
521
  id: "root",
516
522
  path: "",
517
- file: rootRouteFile,
523
+ file: import_pathe3.default.relative(appDirectory, rootRouteFile),
518
524
  children: result.routeConfig
519
525
  }
520
526
  ];
@@ -552,6 +558,7 @@ async function resolveConfig({
552
558
  serverBundles,
553
559
  serverModuleFormat,
554
560
  ssr,
561
+ unstable_rootRouteFile: rootRouteFile,
555
562
  unstable_routeConfig: routeConfig
556
563
  });
557
564
  for (let preset of reactRouterUserConfig.presets ?? []) {
@@ -563,7 +570,8 @@ async function createConfigLoader({
563
570
  rootDirectory: root,
564
571
  watch: watch2,
565
572
  mode,
566
- skipRoutes
573
+ skipRoutes,
574
+ validateConfig
567
575
  }) {
568
576
  root = import_pathe3.default.normalize(root ?? process.env.REACT_ROUTER_ROOT ?? process.cwd());
569
577
  let vite2 = await import("vite");
@@ -582,7 +590,13 @@ async function createConfigLoader({
582
590
  });
583
591
  };
584
592
  updateReactRouterConfigFile();
585
- let getConfig = () => resolveConfig({ root, viteNodeContext, reactRouterConfigFile, skipRoutes });
593
+ let getConfig = () => resolveConfig({
594
+ root,
595
+ viteNodeContext,
596
+ reactRouterConfigFile,
597
+ skipRoutes,
598
+ validateConfig
599
+ });
586
600
  let appDirectory;
587
601
  let initialConfigResult = await getConfig();
588
602
  if (!initialConfigResult.ok) {
@@ -604,11 +618,11 @@ async function createConfigLoader({
604
618
  if (!fsWatcher) {
605
619
  fsWatcher = import_chokidar.default.watch([root, appDirectory], {
606
620
  ignoreInitial: true,
607
- ignored: (path6) => {
608
- let dirname4 = import_pathe3.default.dirname(path6);
621
+ ignored: (path7) => {
622
+ let dirname4 = import_pathe3.default.dirname(path7);
609
623
  return !dirname4.startsWith(appDirectory) && // Ensure we're only watching files outside of the app directory
610
624
  // that are at the root level, not nested in subdirectories
611
- path6 !== root && // Watch the root directory itself
625
+ path7 !== root && // Watch the root directory itself
612
626
  dirname4 !== root;
613
627
  }
614
628
  });
@@ -801,7 +815,8 @@ function isEntryFileDependency(moduleGraph, entryFilepath, filepath, visited = /
801
815
  async function createContext2({
802
816
  rootDirectory,
803
817
  watch: watch2,
804
- mode
818
+ mode,
819
+ rsc
805
820
  }) {
806
821
  const configLoader = await createConfigLoader({ rootDirectory, mode, watch: watch2 });
807
822
  const configResult = await configLoader.getConfig();
@@ -812,7 +827,8 @@ async function createContext2({
812
827
  return {
813
828
  configLoader,
814
829
  rootDirectory,
815
- config
830
+ config,
831
+ rsc
816
832
  };
817
833
  }
818
834
 
@@ -867,7 +883,7 @@ function fullpath(lineage2) {
867
883
  if (lineage2.length === 1 && route?.id === "root") return "/";
868
884
  const isLayout = route && route.index !== true && route.path === void 0;
869
885
  if (isLayout) return void 0;
870
- return "/" + lineage2.map((route2) => route2.path?.replace(/^\//, "")?.replace(/\/$/, "")).filter((path6) => path6 !== void 0 && path6 !== "").join("/");
886
+ return "/" + lineage2.map((route2) => route2.path?.replace(/^\//, "")?.replace(/\/$/, "")).filter((path7) => path7 !== void 0 && path7 !== "").join("/");
871
887
  }
872
888
 
873
889
  // typegen/generate.ts
@@ -1023,8 +1039,8 @@ function routeFilesType({
1023
1039
  );
1024
1040
  }
1025
1041
  function isInAppDirectory(ctx, routeFile) {
1026
- const path6 = Path3.resolve(ctx.config.appDirectory, routeFile);
1027
- return path6.startsWith(ctx.config.appDirectory);
1042
+ const path7 = Path3.resolve(ctx.config.appDirectory, routeFile);
1043
+ return path7.startsWith(ctx.config.appDirectory);
1028
1044
  }
1029
1045
  function getRouteAnnotations({
1030
1046
  ctx,
@@ -1089,7 +1105,7 @@ function getRouteAnnotations({
1089
1105
  module: Module
1090
1106
  }>
1091
1107
  ` + "\n\n" + generate(matchesType).code + "\n\n" + import_dedent.default`
1092
- type Annotations = GetAnnotations<Info & { module: Module, matches: Matches }>;
1108
+ type Annotations = GetAnnotations<Info & { module: Module, matches: Matches }, ${ctx.rsc}>;
1093
1109
 
1094
1110
  export namespace Route {
1095
1111
  // links
@@ -1136,21 +1152,21 @@ function getRouteAnnotations({
1136
1152
  return { filename: filename2, content };
1137
1153
  }
1138
1154
  function relativeImportSource(from, to) {
1139
- let path6 = Path3.relative(Path3.dirname(from), to);
1140
- let extension = Path3.extname(path6);
1141
- path6 = Path3.join(Path3.dirname(path6), Pathe.filename(path6));
1142
- if (!path6.startsWith("../")) path6 = "./" + path6;
1155
+ let path7 = Path3.relative(Path3.dirname(from), to);
1156
+ let extension = Path3.extname(path7);
1157
+ path7 = Path3.join(Path3.dirname(path7), Pathe.filename(path7));
1158
+ if (!path7.startsWith("../")) path7 = "./" + path7;
1143
1159
  if (!extension || /\.(js|ts)x?$/.test(extension)) {
1144
1160
  extension = ".js";
1145
1161
  }
1146
- return path6 + extension;
1162
+ return path7 + extension;
1147
1163
  }
1148
1164
  function rootDirsPath(ctx, typesPath) {
1149
1165
  const rel = Path3.relative(typesDirectory(ctx), typesPath);
1150
1166
  return Path3.join(ctx.rootDirectory, rel);
1151
1167
  }
1152
- function paramsType(path6) {
1153
- const params = parse2(path6);
1168
+ function paramsType(path7) {
1169
+ const params = parse2(path7);
1154
1170
  return t2.tsTypeLiteral(
1155
1171
  Object.entries(params).map(([param, isRequired]) => {
1156
1172
  const property = t2.tsPropertySignature(
@@ -1200,8 +1216,8 @@ async function write(...files) {
1200
1216
  })
1201
1217
  );
1202
1218
  }
1203
- async function watch(rootDirectory, { mode, logger }) {
1204
- const ctx = await createContext2({ rootDirectory, mode, watch: true });
1219
+ async function watch(rootDirectory, { mode, logger, rsc }) {
1220
+ const ctx = await createContext2({ rootDirectory, mode, rsc, watch: true });
1205
1221
  await import_promises.default.rm(typesDirectory(ctx), { recursive: true, force: true });
1206
1222
  await write(
1207
1223
  generateFuture(ctx),
@@ -1486,11 +1502,11 @@ var getCssStringFromViteDevModuleCode = (code) => {
1486
1502
  let cssContent = void 0;
1487
1503
  const ast = import_parser.parse(code, { sourceType: "module" });
1488
1504
  traverse(ast, {
1489
- VariableDeclaration(path6) {
1490
- const declaration = path6.node.declarations[0];
1505
+ VariableDeclaration(path7) {
1506
+ const declaration = path7.node.declarations[0];
1491
1507
  if (declaration?.id?.type === "Identifier" && declaration.id.name === "__vite__css" && declaration.init?.type === "StringLiteral") {
1492
1508
  cssContent = declaration.init.value;
1493
- path6.stop();
1509
+ path7.stop();
1494
1510
  }
1495
1511
  }
1496
1512
  });
@@ -1507,6 +1523,15 @@ function create(name) {
1507
1523
  };
1508
1524
  }
1509
1525
 
1526
+ // vite/resolve-relative-route-file-path.ts
1527
+ var import_pathe4 = __toESM(require("pathe"));
1528
+ function resolveRelativeRouteFilePath(route, reactRouterConfig) {
1529
+ let vite2 = getVite();
1530
+ let file = route.file;
1531
+ let fullPath = import_pathe4.default.resolve(reactRouterConfig.appDirectory, file);
1532
+ return vite2.normalizePath(fullPath);
1533
+ }
1534
+
1510
1535
  // vite/combine-urls.ts
1511
1536
  function combineURLs(baseURL, relativeURL) {
1512
1537
  return relativeURL ? baseURL.replace(/\/+$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
@@ -1520,10 +1545,10 @@ var removeExports = (ast, exportsToRemove) => {
1520
1545
  let markedForRemoval = /* @__PURE__ */ new Set();
1521
1546
  let removedExportLocalNames = /* @__PURE__ */ new Set();
1522
1547
  traverse(ast, {
1523
- ExportDeclaration(path6) {
1524
- if (path6.node.type === "ExportNamedDeclaration") {
1525
- if (path6.node.specifiers.length) {
1526
- path6.node.specifiers = path6.node.specifiers.filter((specifier) => {
1548
+ ExportDeclaration(path7) {
1549
+ if (path7.node.type === "ExportNamedDeclaration") {
1550
+ if (path7.node.specifiers.length) {
1551
+ path7.node.specifiers = path7.node.specifiers.filter((specifier) => {
1527
1552
  if (specifier.type === "ExportSpecifier" && specifier.exported.type === "Identifier") {
1528
1553
  if (exportsToRemove.includes(specifier.exported.name)) {
1529
1554
  exportsFiltered = true;
@@ -1535,12 +1560,12 @@ var removeExports = (ast, exportsToRemove) => {
1535
1560
  }
1536
1561
  return true;
1537
1562
  });
1538
- if (path6.node.specifiers.length === 0) {
1539
- markedForRemoval.add(path6);
1563
+ if (path7.node.specifiers.length === 0) {
1564
+ markedForRemoval.add(path7);
1540
1565
  }
1541
1566
  }
1542
- if (path6.node.declaration?.type === "VariableDeclaration") {
1543
- let declaration = path6.node.declaration;
1567
+ if (path7.node.declaration?.type === "VariableDeclaration") {
1568
+ let declaration = path7.node.declaration;
1544
1569
  declaration.declarations = declaration.declarations.filter(
1545
1570
  (declaration2) => {
1546
1571
  if (declaration2.id.type === "Identifier" && exportsToRemove.includes(declaration2.id.name)) {
@@ -1554,30 +1579,30 @@ var removeExports = (ast, exportsToRemove) => {
1554
1579
  }
1555
1580
  );
1556
1581
  if (declaration.declarations.length === 0) {
1557
- markedForRemoval.add(path6);
1582
+ markedForRemoval.add(path7);
1558
1583
  }
1559
1584
  }
1560
- if (path6.node.declaration?.type === "FunctionDeclaration") {
1561
- let id = path6.node.declaration.id;
1585
+ if (path7.node.declaration?.type === "FunctionDeclaration") {
1586
+ let id = path7.node.declaration.id;
1562
1587
  if (id && exportsToRemove.includes(id.name)) {
1563
- markedForRemoval.add(path6);
1588
+ markedForRemoval.add(path7);
1564
1589
  }
1565
1590
  }
1566
- if (path6.node.declaration?.type === "ClassDeclaration") {
1567
- let id = path6.node.declaration.id;
1591
+ if (path7.node.declaration?.type === "ClassDeclaration") {
1592
+ let id = path7.node.declaration.id;
1568
1593
  if (id && exportsToRemove.includes(id.name)) {
1569
- markedForRemoval.add(path6);
1594
+ markedForRemoval.add(path7);
1570
1595
  }
1571
1596
  }
1572
1597
  }
1573
- if (path6.node.type === "ExportDefaultDeclaration") {
1598
+ if (path7.node.type === "ExportDefaultDeclaration") {
1574
1599
  if (exportsToRemove.includes("default")) {
1575
- markedForRemoval.add(path6);
1576
- if (path6.node.declaration) {
1577
- if (path6.node.declaration.type === "Identifier") {
1578
- removedExportLocalNames.add(path6.node.declaration.name);
1579
- } else if ((path6.node.declaration.type === "FunctionDeclaration" || path6.node.declaration.type === "ClassDeclaration") && path6.node.declaration.id) {
1580
- removedExportLocalNames.add(path6.node.declaration.id.name);
1600
+ markedForRemoval.add(path7);
1601
+ if (path7.node.declaration) {
1602
+ if (path7.node.declaration.type === "Identifier") {
1603
+ removedExportLocalNames.add(path7.node.declaration.name);
1604
+ } else if ((path7.node.declaration.type === "FunctionDeclaration" || path7.node.declaration.type === "ClassDeclaration") && path7.node.declaration.id) {
1605
+ removedExportLocalNames.add(path7.node.declaration.id.name);
1581
1606
  }
1582
1607
  }
1583
1608
  }
@@ -1585,21 +1610,21 @@ var removeExports = (ast, exportsToRemove) => {
1585
1610
  }
1586
1611
  });
1587
1612
  traverse(ast, {
1588
- ExpressionStatement(path6) {
1589
- if (!path6.parentPath.isProgram()) {
1613
+ ExpressionStatement(path7) {
1614
+ if (!path7.parentPath.isProgram()) {
1590
1615
  return;
1591
1616
  }
1592
- if (path6.node.expression.type === "AssignmentExpression") {
1593
- const left = path6.node.expression.left;
1617
+ if (path7.node.expression.type === "AssignmentExpression") {
1618
+ const left = path7.node.expression.left;
1594
1619
  if (left.type === "MemberExpression" && left.object.type === "Identifier" && (exportsToRemove.includes(left.object.name) || removedExportLocalNames.has(left.object.name))) {
1595
- markedForRemoval.add(path6);
1620
+ markedForRemoval.add(path7);
1596
1621
  }
1597
1622
  }
1598
1623
  }
1599
1624
  });
1600
1625
  if (markedForRemoval.size > 0 || exportsFiltered) {
1601
- for (let path6 of markedForRemoval) {
1602
- path6.remove();
1626
+ for (let path7 of markedForRemoval) {
1627
+ path7.remove();
1603
1628
  }
1604
1629
  (0, import_babel_dead_code_elimination.deadCodeElimination)(ast, previouslyReferencedIdentifiers);
1605
1630
  }
@@ -1644,6 +1669,18 @@ function invalidDestructureError(name) {
1644
1669
  return new Error(`Cannot remove destructured export "${name}"`);
1645
1670
  }
1646
1671
 
1672
+ // vite/has-dependency.ts
1673
+ function hasDependency({
1674
+ name,
1675
+ rootDirectory
1676
+ }) {
1677
+ try {
1678
+ return Boolean(require.resolve(name, { paths: [rootDirectory] }));
1679
+ } catch (err2) {
1680
+ return false;
1681
+ }
1682
+ }
1683
+
1647
1684
  // vite/cache.ts
1648
1685
  function getOrSetFromCache(cache, key, version, getValue) {
1649
1686
  if (!cache) {
@@ -1670,28 +1707,28 @@ function codeToAst(code, cache, cacheKey) {
1670
1707
  )
1671
1708
  );
1672
1709
  }
1673
- function assertNodePath(path6) {
1710
+ function assertNodePath(path7) {
1674
1711
  invariant(
1675
- path6 && !Array.isArray(path6),
1676
- `Expected a Path, but got ${Array.isArray(path6) ? "an array" : path6}`
1712
+ path7 && !Array.isArray(path7),
1713
+ `Expected a Path, but got ${Array.isArray(path7) ? "an array" : path7}`
1677
1714
  );
1678
1715
  }
1679
- function assertNodePathIsStatement(path6) {
1716
+ function assertNodePathIsStatement(path7) {
1680
1717
  invariant(
1681
- path6 && !Array.isArray(path6) && t.isStatement(path6.node),
1682
- `Expected a Statement path, but got ${Array.isArray(path6) ? "an array" : path6?.node?.type}`
1718
+ path7 && !Array.isArray(path7) && t.isStatement(path7.node),
1719
+ `Expected a Statement path, but got ${Array.isArray(path7) ? "an array" : path7?.node?.type}`
1683
1720
  );
1684
1721
  }
1685
- function assertNodePathIsVariableDeclarator(path6) {
1722
+ function assertNodePathIsVariableDeclarator(path7) {
1686
1723
  invariant(
1687
- path6 && !Array.isArray(path6) && t.isVariableDeclarator(path6.node),
1688
- `Expected an Identifier path, but got ${Array.isArray(path6) ? "an array" : path6?.node?.type}`
1724
+ path7 && !Array.isArray(path7) && t.isVariableDeclarator(path7.node),
1725
+ `Expected an Identifier path, but got ${Array.isArray(path7) ? "an array" : path7?.node?.type}`
1689
1726
  );
1690
1727
  }
1691
- function assertNodePathIsPattern(path6) {
1728
+ function assertNodePathIsPattern(path7) {
1692
1729
  invariant(
1693
- path6 && !Array.isArray(path6) && t.isPattern(path6.node),
1694
- `Expected a Pattern path, but got ${Array.isArray(path6) ? "an array" : path6?.node?.type}`
1730
+ path7 && !Array.isArray(path7) && t.isPattern(path7.node),
1731
+ `Expected a Pattern path, but got ${Array.isArray(path7) ? "an array" : path7?.node?.type}`
1695
1732
  );
1696
1733
  }
1697
1734
  function getExportDependencies(code, cache, cacheKey) {
@@ -1727,8 +1764,8 @@ function getExportDependencies(code, cache, cacheKey) {
1727
1764
  }
1728
1765
  let isWithinExportDestructuring = Boolean(
1729
1766
  identifier.findParent(
1730
- (path6) => Boolean(
1731
- path6.isPattern() && path6.parentPath?.isVariableDeclarator() && path6.parentPath.parentPath?.parentPath?.isExportNamedDeclaration()
1767
+ (path7) => Boolean(
1768
+ path7.isPattern() && path7.parentPath?.isVariableDeclarator() && path7.parentPath.parentPath?.parentPath?.isExportNamedDeclaration()
1732
1769
  )
1733
1770
  )
1734
1771
  );
@@ -1806,7 +1843,7 @@ function getExportDependencies(code, cache, cacheKey) {
1806
1843
  for (let specifier of node.specifiers) {
1807
1844
  if (t.isIdentifier(specifier.exported)) {
1808
1845
  let name = specifier.exported.name;
1809
- let specifierPath = exportPath.get("specifiers").find((path6) => path6.node === specifier);
1846
+ let specifierPath = exportPath.get("specifiers").find((path7) => path7.node === specifier);
1810
1847
  invariant(
1811
1848
  specifierPath,
1812
1849
  `Expected to find specifier path for ${name}`
@@ -1823,22 +1860,22 @@ function getExportDependencies(code, cache, cacheKey) {
1823
1860
  }
1824
1861
  );
1825
1862
  }
1826
- function getDependentIdentifiersForPath(path6, state) {
1863
+ function getDependentIdentifiersForPath(path7, state) {
1827
1864
  let { visited, identifiers } = state ?? {
1828
1865
  visited: /* @__PURE__ */ new Set(),
1829
1866
  identifiers: /* @__PURE__ */ new Set()
1830
1867
  };
1831
- if (visited.has(path6)) {
1868
+ if (visited.has(path7)) {
1832
1869
  return identifiers;
1833
1870
  }
1834
- visited.add(path6);
1835
- path6.traverse({
1836
- Identifier(path7) {
1837
- if (identifiers.has(path7)) {
1871
+ visited.add(path7);
1872
+ path7.traverse({
1873
+ Identifier(path8) {
1874
+ if (identifiers.has(path8)) {
1838
1875
  return;
1839
1876
  }
1840
- identifiers.add(path7);
1841
- let binding = path7.scope.getBinding(path7.node.name);
1877
+ identifiers.add(path8);
1878
+ let binding = path8.scope.getBinding(path8.node.name);
1842
1879
  if (!binding) {
1843
1880
  return;
1844
1881
  }
@@ -1860,7 +1897,7 @@ function getDependentIdentifiersForPath(path6, state) {
1860
1897
  }
1861
1898
  }
1862
1899
  });
1863
- let topLevelStatement = getTopLevelStatementPathForPath(path6);
1900
+ let topLevelStatement = getTopLevelStatementPathForPath(path7);
1864
1901
  let withinImportStatement = topLevelStatement.isImportDeclaration();
1865
1902
  let withinExportStatement = topLevelStatement.isExportDeclaration();
1866
1903
  if (!withinImportStatement && !withinExportStatement) {
@@ -1869,9 +1906,9 @@ function getDependentIdentifiersForPath(path6, state) {
1869
1906
  identifiers
1870
1907
  });
1871
1908
  }
1872
- if (withinExportStatement && path6.isIdentifier() && (t.isPattern(path6.parentPath.node) || // [foo]
1873
- t.isPattern(path6.parentPath.parentPath?.node))) {
1874
- let variableDeclarator = path6.findParent((p) => p.isVariableDeclarator());
1909
+ if (withinExportStatement && path7.isIdentifier() && (t.isPattern(path7.parentPath.node) || // [foo]
1910
+ t.isPattern(path7.parentPath.parentPath?.node))) {
1911
+ let variableDeclarator = path7.findParent((p) => p.isVariableDeclarator());
1875
1912
  assertNodePath(variableDeclarator);
1876
1913
  getDependentIdentifiersForPath(variableDeclarator, {
1877
1914
  visited,
@@ -1880,16 +1917,16 @@ function getDependentIdentifiersForPath(path6, state) {
1880
1917
  }
1881
1918
  return identifiers;
1882
1919
  }
1883
- function getTopLevelStatementPathForPath(path6) {
1884
- let ancestry = path6.getAncestry();
1920
+ function getTopLevelStatementPathForPath(path7) {
1921
+ let ancestry = path7.getAncestry();
1885
1922
  let topLevelStatement = ancestry[ancestry.length - 2];
1886
1923
  assertNodePathIsStatement(topLevelStatement);
1887
1924
  return topLevelStatement;
1888
1925
  }
1889
1926
  function getTopLevelStatementsForPaths(paths) {
1890
1927
  let topLevelStatements = /* @__PURE__ */ new Set();
1891
- for (let path6 of paths) {
1892
- let topLevelStatement = getTopLevelStatementPathForPath(path6);
1928
+ for (let path7 of paths) {
1929
+ let topLevelStatement = getTopLevelStatementPathForPath(path7);
1893
1930
  topLevelStatements.add(topLevelStatement.node);
1894
1931
  }
1895
1932
  return topLevelStatements;
@@ -2251,6 +2288,31 @@ function getRouteChunkNameFromModuleId(id) {
2251
2288
  return chunkName;
2252
2289
  }
2253
2290
 
2291
+ // vite/optimize-deps-entries.ts
2292
+ var import_tinyglobby = require("tinyglobby");
2293
+ function getOptimizeDepsEntries({
2294
+ entryClientFilePath,
2295
+ reactRouterConfig
2296
+ }) {
2297
+ if (!reactRouterConfig.future.unstable_optimizeDeps) {
2298
+ return [];
2299
+ }
2300
+ const vite2 = getVite();
2301
+ const viteMajorVersion = parseInt(vite2.version.split(".")[0], 10);
2302
+ return [
2303
+ vite2.normalizePath(entryClientFilePath),
2304
+ ...Object.values(reactRouterConfig.routes).map(
2305
+ (route) => resolveRelativeRouteFilePath(route, reactRouterConfig)
2306
+ )
2307
+ ].map(
2308
+ (entry) => (
2309
+ // In Vite 7, the `optimizeDeps.entries` option only accepts glob patterns.
2310
+ // In prior versions, absolute file paths were treated differently.
2311
+ viteMajorVersion >= 7 ? (0, import_tinyglobby.escapePath)(entry) : entry
2312
+ )
2313
+ );
2314
+ }
2315
+
2254
2316
  // vite/with-props.ts
2255
2317
  var namedComponentExports = ["HydrateFallback", "ErrorBoundary"];
2256
2318
  function isNamedComponentExport(name) {
@@ -2258,24 +2320,24 @@ function isNamedComponentExport(name) {
2258
2320
  }
2259
2321
  var decorateComponentExportsWithProps = (ast) => {
2260
2322
  const hocs = [];
2261
- function getHocUid(path6, hocName) {
2262
- const uid = path6.scope.generateUidIdentifier(hocName);
2323
+ function getHocUid(path7, hocName) {
2324
+ const uid = path7.scope.generateUidIdentifier(hocName);
2263
2325
  hocs.push([hocName, uid]);
2264
2326
  return uid;
2265
2327
  }
2266
2328
  traverse(ast, {
2267
- ExportDeclaration(path6) {
2268
- if (path6.isExportDefaultDeclaration()) {
2269
- const declaration = path6.get("declaration");
2329
+ ExportDeclaration(path7) {
2330
+ if (path7.isExportDefaultDeclaration()) {
2331
+ const declaration = path7.get("declaration");
2270
2332
  const expr = declaration.isExpression() ? declaration.node : declaration.isFunctionDeclaration() ? toFunctionExpression(declaration.node) : void 0;
2271
2333
  if (expr) {
2272
- const uid = getHocUid(path6, "UNSAFE_withComponentProps");
2334
+ const uid = getHocUid(path7, "UNSAFE_withComponentProps");
2273
2335
  declaration.replaceWith(t.callExpression(uid, [expr]));
2274
2336
  }
2275
2337
  return;
2276
2338
  }
2277
- if (path6.isExportNamedDeclaration()) {
2278
- const decl = path6.get("declaration");
2339
+ if (path7.isExportNamedDeclaration()) {
2340
+ const decl = path7.get("declaration");
2279
2341
  if (decl.isVariableDeclaration()) {
2280
2342
  decl.get("declarations").forEach((varDeclarator) => {
2281
2343
  const id = varDeclarator.get("id");
@@ -2285,7 +2347,7 @@ var decorateComponentExportsWithProps = (ast) => {
2285
2347
  if (!id.isIdentifier()) return;
2286
2348
  const { name } = id.node;
2287
2349
  if (!isNamedComponentExport(name)) return;
2288
- const uid = getHocUid(path6, `UNSAFE_with${name}Props`);
2350
+ const uid = getHocUid(path7, `UNSAFE_with${name}Props`);
2289
2351
  init.replaceWith(t.callExpression(uid, [expr]));
2290
2352
  });
2291
2353
  return;
@@ -2295,7 +2357,7 @@ var decorateComponentExportsWithProps = (ast) => {
2295
2357
  if (!id) return;
2296
2358
  const { name } = id;
2297
2359
  if (!isNamedComponentExport(name)) return;
2298
- const uid = getHocUid(path6, `UNSAFE_with${name}Props`);
2360
+ const uid = getHocUid(path7, `UNSAFE_with${name}Props`);
2299
2361
  decl.replaceWith(
2300
2362
  t.variableDeclaration("const", [
2301
2363
  t.variableDeclarator(
@@ -2340,16 +2402,57 @@ function validatePluginOrder() {
2340
2402
  (plugin) => pluginName.includes(plugin.name)
2341
2403
  );
2342
2404
  };
2343
- let rollupPrePlugins = [
2344
- { pluginName: "@mdx-js/rollup", displayName: "@mdx-js/rollup" }
2345
- ];
2346
- for (let prePlugin of rollupPrePlugins) {
2347
- let prePluginIndex = pluginIndex(prePlugin.pluginName);
2348
- if (prePluginIndex >= 0 && prePluginIndex > pluginIndex(["react-router", "react-router/rsc"])) {
2349
- throw new Error(
2350
- `The "${prePlugin.displayName}" plugin should be placed before the React Router plugin in your Vite config file`
2351
- );
2352
- }
2405
+ let reactRouterRscPluginIndex = pluginIndex("react-router/rsc");
2406
+ let viteRscPluginIndex = pluginIndex("rsc");
2407
+ if (reactRouterRscPluginIndex >= 0 && viteRscPluginIndex >= 0 && reactRouterRscPluginIndex > viteRscPluginIndex) {
2408
+ throw new Error(
2409
+ `The "@vitejs/plugin-rsc" plugin should be placed after the React Router RSC plugin in your Vite config`
2410
+ );
2411
+ }
2412
+ let reactRouterPluginIndex = pluginIndex([
2413
+ "react-router",
2414
+ "react-router/rsc"
2415
+ ]);
2416
+ let mdxPluginIndex = pluginIndex("@mdx-js/rollup");
2417
+ if (mdxPluginIndex >= 0 && mdxPluginIndex > reactRouterPluginIndex) {
2418
+ throw new Error(
2419
+ `The "@mdx-js/rollup" plugin should be placed before the React Router plugin in your Vite config`
2420
+ );
2421
+ }
2422
+ }
2423
+ };
2424
+ }
2425
+
2426
+ // vite/plugins/warn-on-client-source-maps.ts
2427
+ var import_picocolors3 = __toESM(require("picocolors"));
2428
+ function warnOnClientSourceMaps() {
2429
+ let viteConfig;
2430
+ let viteCommand;
2431
+ let logged = false;
2432
+ return {
2433
+ name: "react-router:warn-on-client-source-maps",
2434
+ config(_, configEnv) {
2435
+ viteCommand = configEnv.command;
2436
+ },
2437
+ configResolved(config) {
2438
+ viteConfig = config;
2439
+ },
2440
+ buildStart() {
2441
+ invariant(viteConfig);
2442
+ if (!logged && viteCommand === "build" && viteConfig.mode === "production" && !viteConfig.build.ssr && (viteConfig.build.sourcemap || viteConfig.environments?.client?.build.sourcemap)) {
2443
+ viteConfig.logger.warn(
2444
+ import_picocolors3.default.yellow(
2445
+ "\n" + import_picocolors3.default.bold(" \u26A0\uFE0F Source maps are enabled in production\n") + [
2446
+ "This makes your server code publicly",
2447
+ "visible in the browser. This is highly",
2448
+ "discouraged! If you insist, ensure that",
2449
+ "you are using environment variables for",
2450
+ "secrets and not hard-coding them in",
2451
+ "your source code."
2452
+ ].map((line) => " " + line).join("\n") + "\n"
2453
+ )
2454
+ );
2455
+ logged = true;
2353
2456
  }
2354
2457
  }
2355
2458
  };
@@ -2416,16 +2519,10 @@ var virtualHmrRuntime = create("hmr-runtime");
2416
2519
  var virtualInjectHmrRuntime = create("inject-hmr-runtime");
2417
2520
  var normalizeRelativeFilePath = (file, reactRouterConfig) => {
2418
2521
  let vite2 = getVite();
2419
- let fullPath = path5.resolve(reactRouterConfig.appDirectory, file);
2420
- let relativePath = path5.relative(reactRouterConfig.appDirectory, fullPath);
2522
+ let fullPath = path6.resolve(reactRouterConfig.appDirectory, file);
2523
+ let relativePath = path6.relative(reactRouterConfig.appDirectory, fullPath);
2421
2524
  return vite2.normalizePath(relativePath).split("?")[0];
2422
2525
  };
2423
- var resolveRelativeRouteFilePath = (route, reactRouterConfig) => {
2424
- let vite2 = getVite();
2425
- let file = route.file;
2426
- let fullPath = path5.resolve(reactRouterConfig.appDirectory, file);
2427
- return vite2.normalizePath(fullPath);
2428
- };
2429
2526
  var virtual = {
2430
2527
  serverBuild: create("server-build"),
2431
2528
  serverManifest: create("server-manifest"),
@@ -2446,7 +2543,7 @@ var getHash = (source, maxLength) => {
2446
2543
  var resolveChunk = (ctx, viteManifest, absoluteFilePath) => {
2447
2544
  let vite2 = getVite();
2448
2545
  let rootRelativeFilePath = vite2.normalizePath(
2449
- path5.relative(ctx.rootDirectory, absoluteFilePath)
2546
+ path6.relative(ctx.rootDirectory, absoluteFilePath)
2450
2547
  );
2451
2548
  let entryChunk = viteManifest[rootRelativeFilePath];
2452
2549
  if (!entryChunk) {
@@ -2535,7 +2632,7 @@ function dedupe(array2) {
2535
2632
  return [...new Set(array2)];
2536
2633
  }
2537
2634
  var writeFileSafe = async (file, contents) => {
2538
- await (0, import_promises2.mkdir)(path5.dirname(file), { recursive: true });
2635
+ await (0, import_promises2.mkdir)(path6.dirname(file), { recursive: true });
2539
2636
  await (0, import_promises2.writeFile)(file, contents);
2540
2637
  };
2541
2638
  var getExportNames = (code) => {
@@ -2561,7 +2658,7 @@ var compileRouteFile = async (viteChildCompiler, ctx, routeFile, readRouteFile)
2561
2658
  }
2562
2659
  let ssr = true;
2563
2660
  let { pluginContainer, moduleGraph } = viteChildCompiler;
2564
- let routePath = path5.resolve(ctx.reactRouterConfig.appDirectory, routeFile);
2661
+ let routePath = path6.resolve(ctx.reactRouterConfig.appDirectory, routeFile);
2565
2662
  let url2 = resolveFileUrl(ctx, routePath);
2566
2663
  let resolveId = async () => {
2567
2664
  let result = await pluginContainer.resolveId(url2, void 0, { ssr });
@@ -2603,12 +2700,12 @@ var resolveEnvironmentBuildContext = ({
2603
2700
  };
2604
2701
  return resolvedBuildContext;
2605
2702
  };
2606
- var getServerBuildDirectory = (reactRouterConfig, { serverBundleId } = {}) => path5.join(
2703
+ var getServerBuildDirectory = (reactRouterConfig, { serverBundleId } = {}) => path6.join(
2607
2704
  reactRouterConfig.buildDirectory,
2608
2705
  "server",
2609
2706
  ...serverBundleId ? [serverBundleId] : []
2610
2707
  );
2611
- var getClientBuildDirectory = (reactRouterConfig) => path5.join(reactRouterConfig.buildDirectory, "client");
2708
+ var getClientBuildDirectory = (reactRouterConfig) => path6.join(reactRouterConfig.buildDirectory, "client");
2612
2709
  var getServerBundleRouteIds = (vitePluginContext, ctx) => {
2613
2710
  if (!ctx.buildManifest) {
2614
2711
  return void 0;
@@ -2626,14 +2723,14 @@ var getServerBundleRouteIds = (vitePluginContext, ctx) => {
2626
2723
  );
2627
2724
  return Object.keys(serverBundleRoutes);
2628
2725
  };
2629
- var defaultEntriesDir = path5.resolve(
2630
- path5.dirname(require.resolve("@react-router/dev/package.json")),
2726
+ var defaultEntriesDir = path6.resolve(
2727
+ path6.dirname(require.resolve("@react-router/dev/package.json")),
2631
2728
  "dist",
2632
2729
  "config",
2633
2730
  "defaults"
2634
2731
  );
2635
2732
  var defaultEntries = (0, import_node_fs2.readdirSync)(defaultEntriesDir).map(
2636
- (filename2) => path5.join(defaultEntriesDir, filename2)
2733
+ (filename2) => path6.join(defaultEntriesDir, filename2)
2637
2734
  );
2638
2735
  invariant(defaultEntries.length > 0, "No default entries found");
2639
2736
  var reactRouterDevLoadContext = () => void 0;
@@ -2671,7 +2768,7 @@ var reactRouterVitePlugin = () => {
2671
2768
  let publicPath = viteUserConfig.base ?? "/";
2672
2769
  if (reactRouterConfig.basename !== "/" && viteCommand === "serve" && !viteUserConfig.server?.middlewareMode && !reactRouterConfig.basename.startsWith(publicPath)) {
2673
2770
  logger.error(
2674
- import_picocolors3.default.red(
2771
+ import_picocolors4.default.red(
2675
2772
  "When using the React Router `basename` and the Vite `base` config, the `basename` config must begin with `base` for the default Vite dev server."
2676
2773
  )
2677
2774
  );
@@ -2729,7 +2826,7 @@ var reactRouterVitePlugin = () => {
2729
2826
  virtual.serverManifest.id
2730
2827
  )};
2731
2828
  export const assetsBuildDirectory = ${JSON.stringify(
2732
- path5.relative(
2829
+ path6.relative(
2733
2830
  ctx.rootDirectory,
2734
2831
  getClientBuildDirectory(ctx.reactRouterConfig)
2735
2832
  )
@@ -2768,18 +2865,11 @@ var reactRouterVitePlugin = () => {
2768
2865
  };
2769
2866
  let loadViteManifest = async (directory) => {
2770
2867
  let manifestContents = await (0, import_promises2.readFile)(
2771
- path5.resolve(directory, ".vite", "manifest.json"),
2868
+ path6.resolve(directory, ".vite", "manifest.json"),
2772
2869
  "utf-8"
2773
2870
  );
2774
2871
  return JSON.parse(manifestContents);
2775
2872
  };
2776
- let hasDependency = (name) => {
2777
- try {
2778
- return Boolean(require.resolve(name, { paths: [ctx.rootDirectory] }));
2779
- } catch (err2) {
2780
- return false;
2781
- }
2782
- };
2783
2873
  let getViteManifestAssetPaths = (viteManifest) => {
2784
2874
  let cssUrlPaths = Object.values(viteManifest).filter((chunk) => chunk.file.endsWith(".css")).map((chunk) => chunk.file);
2785
2875
  let chunkAssetPaths = Object.values(viteManifest).flatMap(
@@ -2800,7 +2890,7 @@ var reactRouterVitePlugin = () => {
2800
2890
  let contents;
2801
2891
  try {
2802
2892
  contents = await (0, import_promises2.readFile)(
2803
- path5.join(entryNormalizedPath, entry.name),
2893
+ path6.join(entryNormalizedPath, entry.name),
2804
2894
  "utf-8"
2805
2895
  );
2806
2896
  } catch (e) {
@@ -2809,9 +2899,9 @@ var reactRouterVitePlugin = () => {
2809
2899
  }
2810
2900
  let hash = (0, import_node_crypto.createHash)("sha384").update(contents).digest().toString("base64");
2811
2901
  let filepath = getVite().normalizePath(
2812
- path5.relative(
2902
+ path6.relative(
2813
2903
  clientBuildDirectory,
2814
- path5.join(entryNormalizedPath, entry.name)
2904
+ path6.join(entryNormalizedPath, entry.name)
2815
2905
  )
2816
2906
  );
2817
2907
  sriManifest[`${ctx2.publicPath}${filepath}`] = `sha384-${hash}`;
@@ -2842,7 +2932,7 @@ var reactRouterVitePlugin = () => {
2842
2932
  );
2843
2933
  let enforceSplitRouteModules = ctx.reactRouterConfig.future.unstable_splitRouteModules === "enforce";
2844
2934
  for (let route of Object.values(ctx.reactRouterConfig.routes)) {
2845
- let routeFile = path5.join(ctx.reactRouterConfig.appDirectory, route.file);
2935
+ let routeFile = path6.join(ctx.reactRouterConfig.appDirectory, route.file);
2846
2936
  let sourceExports = routeManifestExports[route.id];
2847
2937
  let hasClientAction = sourceExports.includes("clientAction");
2848
2938
  let hasClientLoader = sourceExports.includes("clientLoader");
@@ -2913,7 +3003,7 @@ var reactRouterVitePlugin = () => {
2913
3003
  }
2914
3004
  let fingerprintedValues = { entry, routes: browserRoutes };
2915
3005
  let version = getHash(JSON.stringify(fingerprintedValues), 8);
2916
- let manifestPath = path5.posix.join(
3006
+ let manifestPath = path6.posix.join(
2917
3007
  viteConfig2.build.assetsDir,
2918
3008
  `manifest-${version}.js`
2919
3009
  );
@@ -2925,7 +3015,7 @@ var reactRouterVitePlugin = () => {
2925
3015
  sri: void 0
2926
3016
  };
2927
3017
  await writeFileSafe(
2928
- path5.join(getClientBuildDirectory(ctx.reactRouterConfig), manifestPath),
3018
+ path6.join(getClientBuildDirectory(ctx.reactRouterConfig), manifestPath),
2929
3019
  `window.__reactRouterManifest=${JSON.stringify(
2930
3020
  reactRouterBrowserManifest
2931
3021
  )};`
@@ -3051,7 +3141,6 @@ var reactRouterVitePlugin = () => {
3051
3141
  config: async (_viteUserConfig, _viteConfigEnv) => {
3052
3142
  await preloadVite();
3053
3143
  let vite2 = getVite();
3054
- let viteMajorVersion = parseInt(vite2.version.split(".")[0], 10);
3055
3144
  viteUserConfig = _viteUserConfig;
3056
3145
  viteConfigEnv = _viteConfigEnv;
3057
3146
  viteCommand = viteConfigEnv.command;
@@ -3066,6 +3155,7 @@ var reactRouterVitePlugin = () => {
3066
3155
  if (viteCommand === "serve") {
3067
3156
  typegenWatcherPromise = watch(rootDirectory, {
3068
3157
  mode,
3158
+ rsc: false,
3069
3159
  // ignore `info` logs from typegen since they are redundant when Vite plugin logs are active
3070
3160
  logger: vite2.createLogger("warn", { prefix: "[react-router]" })
3071
3161
  });
@@ -3105,18 +3195,10 @@ var reactRouterVitePlugin = () => {
3105
3195
  resolve: serverEnvironment.resolve
3106
3196
  },
3107
3197
  optimizeDeps: {
3108
- entries: ctx.reactRouterConfig.future.unstable_optimizeDeps ? [
3109
- vite2.normalizePath(ctx.entryClientFilePath),
3110
- ...Object.values(ctx.reactRouterConfig.routes).map(
3111
- (route) => resolveRelativeRouteFilePath(route, ctx.reactRouterConfig)
3112
- )
3113
- ].map(
3114
- (entry) => (
3115
- // In Vite 7, the `optimizeDeps.entries` option only accepts glob patterns.
3116
- // In prior versions, absolute file paths were treated differently.
3117
- viteMajorVersion >= 7 ? (0, import_tinyglobby.escapePath)(entry) : entry
3118
- )
3119
- ) : [],
3198
+ entries: getOptimizeDepsEntries({
3199
+ entryClientFilePath: ctx.entryClientFilePath,
3200
+ reactRouterConfig: ctx.reactRouterConfig
3201
+ }),
3120
3202
  include: [
3121
3203
  // Pre-bundle React dependencies to avoid React duplicates,
3122
3204
  // even if React dependencies are not direct dependencies.
@@ -3131,7 +3213,10 @@ var reactRouterVitePlugin = () => {
3131
3213
  "react-router",
3132
3214
  "react-router/dom",
3133
3215
  // Check to avoid "Failed to resolve dependency: react-router-dom, present in 'optimizeDeps.include'"
3134
- ...hasDependency("react-router-dom") ? ["react-router-dom"] : []
3216
+ ...hasDependency({
3217
+ name: "react-router-dom",
3218
+ rootDirectory: ctx.rootDirectory
3219
+ }) ? ["react-router-dom"] : []
3135
3220
  ]
3136
3221
  },
3137
3222
  esbuild: {
@@ -3283,23 +3368,6 @@ var reactRouterVitePlugin = () => {
3283
3368
  cssModulesManifest[id] = code;
3284
3369
  }
3285
3370
  },
3286
- buildStart() {
3287
- invariant(viteConfig);
3288
- if (viteCommand === "build" && viteConfig.mode === "production" && !viteConfig.build.ssr && viteConfig.build.sourcemap) {
3289
- viteConfig.logger.warn(
3290
- import_picocolors3.default.yellow(
3291
- "\n" + import_picocolors3.default.bold(" \u26A0\uFE0F Source maps are enabled in production\n") + [
3292
- "This makes your server code publicly",
3293
- "visible in the browser. This is highly",
3294
- "discouraged! If you insist, ensure that",
3295
- "you are using environment variables for",
3296
- "secrets and not hard-coding them in",
3297
- "your source code."
3298
- ].map((line) => " " + line).join("\n") + "\n"
3299
- )
3300
- );
3301
- }
3302
- },
3303
3371
  async configureServer(viteDevServer) {
3304
3372
  (0, import_react_router2.unstable_setDevServerHooks)({
3305
3373
  // Give the request handler access to the critical CSS in dev to avoid a
@@ -3339,7 +3407,7 @@ var reactRouterVitePlugin = () => {
3339
3407
  return;
3340
3408
  }
3341
3409
  let message = configChanged ? "Config changed." : routeConfigChanged ? "Route config changed." : configCodeChanged ? "Config saved." : routeConfigCodeChanged ? " Route config saved." : "Config saved";
3342
- logger.info(import_picocolors3.default.green(message), {
3410
+ logger.info(import_picocolors4.default.green(message), {
3343
3411
  clear: true,
3344
3412
  timestamp: true
3345
3413
  });
@@ -3429,11 +3497,11 @@ var reactRouterVitePlugin = () => {
3429
3497
  let removedAssetPaths = [];
3430
3498
  let copiedAssetPaths = [];
3431
3499
  for (let ssrAssetPath of ssrAssetPaths) {
3432
- let src = path5.join(serverBuildDirectory, ssrAssetPath);
3433
- let dest = path5.join(clientBuildDirectory, ssrAssetPath);
3500
+ let src = path6.join(serverBuildDirectory, ssrAssetPath);
3501
+ let dest = path6.join(clientBuildDirectory, ssrAssetPath);
3434
3502
  if (!userSsrEmitAssets) {
3435
3503
  if (!(0, import_node_fs2.existsSync)(dest)) {
3436
- await (0, import_promises2.mkdir)(path5.dirname(dest), { recursive: true });
3504
+ await (0, import_promises2.mkdir)(path6.dirname(dest), { recursive: true });
3437
3505
  await (0, import_promises2.rename)(src, dest);
3438
3506
  movedAssetPaths.push(dest);
3439
3507
  } else {
@@ -3451,7 +3519,7 @@ var reactRouterVitePlugin = () => {
3451
3519
  );
3452
3520
  await Promise.all(
3453
3521
  ssrCssPaths.map(async (cssPath) => {
3454
- let src = path5.join(serverBuildDirectory, cssPath);
3522
+ let src = path6.join(serverBuildDirectory, cssPath);
3455
3523
  await (0, import_promises2.rm)(src, { force: true, recursive: true });
3456
3524
  removedAssetPaths.push(src);
3457
3525
  })
@@ -3459,7 +3527,7 @@ var reactRouterVitePlugin = () => {
3459
3527
  }
3460
3528
  let cleanedAssetPaths = [...removedAssetPaths, ...movedAssetPaths];
3461
3529
  let handledAssetPaths = [...cleanedAssetPaths, ...copiedAssetPaths];
3462
- let cleanedAssetDirs = new Set(cleanedAssetPaths.map(path5.dirname));
3530
+ let cleanedAssetDirs = new Set(cleanedAssetPaths.map(path6.dirname));
3463
3531
  await Promise.all(
3464
3532
  Array.from(cleanedAssetDirs).map(async (dir) => {
3465
3533
  try {
@@ -3479,9 +3547,9 @@ var reactRouterVitePlugin = () => {
3479
3547
  if (paths.length) {
3480
3548
  viteConfig.logger.info(
3481
3549
  [
3482
- `${import_picocolors3.default.green("\u2713")} ${message}`,
3550
+ `${import_picocolors4.default.green("\u2713")} ${message}`,
3483
3551
  ...paths.map(
3484
- (assetPath) => import_picocolors3.default.dim(path5.relative(ctx.rootDirectory, assetPath))
3552
+ (assetPath) => import_picocolors4.default.dim(path6.relative(ctx.rootDirectory, assetPath))
3485
3553
  )
3486
3554
  ].join("\n")
3487
3555
  );
@@ -3525,7 +3593,7 @@ var reactRouterVitePlugin = () => {
3525
3593
  viteConfig.logger.info(
3526
3594
  [
3527
3595
  "Removing the server build in",
3528
- import_picocolors3.default.green(serverBuildDirectory),
3596
+ import_picocolors4.default.green(serverBuildDirectory),
3529
3597
  "due to ssr:false"
3530
3598
  ].join(" ")
3531
3599
  );
@@ -3575,7 +3643,7 @@ var reactRouterVitePlugin = () => {
3575
3643
  );
3576
3644
  let isMainChunkExport = (name) => !chunkedExports.includes(name);
3577
3645
  let mainChunkReexports = sourceExports.filter(isMainChunkExport).join(", ");
3578
- let chunkBasePath = `./${path5.basename(id)}`;
3646
+ let chunkBasePath = `./${path6.basename(id)}`;
3579
3647
  return [
3580
3648
  `export { ${mainChunkReexports} } from "${getRouteChunkModuleId(
3581
3649
  chunkBasePath,
@@ -3595,7 +3663,7 @@ var reactRouterVitePlugin = () => {
3595
3663
  async transform(code, id, options) {
3596
3664
  if (!id.endsWith(BUILD_CLIENT_ROUTE_QUERY_STRING)) return;
3597
3665
  let routeModuleId = id.replace(BUILD_CLIENT_ROUTE_QUERY_STRING, "");
3598
- let routeFileName = path5.basename(routeModuleId);
3666
+ let routeFileName = path6.basename(routeModuleId);
3599
3667
  let sourceExports = await getRouteModuleExports(
3600
3668
  viteChildCompiler,
3601
3669
  ctx,
@@ -3722,7 +3790,7 @@ var reactRouterVitePlugin = () => {
3722
3790
  }
3723
3791
  let vite2 = getVite();
3724
3792
  let importerShort = vite2.normalizePath(
3725
- path5.relative(ctx.rootDirectory, importer)
3793
+ path6.relative(ctx.rootDirectory, importer)
3726
3794
  );
3727
3795
  if (isRoute(ctx.reactRouterConfig, importer)) {
3728
3796
  let serverOnlyExports = SERVER_ONLY_ROUTE_EXPORTS.map(
@@ -3730,7 +3798,7 @@ var reactRouterVitePlugin = () => {
3730
3798
  ).join(", ");
3731
3799
  throw Error(
3732
3800
  [
3733
- import_picocolors3.default.red(`Server-only module referenced by client`),
3801
+ import_picocolors4.default.red(`Server-only module referenced by client`),
3734
3802
  "",
3735
3803
  ` '${id}' imported by route '${importerShort}'`,
3736
3804
  "",
@@ -3746,7 +3814,7 @@ var reactRouterVitePlugin = () => {
3746
3814
  }
3747
3815
  throw Error(
3748
3816
  [
3749
- import_picocolors3.default.red(`Server-only module referenced by client`),
3817
+ import_picocolors4.default.red(`Server-only module referenced by client`),
3750
3818
  "",
3751
3819
  ` '${id}' imported by '${importerShort}'`,
3752
3820
  "",
@@ -3844,10 +3912,10 @@ var reactRouterVitePlugin = () => {
3844
3912
  },
3845
3913
  async load(id) {
3846
3914
  if (id !== virtualHmrRuntime.resolvedId) return;
3847
- let reactRefreshDir = path5.dirname(
3915
+ let reactRefreshDir = path6.dirname(
3848
3916
  require.resolve("react-refresh/package.json")
3849
3917
  );
3850
- let reactRefreshRuntimePath = path5.join(
3918
+ let reactRefreshRuntimePath = path6.join(
3851
3919
  reactRefreshDir,
3852
3920
  "cjs/react-refresh-runtime.development.js"
3853
3921
  );
@@ -3956,7 +4024,8 @@ var reactRouterVitePlugin = () => {
3956
4024
  }
3957
4025
  }
3958
4026
  },
3959
- validatePluginOrder()
4027
+ validatePluginOrder(),
4028
+ warnOnClientSourceMaps()
3960
4029
  ];
3961
4030
  };
3962
4031
  function getParentClientNodes(clientModuleGraph, module2) {
@@ -4026,7 +4095,7 @@ if (import.meta.hot && !inWebWorker) {
4026
4095
  function getRoute(pluginConfig, file) {
4027
4096
  let vite2 = getVite();
4028
4097
  let routePath = vite2.normalizePath(
4029
- path5.relative(pluginConfig.appDirectory, file)
4098
+ path6.relative(pluginConfig.appDirectory, file)
4030
4099
  );
4031
4100
  let route = Object.values(pluginConfig.routes).find(
4032
4101
  (r) => vite2.normalizePath(r.file) === routePath
@@ -4065,7 +4134,7 @@ async function getRouteMetadata(cache, ctx, viteChildCompiler, route, readRouteF
4065
4134
  caseSensitive: route.caseSensitive,
4066
4135
  url: combineURLs(
4067
4136
  ctx.publicPath,
4068
- "/" + path5.relative(
4137
+ "/" + path6.relative(
4069
4138
  ctx.rootDirectory,
4070
4139
  resolveRelativeRouteFilePath(route, ctx.reactRouterConfig)
4071
4140
  )
@@ -4093,7 +4162,7 @@ function isSpaModeEnabled(reactRouterConfig) {
4093
4162
  return reactRouterConfig.ssr === false && !isPrerenderingEnabled(reactRouterConfig);
4094
4163
  }
4095
4164
  async function getPrerenderBuildAndHandler(viteConfig, serverBuildDirectory, serverBuildFile) {
4096
- let serverBuildPath = path5.join(serverBuildDirectory, serverBuildFile);
4165
+ let serverBuildPath = path6.join(serverBuildDirectory, serverBuildFile);
4097
4166
  let build = await import(url.pathToFileURL(serverBuildPath).toString());
4098
4167
  let { createRequestHandler: createHandler } = await import("react-router");
4099
4168
  return {
@@ -4135,15 +4204,15 @@ async function handleSpaMode(viteConfig, reactRouterConfig, serverBuildDirectory
4135
4204
  "SPA Mode: Did you forget to include `<Scripts/>` in your root route? Your pre-rendered HTML cannot hydrate without `<Scripts />`."
4136
4205
  );
4137
4206
  }
4138
- await (0, import_promises2.writeFile)(path5.join(clientBuildDirectory, filename2), html);
4139
- let prettyDir = path5.relative(viteConfig.root, clientBuildDirectory);
4140
- let prettyPath = path5.join(prettyDir, filename2);
4207
+ await (0, import_promises2.writeFile)(path6.join(clientBuildDirectory, filename2), html);
4208
+ let prettyDir = path6.relative(viteConfig.root, clientBuildDirectory);
4209
+ let prettyPath = path6.join(prettyDir, filename2);
4141
4210
  if (build.prerender.length > 0) {
4142
4211
  viteConfig.logger.info(
4143
- `Prerender (html): SPA Fallback -> ${import_picocolors3.default.bold(prettyPath)}`
4212
+ `Prerender (html): SPA Fallback -> ${import_picocolors4.default.bold(prettyPath)}`
4144
4213
  );
4145
4214
  } else {
4146
- viteConfig.logger.info(`SPA Mode: Generated ${import_picocolors3.default.bold(prettyPath)}`);
4215
+ viteConfig.logger.info(`SPA Mode: Generated ${import_picocolors4.default.bold(prettyPath)}`);
4147
4216
  }
4148
4217
  }
4149
4218
  async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirectory, serverBuildPath, clientBuildDirectory) {
@@ -4153,17 +4222,17 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
4153
4222
  serverBuildPath
4154
4223
  );
4155
4224
  let routes = createPrerenderRoutes(reactRouterConfig.routes);
4156
- for (let path6 of build.prerender) {
4157
- let matches = (0, import_react_router2.matchRoutes)(routes, `/${path6}/`.replace(/^\/\/+/, "/"));
4225
+ for (let path7 of build.prerender) {
4226
+ let matches = (0, import_react_router2.matchRoutes)(routes, `/${path7}/`.replace(/^\/\/+/, "/"));
4158
4227
  if (!matches) {
4159
4228
  throw new Error(
4160
- `Unable to prerender path because it does not match any routes: ${path6}`
4229
+ `Unable to prerender path because it does not match any routes: ${path7}`
4161
4230
  );
4162
4231
  }
4163
4232
  }
4164
4233
  let buildRoutes = createPrerenderRoutes(build.routes);
4165
- for (let path6 of build.prerender) {
4166
- let matches = (0, import_react_router2.matchRoutes)(buildRoutes, `/${path6}/`.replace(/^\/\/+/, "/"));
4234
+ for (let path7 of build.prerender) {
4235
+ let matches = (0, import_react_router2.matchRoutes)(buildRoutes, `/${path7}/`.replace(/^\/\/+/, "/"));
4167
4236
  if (!matches) {
4168
4237
  continue;
4169
4238
  }
@@ -4176,7 +4245,7 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
4176
4245
  if (manifestRoute.loader) {
4177
4246
  await prerenderData(
4178
4247
  handler,
4179
- path6,
4248
+ path7,
4180
4249
  [leafRoute.id],
4181
4250
  clientBuildDirectory,
4182
4251
  reactRouterConfig,
@@ -4184,7 +4253,7 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
4184
4253
  );
4185
4254
  await prerenderResourceRoute(
4186
4255
  handler,
4187
- path6,
4256
+ path7,
4188
4257
  clientBuildDirectory,
4189
4258
  reactRouterConfig,
4190
4259
  viteConfig
@@ -4202,7 +4271,7 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
4202
4271
  if (!isResourceRoute && hasLoaders) {
4203
4272
  data = await prerenderData(
4204
4273
  handler,
4205
- path6,
4274
+ path7,
4206
4275
  null,
4207
4276
  clientBuildDirectory,
4208
4277
  reactRouterConfig,
@@ -4211,7 +4280,7 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
4211
4280
  }
4212
4281
  await prerenderRoute(
4213
4282
  handler,
4214
- path6,
4283
+ path7,
4215
4284
  clientBuildDirectory,
4216
4285
  reactRouterConfig,
4217
4286
  viteConfig,
@@ -4264,12 +4333,12 @@ async function prerenderData(handler, prerenderPath, onlyRoutes, clientBuildDire
4264
4333
  ${normalizedPath}`
4265
4334
  );
4266
4335
  }
4267
- let outfile = path5.join(clientBuildDirectory, ...normalizedPath.split("/"));
4268
- await (0, import_promises2.mkdir)(path5.dirname(outfile), { recursive: true });
4336
+ let outfile = path6.join(clientBuildDirectory, ...normalizedPath.split("/"));
4337
+ await (0, import_promises2.mkdir)(path6.dirname(outfile), { recursive: true });
4269
4338
  await (0, import_promises2.writeFile)(outfile, data);
4270
4339
  viteConfig.logger.info(
4271
- `Prerender (data): ${prerenderPath} -> ${import_picocolors3.default.bold(
4272
- path5.relative(viteConfig.root, outfile)
4340
+ `Prerender (data): ${prerenderPath} -> ${import_picocolors4.default.bold(
4341
+ path6.relative(viteConfig.root, outfile)
4273
4342
  )}`
4274
4343
  );
4275
4344
  return data;
@@ -4304,16 +4373,16 @@ async function prerenderRoute(handler, prerenderPath, clientBuildDirectory, reac
4304
4373
  ${html}`
4305
4374
  );
4306
4375
  }
4307
- let outfile = path5.join(
4376
+ let outfile = path6.join(
4308
4377
  clientBuildDirectory,
4309
4378
  ...normalizedPath.split("/"),
4310
4379
  "index.html"
4311
4380
  );
4312
- await (0, import_promises2.mkdir)(path5.dirname(outfile), { recursive: true });
4381
+ await (0, import_promises2.mkdir)(path6.dirname(outfile), { recursive: true });
4313
4382
  await (0, import_promises2.writeFile)(outfile, html);
4314
4383
  viteConfig.logger.info(
4315
- `Prerender (html): ${prerenderPath} -> ${import_picocolors3.default.bold(
4316
- path5.relative(viteConfig.root, outfile)
4384
+ `Prerender (html): ${prerenderPath} -> ${import_picocolors4.default.bold(
4385
+ path6.relative(viteConfig.root, outfile)
4317
4386
  )}`
4318
4387
  );
4319
4388
  }
@@ -4328,12 +4397,12 @@ async function prerenderResourceRoute(handler, prerenderPath, clientBuildDirecto
4328
4397
  ${content.toString("utf8")}`
4329
4398
  );
4330
4399
  }
4331
- let outfile = path5.join(clientBuildDirectory, ...normalizedPath.split("/"));
4332
- await (0, import_promises2.mkdir)(path5.dirname(outfile), { recursive: true });
4400
+ let outfile = path6.join(clientBuildDirectory, ...normalizedPath.split("/"));
4401
+ await (0, import_promises2.mkdir)(path6.dirname(outfile), { recursive: true });
4333
4402
  await (0, import_promises2.writeFile)(outfile, content);
4334
4403
  viteConfig.logger.info(
4335
- `Prerender (resource): ${prerenderPath} -> ${import_picocolors3.default.bold(
4336
- path5.relative(viteConfig.root, outfile)
4404
+ `Prerender (resource): ${prerenderPath} -> ${import_picocolors4.default.bold(
4405
+ path6.relative(viteConfig.root, outfile)
4337
4406
  )}`
4338
4407
  );
4339
4408
  }
@@ -4345,7 +4414,7 @@ async function getPrerenderPaths(prerender, ssr, routes, logWarning = false) {
4345
4414
  let { paths, paramRoutes } = getStaticPrerenderPaths(prerenderRoutes);
4346
4415
  if (logWarning && !ssr && paramRoutes.length > 0) {
4347
4416
  console.warn(
4348
- import_picocolors3.default.yellow(
4417
+ import_picocolors4.default.yellow(
4349
4418
  [
4350
4419
  "\u26A0\uFE0F Paths with dynamic/splat params cannot be prerendered when using `prerender: true`. You may want to use the `prerender()` API to prerender the following paths:",
4351
4420
  ...paramRoutes.map((p) => " - " + p)
@@ -4407,14 +4476,14 @@ async function validateSsrFalsePrerenderExports(viteConfig, ctx, manifest, viteC
4407
4476
  }
4408
4477
  let prerenderRoutes = createPrerenderRoutes(manifest.routes);
4409
4478
  let prerenderedRoutes = /* @__PURE__ */ new Set();
4410
- for (let path6 of prerenderPaths) {
4479
+ for (let path7 of prerenderPaths) {
4411
4480
  let matches = (0, import_react_router2.matchRoutes)(
4412
4481
  prerenderRoutes,
4413
- `/${path6}/`.replace(/^\/\/+/, "/")
4482
+ `/${path7}/`.replace(/^\/\/+/, "/")
4414
4483
  );
4415
4484
  invariant(
4416
4485
  matches,
4417
- `Unable to prerender path because it does not match any routes: ${path6}`
4486
+ `Unable to prerender path because it does not match any routes: ${path7}`
4418
4487
  );
4419
4488
  matches.forEach((m) => prerenderedRoutes.add(m.route.id));
4420
4489
  }
@@ -4452,7 +4521,7 @@ async function validateSsrFalsePrerenderExports(viteConfig, ctx, manifest, viteC
4452
4521
  }
4453
4522
  }
4454
4523
  if (errors.length > 0) {
4455
- viteConfig.logger.error(import_picocolors3.default.red(errors.join("\n")));
4524
+ viteConfig.logger.error(import_picocolors4.default.red(errors.join("\n")));
4456
4525
  throw new Error(
4457
4526
  "Invalid route exports found when prerendering with `ssr:false`"
4458
4527
  );
@@ -4581,8 +4650,8 @@ function validateRouteChunks({
4581
4650
  async function cleanBuildDirectory(viteConfig, ctx) {
4582
4651
  let buildDirectory = ctx.reactRouterConfig.buildDirectory;
4583
4652
  let isWithinRoot = () => {
4584
- let relativePath = path5.relative(ctx.rootDirectory, buildDirectory);
4585
- return !relativePath.startsWith("..") && !path5.isAbsolute(relativePath);
4653
+ let relativePath = path6.relative(ctx.rootDirectory, buildDirectory);
4654
+ return !relativePath.startsWith("..") && !path6.isAbsolute(relativePath);
4586
4655
  };
4587
4656
  if (viteConfig.build.emptyOutDir ?? isWithinRoot()) {
4588
4657
  await (0, import_promises2.rm)(buildDirectory, { force: true, recursive: true });
@@ -4593,7 +4662,7 @@ async function cleanViteManifests(environmentsOptions, ctx) {
4593
4662
  ([environmentName, options]) => {
4594
4663
  let outDir = options.build?.outDir;
4595
4664
  invariant(outDir, `Expected build.outDir for ${environmentName}`);
4596
- return path5.join(outDir, ".vite/manifest.json");
4665
+ return path6.join(outDir, ".vite/manifest.json");
4597
4666
  }
4598
4667
  );
4599
4668
  await Promise.all(
@@ -4603,7 +4672,7 @@ async function cleanViteManifests(environmentsOptions, ctx) {
4603
4672
  if (!ctx.viteManifestEnabled) {
4604
4673
  await (0, import_promises2.rm)(viteManifestPath, { force: true, recursive: true });
4605
4674
  }
4606
- let viteDir = path5.dirname(viteManifestPath);
4675
+ let viteDir = path6.dirname(viteManifestPath);
4607
4676
  let viteDirFiles = await (0, import_promises2.readdir)(viteDir, { recursive: true });
4608
4677
  if (viteDirFiles.length === 0) {
4609
4678
  await (0, import_promises2.rm)(viteDir, { force: true, recursive: true });
@@ -4621,12 +4690,12 @@ async function getBuildManifest({
4621
4690
  }
4622
4691
  let { normalizePath } = await import("vite");
4623
4692
  let serverBuildDirectory = getServerBuildDirectory(reactRouterConfig);
4624
- let resolvedAppDirectory = path5.resolve(rootDirectory, appDirectory);
4693
+ let resolvedAppDirectory = path6.resolve(rootDirectory, appDirectory);
4625
4694
  let rootRelativeRoutes = Object.fromEntries(
4626
4695
  Object.entries(routes).map(([id, route]) => {
4627
- let filePath = path5.join(resolvedAppDirectory, route.file);
4696
+ let filePath = path6.join(resolvedAppDirectory, route.file);
4628
4697
  let rootRelativeFilePath = normalizePath(
4629
- path5.relative(rootDirectory, filePath)
4698
+ path6.relative(rootDirectory, filePath)
4630
4699
  );
4631
4700
  return [id, { ...route, file: rootRelativeFilePath }];
4632
4701
  })
@@ -4644,7 +4713,7 @@ async function getBuildManifest({
4644
4713
  (route2) => configRouteToBranchRoute({
4645
4714
  ...route2,
4646
4715
  // Ensure absolute paths are passed to the serverBundles function
4647
- file: path5.join(resolvedAppDirectory, route2.file)
4716
+ file: path6.join(resolvedAppDirectory, route2.file)
4648
4717
  })
4649
4718
  )
4650
4719
  });
@@ -4668,10 +4737,10 @@ async function getBuildManifest({
4668
4737
  buildManifest.serverBundles[serverBundleId] ??= {
4669
4738
  id: serverBundleId,
4670
4739
  file: normalizePath(
4671
- path5.join(
4672
- path5.relative(
4740
+ path6.join(
4741
+ path6.relative(
4673
4742
  rootDirectory,
4674
- path5.join(serverBuildDirectory, serverBundleId)
4743
+ path6.join(serverBuildDirectory, serverBundleId)
4675
4744
  ),
4676
4745
  reactRouterConfig.serverBuildFile
4677
4746
  )
@@ -4690,10 +4759,10 @@ function mergeEnvironmentOptions(base, ...overrides) {
4690
4759
  }
4691
4760
  async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
4692
4761
  let { serverBuildFile, serverModuleFormat } = ctx.reactRouterConfig;
4693
- let packageRoot = path5.dirname(
4762
+ let packageRoot = path6.dirname(
4694
4763
  require.resolve("@react-router/dev/package.json")
4695
4764
  );
4696
- let { moduleSyncEnabled } = await import(`file:///${path5.join(packageRoot, "module-sync-enabled/index.mjs")}`);
4765
+ let { moduleSyncEnabled } = await import(`file:///${path6.join(packageRoot, "module-sync-enabled/index.mjs")}`);
4697
4766
  let vite2 = getVite();
4698
4767
  function getBaseOptions({
4699
4768
  viteUserConfig
@@ -4772,7 +4841,7 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
4772
4841
  ctx.entryClientFilePath,
4773
4842
  ...Object.values(ctx.reactRouterConfig.routes).flatMap(
4774
4843
  (route) => {
4775
- let routeFilePath = path5.resolve(
4844
+ let routeFilePath = path6.resolve(
4776
4845
  ctx.reactRouterConfig.appDirectory,
4777
4846
  route.file
4778
4847
  );
@@ -4796,7 +4865,7 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
4796
4865
  ) : null;
4797
4866
  let routeChunkSuffix = routeChunkName ? `-${(0, import_kebabCase.default)(routeChunkName)}` : "";
4798
4867
  let assetsDir = (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi ? viteUserConfig?.environments?.client?.build?.assetsDir : null) ?? viteUserConfig?.build?.assetsDir ?? "assets";
4799
- return path5.posix.join(
4868
+ return path6.posix.join(
4800
4869
  assetsDir,
4801
4870
  `[name]${routeChunkSuffix}-[hash].js`
4802
4871
  );