@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/vite.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
  *
@@ -48,11 +48,12 @@ 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 path6 = __toESM(require("path"));
51
+ var path5 = __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");
56
57
  var import_pick3 = __toESM(require("lodash/pick"));
57
58
  var import_jsesc = __toESM(require("jsesc"));
58
59
  var import_picocolors3 = __toESM(require("picocolors"));
@@ -246,7 +247,7 @@ function validateRouteConfig({
246
247
  `Route config in "${routeConfigFile}" is invalid.`,
247
248
  root ? `${root}` : [],
248
249
  nested ? Object.entries(nested).map(
249
- ([path7, message]) => `Path: routes.${path7}
250
+ ([path6, message]) => `Path: routes.${path6}
250
251
  ${message}`
251
252
  ) : []
252
253
  ].flat().join("\n\n")
@@ -366,8 +367,7 @@ async function resolveConfig({
366
367
  root,
367
368
  viteNodeContext,
368
369
  reactRouterConfigFile,
369
- skipRoutes,
370
- validateConfig
370
+ skipRoutes
371
371
  }) {
372
372
  let reactRouterUserConfig = {};
373
373
  if (reactRouterConfigFile) {
@@ -385,12 +385,6 @@ 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
- }
394
388
  } catch (error) {
395
389
  return err(`Error loading ${reactRouterConfigFile}: ${error}`);
396
390
  }
@@ -539,7 +533,7 @@ async function resolveConfig({
539
533
  }
540
534
  }
541
535
  let future = {
542
- v8_middleware: reactRouterUserConfig.future?.v8_middleware ?? false,
536
+ unstable_middleware: reactRouterUserConfig.future?.unstable_middleware ?? false,
543
537
  unstable_optimizeDeps: reactRouterUserConfig.future?.unstable_optimizeDeps ?? false,
544
538
  unstable_splitRouteModules: reactRouterUserConfig.future?.unstable_splitRouteModules ?? false,
545
539
  unstable_subResourceIntegrity: reactRouterUserConfig.future?.unstable_subResourceIntegrity ?? false,
@@ -569,8 +563,7 @@ async function createConfigLoader({
569
563
  rootDirectory: root,
570
564
  watch: watch2,
571
565
  mode,
572
- skipRoutes,
573
- validateConfig
566
+ skipRoutes
574
567
  }) {
575
568
  root = import_pathe3.default.normalize(root ?? process.env.REACT_ROUTER_ROOT ?? process.cwd());
576
569
  let vite2 = await import("vite");
@@ -589,13 +582,7 @@ async function createConfigLoader({
589
582
  });
590
583
  };
591
584
  updateReactRouterConfigFile();
592
- let getConfig = () => resolveConfig({
593
- root,
594
- viteNodeContext,
595
- reactRouterConfigFile,
596
- skipRoutes,
597
- validateConfig
598
- });
585
+ let getConfig = () => resolveConfig({ root, viteNodeContext, reactRouterConfigFile, skipRoutes });
599
586
  let appDirectory;
600
587
  let initialConfigResult = await getConfig();
601
588
  if (!initialConfigResult.ok) {
@@ -617,11 +604,11 @@ async function createConfigLoader({
617
604
  if (!fsWatcher) {
618
605
  fsWatcher = import_chokidar.default.watch([root, appDirectory], {
619
606
  ignoreInitial: true,
620
- ignored: (path7) => {
621
- let dirname4 = import_pathe3.default.dirname(path7);
607
+ ignored: (path6) => {
608
+ let dirname4 = import_pathe3.default.dirname(path6);
622
609
  return !dirname4.startsWith(appDirectory) && // Ensure we're only watching files outside of the app directory
623
610
  // that are at the root level, not nested in subdirectories
624
- path7 !== root && // Watch the root directory itself
611
+ path6 !== root && // Watch the root directory itself
625
612
  dirname4 !== root;
626
613
  }
627
614
  });
@@ -880,7 +867,7 @@ function fullpath(lineage2) {
880
867
  if (lineage2.length === 1 && route?.id === "root") return "/";
881
868
  const isLayout = route && route.index !== true && route.path === void 0;
882
869
  if (isLayout) return void 0;
883
- return "/" + lineage2.map((route2) => route2.path?.replace(/^\//, "")?.replace(/\/$/, "")).filter((path7) => path7 !== void 0 && path7 !== "").join("/");
870
+ return "/" + lineage2.map((route2) => route2.path?.replace(/^\//, "")?.replace(/\/$/, "")).filter((path6) => path6 !== void 0 && path6 !== "").join("/");
884
871
  }
885
872
 
886
873
  // typegen/generate.ts
@@ -896,7 +883,7 @@ function generateFuture(ctx) {
896
883
 
897
884
  declare module "react-router" {
898
885
  interface Future {
899
- middleware: ${ctx.config.future.v8_middleware}
886
+ unstable_middleware: ${ctx.config.future.unstable_middleware}
900
887
  }
901
888
  }
902
889
  `;
@@ -1036,8 +1023,8 @@ function routeFilesType({
1036
1023
  );
1037
1024
  }
1038
1025
  function isInAppDirectory(ctx, routeFile) {
1039
- const path7 = Path3.resolve(ctx.config.appDirectory, routeFile);
1040
- return path7.startsWith(ctx.config.appDirectory);
1026
+ const path6 = Path3.resolve(ctx.config.appDirectory, routeFile);
1027
+ return path6.startsWith(ctx.config.appDirectory);
1041
1028
  }
1042
1029
  function getRouteAnnotations({
1043
1030
  ctx,
@@ -1118,11 +1105,11 @@ function getRouteAnnotations({
1118
1105
  export type HeadersArgs = Annotations["HeadersArgs"];
1119
1106
  export type HeadersFunction = Annotations["HeadersFunction"];
1120
1107
 
1121
- // middleware
1122
- export type MiddlewareFunction = Annotations["MiddlewareFunction"];
1108
+ // unstable_middleware
1109
+ export type unstable_MiddlewareFunction = Annotations["unstable_MiddlewareFunction"];
1123
1110
 
1124
- // clientMiddleware
1125
- export type ClientMiddlewareFunction = Annotations["ClientMiddlewareFunction"];
1111
+ // unstable_clientMiddleware
1112
+ export type unstable_ClientMiddlewareFunction = Annotations["unstable_ClientMiddlewareFunction"];
1126
1113
 
1127
1114
  // loader
1128
1115
  export type LoaderArgs = Annotations["LoaderArgs"];
@@ -1149,21 +1136,21 @@ function getRouteAnnotations({
1149
1136
  return { filename: filename2, content };
1150
1137
  }
1151
1138
  function relativeImportSource(from, to) {
1152
- let path7 = Path3.relative(Path3.dirname(from), to);
1153
- let extension = Path3.extname(path7);
1154
- path7 = Path3.join(Path3.dirname(path7), Pathe.filename(path7));
1155
- if (!path7.startsWith("../")) path7 = "./" + path7;
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;
1156
1143
  if (!extension || /\.(js|ts)x?$/.test(extension)) {
1157
1144
  extension = ".js";
1158
1145
  }
1159
- return path7 + extension;
1146
+ return path6 + extension;
1160
1147
  }
1161
1148
  function rootDirsPath(ctx, typesPath) {
1162
1149
  const rel = Path3.relative(typesDirectory(ctx), typesPath);
1163
1150
  return Path3.join(ctx.rootDirectory, rel);
1164
1151
  }
1165
- function paramsType(path7) {
1166
- const params = parse2(path7);
1152
+ function paramsType(path6) {
1153
+ const params = parse2(path6);
1167
1154
  return t2.tsTypeLiteral(
1168
1155
  Object.entries(params).map(([param, isRequired]) => {
1169
1156
  const property = t2.tsPropertySignature(
@@ -1499,11 +1486,11 @@ var getCssStringFromViteDevModuleCode = (code) => {
1499
1486
  let cssContent = void 0;
1500
1487
  const ast = import_parser.parse(code, { sourceType: "module" });
1501
1488
  traverse(ast, {
1502
- VariableDeclaration(path7) {
1503
- const declaration = path7.node.declarations[0];
1489
+ VariableDeclaration(path6) {
1490
+ const declaration = path6.node.declarations[0];
1504
1491
  if (declaration?.id?.type === "Identifier" && declaration.id.name === "__vite__css" && declaration.init?.type === "StringLiteral") {
1505
1492
  cssContent = declaration.init.value;
1506
- path7.stop();
1493
+ path6.stop();
1507
1494
  }
1508
1495
  }
1509
1496
  });
@@ -1520,15 +1507,6 @@ function create(name) {
1520
1507
  };
1521
1508
  }
1522
1509
 
1523
- // vite/resolve-relative-route-file-path.ts
1524
- var import_pathe4 = __toESM(require("pathe"));
1525
- function resolveRelativeRouteFilePath(route, reactRouterConfig) {
1526
- let vite2 = getVite();
1527
- let file = route.file;
1528
- let fullPath = import_pathe4.default.resolve(reactRouterConfig.appDirectory, file);
1529
- return vite2.normalizePath(fullPath);
1530
- }
1531
-
1532
1510
  // vite/combine-urls.ts
1533
1511
  function combineURLs(baseURL, relativeURL) {
1534
1512
  return relativeURL ? baseURL.replace(/\/+$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
@@ -1542,10 +1520,10 @@ var removeExports = (ast, exportsToRemove) => {
1542
1520
  let markedForRemoval = /* @__PURE__ */ new Set();
1543
1521
  let removedExportLocalNames = /* @__PURE__ */ new Set();
1544
1522
  traverse(ast, {
1545
- ExportDeclaration(path7) {
1546
- if (path7.node.type === "ExportNamedDeclaration") {
1547
- if (path7.node.specifiers.length) {
1548
- path7.node.specifiers = path7.node.specifiers.filter((specifier) => {
1523
+ ExportDeclaration(path6) {
1524
+ if (path6.node.type === "ExportNamedDeclaration") {
1525
+ if (path6.node.specifiers.length) {
1526
+ path6.node.specifiers = path6.node.specifiers.filter((specifier) => {
1549
1527
  if (specifier.type === "ExportSpecifier" && specifier.exported.type === "Identifier") {
1550
1528
  if (exportsToRemove.includes(specifier.exported.name)) {
1551
1529
  exportsFiltered = true;
@@ -1557,12 +1535,12 @@ var removeExports = (ast, exportsToRemove) => {
1557
1535
  }
1558
1536
  return true;
1559
1537
  });
1560
- if (path7.node.specifiers.length === 0) {
1561
- markedForRemoval.add(path7);
1538
+ if (path6.node.specifiers.length === 0) {
1539
+ markedForRemoval.add(path6);
1562
1540
  }
1563
1541
  }
1564
- if (path7.node.declaration?.type === "VariableDeclaration") {
1565
- let declaration = path7.node.declaration;
1542
+ if (path6.node.declaration?.type === "VariableDeclaration") {
1543
+ let declaration = path6.node.declaration;
1566
1544
  declaration.declarations = declaration.declarations.filter(
1567
1545
  (declaration2) => {
1568
1546
  if (declaration2.id.type === "Identifier" && exportsToRemove.includes(declaration2.id.name)) {
@@ -1576,30 +1554,30 @@ var removeExports = (ast, exportsToRemove) => {
1576
1554
  }
1577
1555
  );
1578
1556
  if (declaration.declarations.length === 0) {
1579
- markedForRemoval.add(path7);
1557
+ markedForRemoval.add(path6);
1580
1558
  }
1581
1559
  }
1582
- if (path7.node.declaration?.type === "FunctionDeclaration") {
1583
- let id = path7.node.declaration.id;
1560
+ if (path6.node.declaration?.type === "FunctionDeclaration") {
1561
+ let id = path6.node.declaration.id;
1584
1562
  if (id && exportsToRemove.includes(id.name)) {
1585
- markedForRemoval.add(path7);
1563
+ markedForRemoval.add(path6);
1586
1564
  }
1587
1565
  }
1588
- if (path7.node.declaration?.type === "ClassDeclaration") {
1589
- let id = path7.node.declaration.id;
1566
+ if (path6.node.declaration?.type === "ClassDeclaration") {
1567
+ let id = path6.node.declaration.id;
1590
1568
  if (id && exportsToRemove.includes(id.name)) {
1591
- markedForRemoval.add(path7);
1569
+ markedForRemoval.add(path6);
1592
1570
  }
1593
1571
  }
1594
1572
  }
1595
- if (path7.node.type === "ExportDefaultDeclaration") {
1573
+ if (path6.node.type === "ExportDefaultDeclaration") {
1596
1574
  if (exportsToRemove.includes("default")) {
1597
- markedForRemoval.add(path7);
1598
- if (path7.node.declaration) {
1599
- if (path7.node.declaration.type === "Identifier") {
1600
- removedExportLocalNames.add(path7.node.declaration.name);
1601
- } else if ((path7.node.declaration.type === "FunctionDeclaration" || path7.node.declaration.type === "ClassDeclaration") && path7.node.declaration.id) {
1602
- removedExportLocalNames.add(path7.node.declaration.id.name);
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);
1603
1581
  }
1604
1582
  }
1605
1583
  }
@@ -1607,21 +1585,21 @@ var removeExports = (ast, exportsToRemove) => {
1607
1585
  }
1608
1586
  });
1609
1587
  traverse(ast, {
1610
- ExpressionStatement(path7) {
1611
- if (!path7.parentPath.isProgram()) {
1588
+ ExpressionStatement(path6) {
1589
+ if (!path6.parentPath.isProgram()) {
1612
1590
  return;
1613
1591
  }
1614
- if (path7.node.expression.type === "AssignmentExpression") {
1615
- const left = path7.node.expression.left;
1592
+ if (path6.node.expression.type === "AssignmentExpression") {
1593
+ const left = path6.node.expression.left;
1616
1594
  if (left.type === "MemberExpression" && left.object.type === "Identifier" && (exportsToRemove.includes(left.object.name) || removedExportLocalNames.has(left.object.name))) {
1617
- markedForRemoval.add(path7);
1595
+ markedForRemoval.add(path6);
1618
1596
  }
1619
1597
  }
1620
1598
  }
1621
1599
  });
1622
1600
  if (markedForRemoval.size > 0 || exportsFiltered) {
1623
- for (let path7 of markedForRemoval) {
1624
- path7.remove();
1601
+ for (let path6 of markedForRemoval) {
1602
+ path6.remove();
1625
1603
  }
1626
1604
  (0, import_babel_dead_code_elimination.deadCodeElimination)(ast, previouslyReferencedIdentifiers);
1627
1605
  }
@@ -1666,18 +1644,6 @@ function invalidDestructureError(name) {
1666
1644
  return new Error(`Cannot remove destructured export "${name}"`);
1667
1645
  }
1668
1646
 
1669
- // vite/has-dependency.ts
1670
- function hasDependency({
1671
- name,
1672
- rootDirectory
1673
- }) {
1674
- try {
1675
- return Boolean(require.resolve(name, { paths: [rootDirectory] }));
1676
- } catch (err2) {
1677
- return false;
1678
- }
1679
- }
1680
-
1681
1647
  // vite/cache.ts
1682
1648
  function getOrSetFromCache(cache, key, version, getValue) {
1683
1649
  if (!cache) {
@@ -1704,28 +1670,28 @@ function codeToAst(code, cache, cacheKey) {
1704
1670
  )
1705
1671
  );
1706
1672
  }
1707
- function assertNodePath(path7) {
1673
+ function assertNodePath(path6) {
1708
1674
  invariant(
1709
- path7 && !Array.isArray(path7),
1710
- `Expected a Path, but got ${Array.isArray(path7) ? "an array" : path7}`
1675
+ path6 && !Array.isArray(path6),
1676
+ `Expected a Path, but got ${Array.isArray(path6) ? "an array" : path6}`
1711
1677
  );
1712
1678
  }
1713
- function assertNodePathIsStatement(path7) {
1679
+ function assertNodePathIsStatement(path6) {
1714
1680
  invariant(
1715
- path7 && !Array.isArray(path7) && t.isStatement(path7.node),
1716
- `Expected a Statement path, but got ${Array.isArray(path7) ? "an array" : path7?.node?.type}`
1681
+ path6 && !Array.isArray(path6) && t.isStatement(path6.node),
1682
+ `Expected a Statement path, but got ${Array.isArray(path6) ? "an array" : path6?.node?.type}`
1717
1683
  );
1718
1684
  }
1719
- function assertNodePathIsVariableDeclarator(path7) {
1685
+ function assertNodePathIsVariableDeclarator(path6) {
1720
1686
  invariant(
1721
- path7 && !Array.isArray(path7) && t.isVariableDeclarator(path7.node),
1722
- `Expected an Identifier path, but got ${Array.isArray(path7) ? "an array" : path7?.node?.type}`
1687
+ path6 && !Array.isArray(path6) && t.isVariableDeclarator(path6.node),
1688
+ `Expected an Identifier path, but got ${Array.isArray(path6) ? "an array" : path6?.node?.type}`
1723
1689
  );
1724
1690
  }
1725
- function assertNodePathIsPattern(path7) {
1691
+ function assertNodePathIsPattern(path6) {
1726
1692
  invariant(
1727
- path7 && !Array.isArray(path7) && t.isPattern(path7.node),
1728
- `Expected a Pattern path, but got ${Array.isArray(path7) ? "an array" : path7?.node?.type}`
1693
+ path6 && !Array.isArray(path6) && t.isPattern(path6.node),
1694
+ `Expected a Pattern path, but got ${Array.isArray(path6) ? "an array" : path6?.node?.type}`
1729
1695
  );
1730
1696
  }
1731
1697
  function getExportDependencies(code, cache, cacheKey) {
@@ -1761,8 +1727,8 @@ function getExportDependencies(code, cache, cacheKey) {
1761
1727
  }
1762
1728
  let isWithinExportDestructuring = Boolean(
1763
1729
  identifier.findParent(
1764
- (path7) => Boolean(
1765
- path7.isPattern() && path7.parentPath?.isVariableDeclarator() && path7.parentPath.parentPath?.parentPath?.isExportNamedDeclaration()
1730
+ (path6) => Boolean(
1731
+ path6.isPattern() && path6.parentPath?.isVariableDeclarator() && path6.parentPath.parentPath?.parentPath?.isExportNamedDeclaration()
1766
1732
  )
1767
1733
  )
1768
1734
  );
@@ -1840,7 +1806,7 @@ function getExportDependencies(code, cache, cacheKey) {
1840
1806
  for (let specifier of node.specifiers) {
1841
1807
  if (t.isIdentifier(specifier.exported)) {
1842
1808
  let name = specifier.exported.name;
1843
- let specifierPath = exportPath.get("specifiers").find((path7) => path7.node === specifier);
1809
+ let specifierPath = exportPath.get("specifiers").find((path6) => path6.node === specifier);
1844
1810
  invariant(
1845
1811
  specifierPath,
1846
1812
  `Expected to find specifier path for ${name}`
@@ -1857,22 +1823,22 @@ function getExportDependencies(code, cache, cacheKey) {
1857
1823
  }
1858
1824
  );
1859
1825
  }
1860
- function getDependentIdentifiersForPath(path7, state) {
1826
+ function getDependentIdentifiersForPath(path6, state) {
1861
1827
  let { visited, identifiers } = state ?? {
1862
1828
  visited: /* @__PURE__ */ new Set(),
1863
1829
  identifiers: /* @__PURE__ */ new Set()
1864
1830
  };
1865
- if (visited.has(path7)) {
1831
+ if (visited.has(path6)) {
1866
1832
  return identifiers;
1867
1833
  }
1868
- visited.add(path7);
1869
- path7.traverse({
1870
- Identifier(path8) {
1871
- if (identifiers.has(path8)) {
1834
+ visited.add(path6);
1835
+ path6.traverse({
1836
+ Identifier(path7) {
1837
+ if (identifiers.has(path7)) {
1872
1838
  return;
1873
1839
  }
1874
- identifiers.add(path8);
1875
- let binding = path8.scope.getBinding(path8.node.name);
1840
+ identifiers.add(path7);
1841
+ let binding = path7.scope.getBinding(path7.node.name);
1876
1842
  if (!binding) {
1877
1843
  return;
1878
1844
  }
@@ -1894,7 +1860,7 @@ function getDependentIdentifiersForPath(path7, state) {
1894
1860
  }
1895
1861
  }
1896
1862
  });
1897
- let topLevelStatement = getTopLevelStatementPathForPath(path7);
1863
+ let topLevelStatement = getTopLevelStatementPathForPath(path6);
1898
1864
  let withinImportStatement = topLevelStatement.isImportDeclaration();
1899
1865
  let withinExportStatement = topLevelStatement.isExportDeclaration();
1900
1866
  if (!withinImportStatement && !withinExportStatement) {
@@ -1903,9 +1869,9 @@ function getDependentIdentifiersForPath(path7, state) {
1903
1869
  identifiers
1904
1870
  });
1905
1871
  }
1906
- if (withinExportStatement && path7.isIdentifier() && (t.isPattern(path7.parentPath.node) || // [foo]
1907
- t.isPattern(path7.parentPath.parentPath?.node))) {
1908
- let variableDeclarator = path7.findParent((p) => p.isVariableDeclarator());
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
1875
  assertNodePath(variableDeclarator);
1910
1876
  getDependentIdentifiersForPath(variableDeclarator, {
1911
1877
  visited,
@@ -1914,16 +1880,16 @@ function getDependentIdentifiersForPath(path7, state) {
1914
1880
  }
1915
1881
  return identifiers;
1916
1882
  }
1917
- function getTopLevelStatementPathForPath(path7) {
1918
- let ancestry = path7.getAncestry();
1883
+ function getTopLevelStatementPathForPath(path6) {
1884
+ let ancestry = path6.getAncestry();
1919
1885
  let topLevelStatement = ancestry[ancestry.length - 2];
1920
1886
  assertNodePathIsStatement(topLevelStatement);
1921
1887
  return topLevelStatement;
1922
1888
  }
1923
1889
  function getTopLevelStatementsForPaths(paths) {
1924
1890
  let topLevelStatements = /* @__PURE__ */ new Set();
1925
- for (let path7 of paths) {
1926
- let topLevelStatement = getTopLevelStatementPathForPath(path7);
1891
+ for (let path6 of paths) {
1892
+ let topLevelStatement = getTopLevelStatementPathForPath(path6);
1927
1893
  topLevelStatements.add(topLevelStatement.node);
1928
1894
  }
1929
1895
  return topLevelStatements;
@@ -2244,7 +2210,7 @@ function detectRouteChunks(code, cache, cacheKey) {
2244
2210
  var routeChunkExportNames = [
2245
2211
  "clientAction",
2246
2212
  "clientLoader",
2247
- "clientMiddleware",
2213
+ "unstable_clientMiddleware",
2248
2214
  "HydrateFallback"
2249
2215
  ];
2250
2216
  var mainChunkName = "main";
@@ -2260,7 +2226,7 @@ var routeChunkQueryStrings = {
2260
2226
  main: `${routeChunkQueryStringPrefix}main`,
2261
2227
  clientAction: `${routeChunkQueryStringPrefix}clientAction`,
2262
2228
  clientLoader: `${routeChunkQueryStringPrefix}clientLoader`,
2263
- clientMiddleware: `${routeChunkQueryStringPrefix}clientMiddleware`,
2229
+ unstable_clientMiddleware: `${routeChunkQueryStringPrefix}unstable_clientMiddleware`,
2264
2230
  HydrateFallback: `${routeChunkQueryStringPrefix}HydrateFallback`
2265
2231
  };
2266
2232
  function getRouteChunkModuleId(filePath, chunkName) {
@@ -2285,31 +2251,6 @@ function getRouteChunkNameFromModuleId(id) {
2285
2251
  return chunkName;
2286
2252
  }
2287
2253
 
2288
- // vite/optimize-deps-entries.ts
2289
- var import_tinyglobby = require("tinyglobby");
2290
- function getOptimizeDepsEntries({
2291
- entryClientFilePath,
2292
- reactRouterConfig
2293
- }) {
2294
- if (!reactRouterConfig.future.unstable_optimizeDeps) {
2295
- return [];
2296
- }
2297
- const vite2 = getVite();
2298
- const viteMajorVersion = parseInt(vite2.version.split(".")[0], 10);
2299
- return [
2300
- vite2.normalizePath(entryClientFilePath),
2301
- ...Object.values(reactRouterConfig.routes).map(
2302
- (route) => resolveRelativeRouteFilePath(route, reactRouterConfig)
2303
- )
2304
- ].map(
2305
- (entry) => (
2306
- // In Vite 7, the `optimizeDeps.entries` option only accepts glob patterns.
2307
- // In prior versions, absolute file paths were treated differently.
2308
- viteMajorVersion >= 7 ? (0, import_tinyglobby.escapePath)(entry) : entry
2309
- )
2310
- );
2311
- }
2312
-
2313
2254
  // vite/with-props.ts
2314
2255
  var namedComponentExports = ["HydrateFallback", "ErrorBoundary"];
2315
2256
  function isNamedComponentExport(name) {
@@ -2317,24 +2258,24 @@ function isNamedComponentExport(name) {
2317
2258
  }
2318
2259
  var decorateComponentExportsWithProps = (ast) => {
2319
2260
  const hocs = [];
2320
- function getHocUid(path7, hocName) {
2321
- const uid = path7.scope.generateUidIdentifier(hocName);
2261
+ function getHocUid(path6, hocName) {
2262
+ const uid = path6.scope.generateUidIdentifier(hocName);
2322
2263
  hocs.push([hocName, uid]);
2323
2264
  return uid;
2324
2265
  }
2325
2266
  traverse(ast, {
2326
- ExportDeclaration(path7) {
2327
- if (path7.isExportDefaultDeclaration()) {
2328
- const declaration = path7.get("declaration");
2267
+ ExportDeclaration(path6) {
2268
+ if (path6.isExportDefaultDeclaration()) {
2269
+ const declaration = path6.get("declaration");
2329
2270
  const expr = declaration.isExpression() ? declaration.node : declaration.isFunctionDeclaration() ? toFunctionExpression(declaration.node) : void 0;
2330
2271
  if (expr) {
2331
- const uid = getHocUid(path7, "UNSAFE_withComponentProps");
2272
+ const uid = getHocUid(path6, "UNSAFE_withComponentProps");
2332
2273
  declaration.replaceWith(t.callExpression(uid, [expr]));
2333
2274
  }
2334
2275
  return;
2335
2276
  }
2336
- if (path7.isExportNamedDeclaration()) {
2337
- const decl = path7.get("declaration");
2277
+ if (path6.isExportNamedDeclaration()) {
2278
+ const decl = path6.get("declaration");
2338
2279
  if (decl.isVariableDeclaration()) {
2339
2280
  decl.get("declarations").forEach((varDeclarator) => {
2340
2281
  const id = varDeclarator.get("id");
@@ -2344,7 +2285,7 @@ var decorateComponentExportsWithProps = (ast) => {
2344
2285
  if (!id.isIdentifier()) return;
2345
2286
  const { name } = id.node;
2346
2287
  if (!isNamedComponentExport(name)) return;
2347
- const uid = getHocUid(path7, `UNSAFE_with${name}Props`);
2288
+ const uid = getHocUid(path6, `UNSAFE_with${name}Props`);
2348
2289
  init.replaceWith(t.callExpression(uid, [expr]));
2349
2290
  });
2350
2291
  return;
@@ -2354,7 +2295,7 @@ var decorateComponentExportsWithProps = (ast) => {
2354
2295
  if (!id) return;
2355
2296
  const { name } = id;
2356
2297
  if (!isNamedComponentExport(name)) return;
2357
- const uid = getHocUid(path7, `UNSAFE_with${name}Props`);
2298
+ const uid = getHocUid(path6, `UNSAFE_with${name}Props`);
2358
2299
  decl.replaceWith(
2359
2300
  t.variableDeclaration("const", [
2360
2301
  t.variableDeclarator(
@@ -2399,22 +2340,16 @@ function validatePluginOrder() {
2399
2340
  (plugin) => pluginName.includes(plugin.name)
2400
2341
  );
2401
2342
  };
2402
- let reactRouterRscPluginIndex = pluginIndex("react-router/rsc");
2403
- let viteRscPluginIndex = pluginIndex("rsc");
2404
- if (reactRouterRscPluginIndex >= 0 && viteRscPluginIndex >= 0 && reactRouterRscPluginIndex > viteRscPluginIndex) {
2405
- throw new Error(
2406
- `The "@vitejs/plugin-rsc" plugin should be placed after the React Router RSC plugin in your Vite config`
2407
- );
2408
- }
2409
- let reactRouterPluginIndex = pluginIndex([
2410
- "react-router",
2411
- "react-router/rsc"
2412
- ]);
2413
- let mdxPluginIndex = pluginIndex("@mdx-js/rollup");
2414
- if (mdxPluginIndex >= 0 && mdxPluginIndex > reactRouterPluginIndex) {
2415
- throw new Error(
2416
- `The "@mdx-js/rollup" plugin should be placed before the React Router plugin in your Vite config`
2417
- );
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
+ }
2418
2353
  }
2419
2354
  }
2420
2355
  };
@@ -2424,11 +2359,16 @@ function validatePluginOrder() {
2424
2359
  function extractPluginContext(viteConfig) {
2425
2360
  return viteConfig["__reactRouterPluginContext"];
2426
2361
  }
2427
- var SERVER_ONLY_ROUTE_EXPORTS = ["loader", "action", "middleware", "headers"];
2362
+ var SERVER_ONLY_ROUTE_EXPORTS = [
2363
+ "loader",
2364
+ "action",
2365
+ "unstable_middleware",
2366
+ "headers"
2367
+ ];
2428
2368
  var CLIENT_NON_COMPONENT_EXPORTS = [
2429
2369
  "clientAction",
2430
2370
  "clientLoader",
2431
- "clientMiddleware",
2371
+ "unstable_clientMiddleware",
2432
2372
  "handle",
2433
2373
  "meta",
2434
2374
  "links",
@@ -2481,10 +2421,16 @@ var virtualHmrRuntime = create("hmr-runtime");
2481
2421
  var virtualInjectHmrRuntime = create("inject-hmr-runtime");
2482
2422
  var normalizeRelativeFilePath = (file, reactRouterConfig) => {
2483
2423
  let vite2 = getVite();
2484
- let fullPath = path6.resolve(reactRouterConfig.appDirectory, file);
2485
- let relativePath = path6.relative(reactRouterConfig.appDirectory, fullPath);
2424
+ let fullPath = path5.resolve(reactRouterConfig.appDirectory, file);
2425
+ let relativePath = path5.relative(reactRouterConfig.appDirectory, fullPath);
2486
2426
  return vite2.normalizePath(relativePath).split("?")[0];
2487
2427
  };
2428
+ var resolveRelativeRouteFilePath = (route, reactRouterConfig) => {
2429
+ let vite2 = getVite();
2430
+ let file = route.file;
2431
+ let fullPath = path5.resolve(reactRouterConfig.appDirectory, file);
2432
+ return vite2.normalizePath(fullPath);
2433
+ };
2488
2434
  var virtual = {
2489
2435
  serverBuild: create("server-build"),
2490
2436
  serverManifest: create("server-manifest"),
@@ -2505,7 +2451,7 @@ var getHash = (source, maxLength) => {
2505
2451
  var resolveChunk = (ctx, viteManifest, absoluteFilePath) => {
2506
2452
  let vite2 = getVite();
2507
2453
  let rootRelativeFilePath = vite2.normalizePath(
2508
- path6.relative(ctx.rootDirectory, absoluteFilePath)
2454
+ path5.relative(ctx.rootDirectory, absoluteFilePath)
2509
2455
  );
2510
2456
  let entryChunk = viteManifest[rootRelativeFilePath];
2511
2457
  if (!entryChunk) {
@@ -2594,7 +2540,7 @@ function dedupe(array2) {
2594
2540
  return [...new Set(array2)];
2595
2541
  }
2596
2542
  var writeFileSafe = async (file, contents) => {
2597
- await (0, import_promises2.mkdir)(path6.dirname(file), { recursive: true });
2543
+ await (0, import_promises2.mkdir)(path5.dirname(file), { recursive: true });
2598
2544
  await (0, import_promises2.writeFile)(file, contents);
2599
2545
  };
2600
2546
  var getExportNames = (code) => {
@@ -2620,7 +2566,7 @@ var compileRouteFile = async (viteChildCompiler, ctx, routeFile, readRouteFile)
2620
2566
  }
2621
2567
  let ssr = true;
2622
2568
  let { pluginContainer, moduleGraph } = viteChildCompiler;
2623
- let routePath = path6.resolve(ctx.reactRouterConfig.appDirectory, routeFile);
2569
+ let routePath = path5.resolve(ctx.reactRouterConfig.appDirectory, routeFile);
2624
2570
  let url2 = resolveFileUrl(ctx, routePath);
2625
2571
  let resolveId = async () => {
2626
2572
  let result = await pluginContainer.resolveId(url2, void 0, { ssr });
@@ -2662,12 +2608,12 @@ var resolveEnvironmentBuildContext = ({
2662
2608
  };
2663
2609
  return resolvedBuildContext;
2664
2610
  };
2665
- var getServerBuildDirectory = (reactRouterConfig, { serverBundleId } = {}) => path6.join(
2611
+ var getServerBuildDirectory = (reactRouterConfig, { serverBundleId } = {}) => path5.join(
2666
2612
  reactRouterConfig.buildDirectory,
2667
2613
  "server",
2668
2614
  ...serverBundleId ? [serverBundleId] : []
2669
2615
  );
2670
- var getClientBuildDirectory = (reactRouterConfig) => path6.join(reactRouterConfig.buildDirectory, "client");
2616
+ var getClientBuildDirectory = (reactRouterConfig) => path5.join(reactRouterConfig.buildDirectory, "client");
2671
2617
  var getServerBundleRouteIds = (vitePluginContext, ctx) => {
2672
2618
  if (!ctx.buildManifest) {
2673
2619
  return void 0;
@@ -2685,14 +2631,14 @@ var getServerBundleRouteIds = (vitePluginContext, ctx) => {
2685
2631
  );
2686
2632
  return Object.keys(serverBundleRoutes);
2687
2633
  };
2688
- var defaultEntriesDir = path6.resolve(
2689
- path6.dirname(require.resolve("@react-router/dev/package.json")),
2634
+ var defaultEntriesDir = path5.resolve(
2635
+ path5.dirname(require.resolve("@react-router/dev/package.json")),
2690
2636
  "dist",
2691
2637
  "config",
2692
2638
  "defaults"
2693
2639
  );
2694
2640
  var defaultEntries = (0, import_node_fs2.readdirSync)(defaultEntriesDir).map(
2695
- (filename2) => path6.join(defaultEntriesDir, filename2)
2641
+ (filename2) => path5.join(defaultEntriesDir, filename2)
2696
2642
  );
2697
2643
  invariant(defaultEntries.length > 0, "No default entries found");
2698
2644
  var reactRouterDevLoadContext = () => void 0;
@@ -2788,7 +2734,7 @@ var reactRouterVitePlugin = () => {
2788
2734
  virtual.serverManifest.id
2789
2735
  )};
2790
2736
  export const assetsBuildDirectory = ${JSON.stringify(
2791
- path6.relative(
2737
+ path5.relative(
2792
2738
  ctx.rootDirectory,
2793
2739
  getClientBuildDirectory(ctx.reactRouterConfig)
2794
2740
  )
@@ -2827,11 +2773,18 @@ var reactRouterVitePlugin = () => {
2827
2773
  };
2828
2774
  let loadViteManifest = async (directory) => {
2829
2775
  let manifestContents = await (0, import_promises2.readFile)(
2830
- path6.resolve(directory, ".vite", "manifest.json"),
2776
+ path5.resolve(directory, ".vite", "manifest.json"),
2831
2777
  "utf-8"
2832
2778
  );
2833
2779
  return JSON.parse(manifestContents);
2834
2780
  };
2781
+ let hasDependency = (name) => {
2782
+ try {
2783
+ return Boolean(require.resolve(name, { paths: [ctx.rootDirectory] }));
2784
+ } catch (err2) {
2785
+ return false;
2786
+ }
2787
+ };
2835
2788
  let getViteManifestAssetPaths = (viteManifest) => {
2836
2789
  let cssUrlPaths = Object.values(viteManifest).filter((chunk) => chunk.file.endsWith(".css")).map((chunk) => chunk.file);
2837
2790
  let chunkAssetPaths = Object.values(viteManifest).flatMap(
@@ -2852,7 +2805,7 @@ var reactRouterVitePlugin = () => {
2852
2805
  let contents;
2853
2806
  try {
2854
2807
  contents = await (0, import_promises2.readFile)(
2855
- path6.join(entryNormalizedPath, entry.name),
2808
+ path5.join(entryNormalizedPath, entry.name),
2856
2809
  "utf-8"
2857
2810
  );
2858
2811
  } catch (e) {
@@ -2861,9 +2814,9 @@ var reactRouterVitePlugin = () => {
2861
2814
  }
2862
2815
  let hash = (0, import_node_crypto.createHash)("sha384").update(contents).digest().toString("base64");
2863
2816
  let filepath = getVite().normalizePath(
2864
- path6.relative(
2817
+ path5.relative(
2865
2818
  clientBuildDirectory,
2866
- path6.join(entryNormalizedPath, entry.name)
2819
+ path5.join(entryNormalizedPath, entry.name)
2867
2820
  )
2868
2821
  );
2869
2822
  sriManifest[`${ctx2.publicPath}${filepath}`] = `sha384-${hash}`;
@@ -2894,11 +2847,13 @@ var reactRouterVitePlugin = () => {
2894
2847
  );
2895
2848
  let enforceSplitRouteModules = ctx.reactRouterConfig.future.unstable_splitRouteModules === "enforce";
2896
2849
  for (let route of Object.values(ctx.reactRouterConfig.routes)) {
2897
- let routeFile = path6.join(ctx.reactRouterConfig.appDirectory, route.file);
2850
+ let routeFile = path5.join(ctx.reactRouterConfig.appDirectory, route.file);
2898
2851
  let sourceExports = routeManifestExports[route.id];
2899
2852
  let hasClientAction = sourceExports.includes("clientAction");
2900
2853
  let hasClientLoader = sourceExports.includes("clientLoader");
2901
- let hasClientMiddleware = sourceExports.includes("clientMiddleware");
2854
+ let hasClientMiddleware = sourceExports.includes(
2855
+ "unstable_clientMiddleware"
2856
+ );
2902
2857
  let hasHydrateFallback = sourceExports.includes("HydrateFallback");
2903
2858
  let { hasRouteChunkByExportName } = await detectRouteChunksIfEnabled(
2904
2859
  cache,
@@ -2913,7 +2868,7 @@ var reactRouterVitePlugin = () => {
2913
2868
  valid: {
2914
2869
  clientAction: !hasClientAction || hasRouteChunkByExportName.clientAction,
2915
2870
  clientLoader: !hasClientLoader || hasRouteChunkByExportName.clientLoader,
2916
- clientMiddleware: !hasClientMiddleware || hasRouteChunkByExportName.clientMiddleware,
2871
+ unstable_clientMiddleware: !hasClientMiddleware || hasRouteChunkByExportName.unstable_clientMiddleware,
2917
2872
  HydrateFallback: !hasHydrateFallback || hasRouteChunkByExportName.HydrateFallback
2918
2873
  }
2919
2874
  });
@@ -2947,10 +2902,10 @@ var reactRouterVitePlugin = () => {
2947
2902
  viteManifest,
2948
2903
  getRouteChunkModuleId(routeFile, "clientLoader")
2949
2904
  ) : void 0,
2950
- clientMiddlewareModule: hasRouteChunkByExportName.clientMiddleware ? getPublicModulePathForEntry(
2905
+ clientMiddlewareModule: hasRouteChunkByExportName.unstable_clientMiddleware ? getPublicModulePathForEntry(
2951
2906
  ctx,
2952
2907
  viteManifest,
2953
- getRouteChunkModuleId(routeFile, "clientMiddleware")
2908
+ getRouteChunkModuleId(routeFile, "unstable_clientMiddleware")
2954
2909
  ) : void 0,
2955
2910
  hydrateFallbackModule: hasRouteChunkByExportName.HydrateFallback ? getPublicModulePathForEntry(
2956
2911
  ctx,
@@ -2965,7 +2920,7 @@ var reactRouterVitePlugin = () => {
2965
2920
  }
2966
2921
  let fingerprintedValues = { entry, routes: browserRoutes };
2967
2922
  let version = getHash(JSON.stringify(fingerprintedValues), 8);
2968
- let manifestPath = path6.posix.join(
2923
+ let manifestPath = path5.posix.join(
2969
2924
  viteConfig2.build.assetsDir,
2970
2925
  `manifest-${version}.js`
2971
2926
  );
@@ -2977,7 +2932,7 @@ var reactRouterVitePlugin = () => {
2977
2932
  sri: void 0
2978
2933
  };
2979
2934
  await writeFileSafe(
2980
- path6.join(getClientBuildDirectory(ctx.reactRouterConfig), manifestPath),
2935
+ path5.join(getClientBuildDirectory(ctx.reactRouterConfig), manifestPath),
2981
2936
  `window.__reactRouterManifest=${JSON.stringify(
2982
2937
  reactRouterBrowserManifest
2983
2938
  )};`
@@ -3009,7 +2964,9 @@ var reactRouterVitePlugin = () => {
3009
2964
  let sourceExports = routeManifestExports[key];
3010
2965
  let hasClientAction = sourceExports.includes("clientAction");
3011
2966
  let hasClientLoader = sourceExports.includes("clientLoader");
3012
- let hasClientMiddleware = sourceExports.includes("clientMiddleware");
2967
+ let hasClientMiddleware = sourceExports.includes(
2968
+ "unstable_clientMiddleware"
2969
+ );
3013
2970
  let hasHydrateFallback = sourceExports.includes("HydrateFallback");
3014
2971
  let routeModulePath = combineURLs(
3015
2972
  ctx.publicPath,
@@ -3031,7 +2988,7 @@ var reactRouterVitePlugin = () => {
3031
2988
  valid: {
3032
2989
  clientAction: !hasClientAction || hasRouteChunkByExportName.clientAction,
3033
2990
  clientLoader: !hasClientLoader || hasRouteChunkByExportName.clientLoader,
3034
- clientMiddleware: !hasClientMiddleware || hasRouteChunkByExportName.clientMiddleware,
2991
+ unstable_clientMiddleware: !hasClientMiddleware || hasRouteChunkByExportName.unstable_clientMiddleware,
3035
2992
  HydrateFallback: !hasHydrateFallback || hasRouteChunkByExportName.HydrateFallback
3036
2993
  }
3037
2994
  });
@@ -3103,6 +3060,7 @@ var reactRouterVitePlugin = () => {
3103
3060
  config: async (_viteUserConfig, _viteConfigEnv) => {
3104
3061
  await preloadVite();
3105
3062
  let vite2 = getVite();
3063
+ let viteMajorVersion = parseInt(vite2.version.split(".")[0], 10);
3106
3064
  viteUserConfig = _viteUserConfig;
3107
3065
  viteConfigEnv = _viteConfigEnv;
3108
3066
  viteCommand = viteConfigEnv.command;
@@ -3156,10 +3114,18 @@ var reactRouterVitePlugin = () => {
3156
3114
  resolve: serverEnvironment.resolve
3157
3115
  },
3158
3116
  optimizeDeps: {
3159
- entries: getOptimizeDepsEntries({
3160
- entryClientFilePath: ctx.entryClientFilePath,
3161
- reactRouterConfig: ctx.reactRouterConfig
3162
- }),
3117
+ entries: ctx.reactRouterConfig.future.unstable_optimizeDeps ? [
3118
+ vite2.normalizePath(ctx.entryClientFilePath),
3119
+ ...Object.values(ctx.reactRouterConfig.routes).map(
3120
+ (route) => resolveRelativeRouteFilePath(route, ctx.reactRouterConfig)
3121
+ )
3122
+ ].map(
3123
+ (entry) => (
3124
+ // In Vite 7, the `optimizeDeps.entries` option only accepts glob patterns.
3125
+ // In prior versions, absolute file paths were treated differently.
3126
+ viteMajorVersion >= 7 ? (0, import_tinyglobby.escapePath)(entry) : entry
3127
+ )
3128
+ ) : [],
3163
3129
  include: [
3164
3130
  // Pre-bundle React dependencies to avoid React duplicates,
3165
3131
  // even if React dependencies are not direct dependencies.
@@ -3174,10 +3140,7 @@ var reactRouterVitePlugin = () => {
3174
3140
  "react-router",
3175
3141
  "react-router/dom",
3176
3142
  // Check to avoid "Failed to resolve dependency: react-router-dom, present in 'optimizeDeps.include'"
3177
- ...hasDependency({
3178
- name: "react-router-dom",
3179
- rootDirectory: ctx.rootDirectory
3180
- }) ? ["react-router-dom"] : []
3143
+ ...hasDependency("react-router-dom") ? ["react-router-dom"] : []
3181
3144
  ]
3182
3145
  },
3183
3146
  esbuild: {
@@ -3475,11 +3438,11 @@ var reactRouterVitePlugin = () => {
3475
3438
  let removedAssetPaths = [];
3476
3439
  let copiedAssetPaths = [];
3477
3440
  for (let ssrAssetPath of ssrAssetPaths) {
3478
- let src = path6.join(serverBuildDirectory, ssrAssetPath);
3479
- let dest = path6.join(clientBuildDirectory, ssrAssetPath);
3441
+ let src = path5.join(serverBuildDirectory, ssrAssetPath);
3442
+ let dest = path5.join(clientBuildDirectory, ssrAssetPath);
3480
3443
  if (!userSsrEmitAssets) {
3481
3444
  if (!(0, import_node_fs2.existsSync)(dest)) {
3482
- await (0, import_promises2.mkdir)(path6.dirname(dest), { recursive: true });
3445
+ await (0, import_promises2.mkdir)(path5.dirname(dest), { recursive: true });
3483
3446
  await (0, import_promises2.rename)(src, dest);
3484
3447
  movedAssetPaths.push(dest);
3485
3448
  } else {
@@ -3497,7 +3460,7 @@ var reactRouterVitePlugin = () => {
3497
3460
  );
3498
3461
  await Promise.all(
3499
3462
  ssrCssPaths.map(async (cssPath) => {
3500
- let src = path6.join(serverBuildDirectory, cssPath);
3463
+ let src = path5.join(serverBuildDirectory, cssPath);
3501
3464
  await (0, import_promises2.rm)(src, { force: true, recursive: true });
3502
3465
  removedAssetPaths.push(src);
3503
3466
  })
@@ -3505,7 +3468,7 @@ var reactRouterVitePlugin = () => {
3505
3468
  }
3506
3469
  let cleanedAssetPaths = [...removedAssetPaths, ...movedAssetPaths];
3507
3470
  let handledAssetPaths = [...cleanedAssetPaths, ...copiedAssetPaths];
3508
- let cleanedAssetDirs = new Set(cleanedAssetPaths.map(path6.dirname));
3471
+ let cleanedAssetDirs = new Set(cleanedAssetPaths.map(path5.dirname));
3509
3472
  await Promise.all(
3510
3473
  Array.from(cleanedAssetDirs).map(async (dir) => {
3511
3474
  try {
@@ -3527,7 +3490,7 @@ var reactRouterVitePlugin = () => {
3527
3490
  [
3528
3491
  `${import_picocolors3.default.green("\u2713")} ${message}`,
3529
3492
  ...paths.map(
3530
- (assetPath) => import_picocolors3.default.dim(path6.relative(ctx.rootDirectory, assetPath))
3493
+ (assetPath) => import_picocolors3.default.dim(path5.relative(ctx.rootDirectory, assetPath))
3531
3494
  )
3532
3495
  ].join("\n")
3533
3496
  );
@@ -3621,7 +3584,7 @@ var reactRouterVitePlugin = () => {
3621
3584
  );
3622
3585
  let isMainChunkExport = (name) => !chunkedExports.includes(name);
3623
3586
  let mainChunkReexports = sourceExports.filter(isMainChunkExport).join(", ");
3624
- let chunkBasePath = `./${path6.basename(id)}`;
3587
+ let chunkBasePath = `./${path5.basename(id)}`;
3625
3588
  return [
3626
3589
  `export { ${mainChunkReexports} } from "${getRouteChunkModuleId(
3627
3590
  chunkBasePath,
@@ -3641,7 +3604,7 @@ var reactRouterVitePlugin = () => {
3641
3604
  async transform(code, id, options) {
3642
3605
  if (!id.endsWith(BUILD_CLIENT_ROUTE_QUERY_STRING)) return;
3643
3606
  let routeModuleId = id.replace(BUILD_CLIENT_ROUTE_QUERY_STRING, "");
3644
- let routeFileName = path6.basename(routeModuleId);
3607
+ let routeFileName = path5.basename(routeModuleId);
3645
3608
  let sourceExports = await getRouteModuleExports(
3646
3609
  viteChildCompiler,
3647
3610
  ctx,
@@ -3693,7 +3656,9 @@ var reactRouterVitePlugin = () => {
3693
3656
  valid: {
3694
3657
  clientAction: !exportNames.includes("clientAction"),
3695
3658
  clientLoader: !exportNames.includes("clientLoader"),
3696
- clientMiddleware: !exportNames.includes("clientMiddleware"),
3659
+ unstable_clientMiddleware: !exportNames.includes(
3660
+ "unstable_clientMiddleware"
3661
+ ),
3697
3662
  HydrateFallback: !exportNames.includes("HydrateFallback")
3698
3663
  }
3699
3664
  });
@@ -3768,7 +3733,7 @@ var reactRouterVitePlugin = () => {
3768
3733
  }
3769
3734
  let vite2 = getVite();
3770
3735
  let importerShort = vite2.normalizePath(
3771
- path6.relative(ctx.rootDirectory, importer)
3736
+ path5.relative(ctx.rootDirectory, importer)
3772
3737
  );
3773
3738
  if (isRoute(ctx.reactRouterConfig, importer)) {
3774
3739
  let serverOnlyExports = SERVER_ONLY_ROUTE_EXPORTS.map(
@@ -3890,10 +3855,10 @@ var reactRouterVitePlugin = () => {
3890
3855
  },
3891
3856
  async load(id) {
3892
3857
  if (id !== virtualHmrRuntime.resolvedId) return;
3893
- let reactRefreshDir = path6.dirname(
3858
+ let reactRefreshDir = path5.dirname(
3894
3859
  require.resolve("react-refresh/package.json")
3895
3860
  );
3896
- let reactRefreshRuntimePath = path6.join(
3861
+ let reactRefreshRuntimePath = path5.join(
3897
3862
  reactRefreshDir,
3898
3863
  "cjs/react-refresh-runtime.development.js"
3899
3864
  );
@@ -4072,7 +4037,7 @@ if (import.meta.hot && !inWebWorker) {
4072
4037
  function getRoute(pluginConfig, file) {
4073
4038
  let vite2 = getVite();
4074
4039
  let routePath = vite2.normalizePath(
4075
- path6.relative(pluginConfig.appDirectory, file)
4040
+ path5.relative(pluginConfig.appDirectory, file)
4076
4041
  );
4077
4042
  let route = Object.values(pluginConfig.routes).find(
4078
4043
  (r) => vite2.normalizePath(r.file) === routePath
@@ -4111,7 +4076,7 @@ async function getRouteMetadata(cache, ctx, viteChildCompiler, route, readRouteF
4111
4076
  caseSensitive: route.caseSensitive,
4112
4077
  url: combineURLs(
4113
4078
  ctx.publicPath,
4114
- "/" + path6.relative(
4079
+ "/" + path5.relative(
4115
4080
  ctx.rootDirectory,
4116
4081
  resolveRelativeRouteFilePath(route, ctx.reactRouterConfig)
4117
4082
  )
@@ -4120,13 +4085,13 @@ async function getRouteMetadata(cache, ctx, viteChildCompiler, route, readRouteF
4120
4085
  // Ensure the Vite dev server responds with a JS module
4121
4086
  clientActionModule: hasRouteChunkByExportName.clientAction ? `${getRouteChunkModuleId(moduleUrl, "clientAction")}` : void 0,
4122
4087
  clientLoaderModule: hasRouteChunkByExportName.clientLoader ? `${getRouteChunkModuleId(moduleUrl, "clientLoader")}` : void 0,
4123
- clientMiddlewareModule: hasRouteChunkByExportName.clientMiddleware ? `${getRouteChunkModuleId(moduleUrl, "clientMiddleware")}` : void 0,
4088
+ clientMiddlewareModule: hasRouteChunkByExportName.unstable_clientMiddleware ? `${getRouteChunkModuleId(moduleUrl, "unstable_clientMiddleware")}` : void 0,
4124
4089
  hydrateFallbackModule: hasRouteChunkByExportName.HydrateFallback ? `${getRouteChunkModuleId(moduleUrl, "HydrateFallback")}` : void 0,
4125
4090
  hasAction: sourceExports.includes("action"),
4126
4091
  hasClientAction: sourceExports.includes("clientAction"),
4127
4092
  hasLoader: sourceExports.includes("loader"),
4128
4093
  hasClientLoader: sourceExports.includes("clientLoader"),
4129
- hasClientMiddleware: sourceExports.includes("clientMiddleware"),
4094
+ hasClientMiddleware: sourceExports.includes("unstable_clientMiddleware"),
4130
4095
  hasErrorBoundary: sourceExports.includes("ErrorBoundary"),
4131
4096
  imports: []
4132
4097
  };
@@ -4139,7 +4104,7 @@ function isSpaModeEnabled(reactRouterConfig) {
4139
4104
  return reactRouterConfig.ssr === false && !isPrerenderingEnabled(reactRouterConfig);
4140
4105
  }
4141
4106
  async function getPrerenderBuildAndHandler(viteConfig, serverBuildDirectory, serverBuildFile) {
4142
- let serverBuildPath = path6.join(serverBuildDirectory, serverBuildFile);
4107
+ let serverBuildPath = path5.join(serverBuildDirectory, serverBuildFile);
4143
4108
  let build = await import(url.pathToFileURL(serverBuildPath).toString());
4144
4109
  let { createRequestHandler: createHandler } = await import("react-router");
4145
4110
  return {
@@ -4181,9 +4146,9 @@ async function handleSpaMode(viteConfig, reactRouterConfig, serverBuildDirectory
4181
4146
  "SPA Mode: Did you forget to include `<Scripts/>` in your root route? Your pre-rendered HTML cannot hydrate without `<Scripts />`."
4182
4147
  );
4183
4148
  }
4184
- await (0, import_promises2.writeFile)(path6.join(clientBuildDirectory, filename2), html);
4185
- let prettyDir = path6.relative(viteConfig.root, clientBuildDirectory);
4186
- let prettyPath = path6.join(prettyDir, filename2);
4149
+ await (0, import_promises2.writeFile)(path5.join(clientBuildDirectory, filename2), html);
4150
+ let prettyDir = path5.relative(viteConfig.root, clientBuildDirectory);
4151
+ let prettyPath = path5.join(prettyDir, filename2);
4187
4152
  if (build.prerender.length > 0) {
4188
4153
  viteConfig.logger.info(
4189
4154
  `Prerender (html): SPA Fallback -> ${import_picocolors3.default.bold(prettyPath)}`
@@ -4199,17 +4164,17 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
4199
4164
  serverBuildPath
4200
4165
  );
4201
4166
  let routes = createPrerenderRoutes(reactRouterConfig.routes);
4202
- for (let path7 of build.prerender) {
4203
- let matches = (0, import_react_router2.matchRoutes)(routes, `/${path7}/`.replace(/^\/\/+/, "/"));
4167
+ for (let path6 of build.prerender) {
4168
+ let matches = (0, import_react_router2.matchRoutes)(routes, `/${path6}/`.replace(/^\/\/+/, "/"));
4204
4169
  if (!matches) {
4205
4170
  throw new Error(
4206
- `Unable to prerender path because it does not match any routes: ${path7}`
4171
+ `Unable to prerender path because it does not match any routes: ${path6}`
4207
4172
  );
4208
4173
  }
4209
4174
  }
4210
4175
  let buildRoutes = createPrerenderRoutes(build.routes);
4211
- for (let path7 of build.prerender) {
4212
- let matches = (0, import_react_router2.matchRoutes)(buildRoutes, `/${path7}/`.replace(/^\/\/+/, "/"));
4176
+ for (let path6 of build.prerender) {
4177
+ let matches = (0, import_react_router2.matchRoutes)(buildRoutes, `/${path6}/`.replace(/^\/\/+/, "/"));
4213
4178
  if (!matches) {
4214
4179
  continue;
4215
4180
  }
@@ -4222,7 +4187,7 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
4222
4187
  if (manifestRoute.loader) {
4223
4188
  await prerenderData(
4224
4189
  handler,
4225
- path7,
4190
+ path6,
4226
4191
  [leafRoute.id],
4227
4192
  clientBuildDirectory,
4228
4193
  reactRouterConfig,
@@ -4230,7 +4195,7 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
4230
4195
  );
4231
4196
  await prerenderResourceRoute(
4232
4197
  handler,
4233
- path7,
4198
+ path6,
4234
4199
  clientBuildDirectory,
4235
4200
  reactRouterConfig,
4236
4201
  viteConfig
@@ -4248,7 +4213,7 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
4248
4213
  if (!isResourceRoute && hasLoaders) {
4249
4214
  data = await prerenderData(
4250
4215
  handler,
4251
- path7,
4216
+ path6,
4252
4217
  null,
4253
4218
  clientBuildDirectory,
4254
4219
  reactRouterConfig,
@@ -4257,7 +4222,7 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
4257
4222
  }
4258
4223
  await prerenderRoute(
4259
4224
  handler,
4260
- path7,
4225
+ path6,
4261
4226
  clientBuildDirectory,
4262
4227
  reactRouterConfig,
4263
4228
  viteConfig,
@@ -4310,12 +4275,12 @@ async function prerenderData(handler, prerenderPath, onlyRoutes, clientBuildDire
4310
4275
  ${normalizedPath}`
4311
4276
  );
4312
4277
  }
4313
- let outfile = path6.join(clientBuildDirectory, ...normalizedPath.split("/"));
4314
- await (0, import_promises2.mkdir)(path6.dirname(outfile), { recursive: true });
4278
+ let outfile = path5.join(clientBuildDirectory, ...normalizedPath.split("/"));
4279
+ await (0, import_promises2.mkdir)(path5.dirname(outfile), { recursive: true });
4315
4280
  await (0, import_promises2.writeFile)(outfile, data);
4316
4281
  viteConfig.logger.info(
4317
4282
  `Prerender (data): ${prerenderPath} -> ${import_picocolors3.default.bold(
4318
- path6.relative(viteConfig.root, outfile)
4283
+ path5.relative(viteConfig.root, outfile)
4319
4284
  )}`
4320
4285
  );
4321
4286
  return data;
@@ -4350,16 +4315,16 @@ async function prerenderRoute(handler, prerenderPath, clientBuildDirectory, reac
4350
4315
  ${html}`
4351
4316
  );
4352
4317
  }
4353
- let outfile = path6.join(
4318
+ let outfile = path5.join(
4354
4319
  clientBuildDirectory,
4355
4320
  ...normalizedPath.split("/"),
4356
4321
  "index.html"
4357
4322
  );
4358
- await (0, import_promises2.mkdir)(path6.dirname(outfile), { recursive: true });
4323
+ await (0, import_promises2.mkdir)(path5.dirname(outfile), { recursive: true });
4359
4324
  await (0, import_promises2.writeFile)(outfile, html);
4360
4325
  viteConfig.logger.info(
4361
4326
  `Prerender (html): ${prerenderPath} -> ${import_picocolors3.default.bold(
4362
- path6.relative(viteConfig.root, outfile)
4327
+ path5.relative(viteConfig.root, outfile)
4363
4328
  )}`
4364
4329
  );
4365
4330
  }
@@ -4374,12 +4339,12 @@ async function prerenderResourceRoute(handler, prerenderPath, clientBuildDirecto
4374
4339
  ${content.toString("utf8")}`
4375
4340
  );
4376
4341
  }
4377
- let outfile = path6.join(clientBuildDirectory, ...normalizedPath.split("/"));
4378
- await (0, import_promises2.mkdir)(path6.dirname(outfile), { recursive: true });
4342
+ let outfile = path5.join(clientBuildDirectory, ...normalizedPath.split("/"));
4343
+ await (0, import_promises2.mkdir)(path5.dirname(outfile), { recursive: true });
4379
4344
  await (0, import_promises2.writeFile)(outfile, content);
4380
4345
  viteConfig.logger.info(
4381
4346
  `Prerender (resource): ${prerenderPath} -> ${import_picocolors3.default.bold(
4382
- path6.relative(viteConfig.root, outfile)
4347
+ path5.relative(viteConfig.root, outfile)
4383
4348
  )}`
4384
4349
  );
4385
4350
  }
@@ -4453,14 +4418,14 @@ async function validateSsrFalsePrerenderExports(viteConfig, ctx, manifest, viteC
4453
4418
  }
4454
4419
  let prerenderRoutes = createPrerenderRoutes(manifest.routes);
4455
4420
  let prerenderedRoutes = /* @__PURE__ */ new Set();
4456
- for (let path7 of prerenderPaths) {
4421
+ for (let path6 of prerenderPaths) {
4457
4422
  let matches = (0, import_react_router2.matchRoutes)(
4458
4423
  prerenderRoutes,
4459
- `/${path7}/`.replace(/^\/\/+/, "/")
4424
+ `/${path6}/`.replace(/^\/\/+/, "/")
4460
4425
  );
4461
4426
  invariant(
4462
4427
  matches,
4463
- `Unable to prerender path because it does not match any routes: ${path7}`
4428
+ `Unable to prerender path because it does not match any routes: ${path6}`
4464
4429
  );
4465
4430
  matches.forEach((m) => prerenderedRoutes.add(m.route.id));
4466
4431
  }
@@ -4574,7 +4539,7 @@ async function detectRouteChunksIfEnabled(cache, ctx, id, input) {
4574
4539
  hasRouteChunkByExportName: {
4575
4540
  clientAction: false,
4576
4541
  clientLoader: false,
4577
- clientMiddleware: false,
4542
+ unstable_clientMiddleware: false,
4578
4543
  HydrateFallback: false
4579
4544
  }
4580
4545
  };
@@ -4627,8 +4592,8 @@ function validateRouteChunks({
4627
4592
  async function cleanBuildDirectory(viteConfig, ctx) {
4628
4593
  let buildDirectory = ctx.reactRouterConfig.buildDirectory;
4629
4594
  let isWithinRoot = () => {
4630
- let relativePath = path6.relative(ctx.rootDirectory, buildDirectory);
4631
- return !relativePath.startsWith("..") && !path6.isAbsolute(relativePath);
4595
+ let relativePath = path5.relative(ctx.rootDirectory, buildDirectory);
4596
+ return !relativePath.startsWith("..") && !path5.isAbsolute(relativePath);
4632
4597
  };
4633
4598
  if (viteConfig.build.emptyOutDir ?? isWithinRoot()) {
4634
4599
  await (0, import_promises2.rm)(buildDirectory, { force: true, recursive: true });
@@ -4639,7 +4604,7 @@ async function cleanViteManifests(environmentsOptions, ctx) {
4639
4604
  ([environmentName, options]) => {
4640
4605
  let outDir = options.build?.outDir;
4641
4606
  invariant(outDir, `Expected build.outDir for ${environmentName}`);
4642
- return path6.join(outDir, ".vite/manifest.json");
4607
+ return path5.join(outDir, ".vite/manifest.json");
4643
4608
  }
4644
4609
  );
4645
4610
  await Promise.all(
@@ -4649,7 +4614,7 @@ async function cleanViteManifests(environmentsOptions, ctx) {
4649
4614
  if (!ctx.viteManifestEnabled) {
4650
4615
  await (0, import_promises2.rm)(viteManifestPath, { force: true, recursive: true });
4651
4616
  }
4652
- let viteDir = path6.dirname(viteManifestPath);
4617
+ let viteDir = path5.dirname(viteManifestPath);
4653
4618
  let viteDirFiles = await (0, import_promises2.readdir)(viteDir, { recursive: true });
4654
4619
  if (viteDirFiles.length === 0) {
4655
4620
  await (0, import_promises2.rm)(viteDir, { force: true, recursive: true });
@@ -4667,12 +4632,12 @@ async function getBuildManifest({
4667
4632
  }
4668
4633
  let { normalizePath } = await import("vite");
4669
4634
  let serverBuildDirectory = getServerBuildDirectory(reactRouterConfig);
4670
- let resolvedAppDirectory = path6.resolve(rootDirectory, appDirectory);
4635
+ let resolvedAppDirectory = path5.resolve(rootDirectory, appDirectory);
4671
4636
  let rootRelativeRoutes = Object.fromEntries(
4672
4637
  Object.entries(routes).map(([id, route]) => {
4673
- let filePath = path6.join(resolvedAppDirectory, route.file);
4638
+ let filePath = path5.join(resolvedAppDirectory, route.file);
4674
4639
  let rootRelativeFilePath = normalizePath(
4675
- path6.relative(rootDirectory, filePath)
4640
+ path5.relative(rootDirectory, filePath)
4676
4641
  );
4677
4642
  return [id, { ...route, file: rootRelativeFilePath }];
4678
4643
  })
@@ -4690,7 +4655,7 @@ async function getBuildManifest({
4690
4655
  (route2) => configRouteToBranchRoute({
4691
4656
  ...route2,
4692
4657
  // Ensure absolute paths are passed to the serverBundles function
4693
- file: path6.join(resolvedAppDirectory, route2.file)
4658
+ file: path5.join(resolvedAppDirectory, route2.file)
4694
4659
  })
4695
4660
  )
4696
4661
  });
@@ -4714,10 +4679,10 @@ async function getBuildManifest({
4714
4679
  buildManifest.serverBundles[serverBundleId] ??= {
4715
4680
  id: serverBundleId,
4716
4681
  file: normalizePath(
4717
- path6.join(
4718
- path6.relative(
4682
+ path5.join(
4683
+ path5.relative(
4719
4684
  rootDirectory,
4720
- path6.join(serverBuildDirectory, serverBundleId)
4685
+ path5.join(serverBuildDirectory, serverBundleId)
4721
4686
  ),
4722
4687
  reactRouterConfig.serverBuildFile
4723
4688
  )
@@ -4736,10 +4701,10 @@ function mergeEnvironmentOptions(base, ...overrides) {
4736
4701
  }
4737
4702
  async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
4738
4703
  let { serverBuildFile, serverModuleFormat } = ctx.reactRouterConfig;
4739
- let packageRoot = path6.dirname(
4704
+ let packageRoot = path5.dirname(
4740
4705
  require.resolve("@react-router/dev/package.json")
4741
4706
  );
4742
- let { moduleSyncEnabled } = await import(`file:///${path6.join(packageRoot, "module-sync-enabled/index.mjs")}`);
4707
+ let { moduleSyncEnabled } = await import(`file:///${path5.join(packageRoot, "module-sync-enabled/index.mjs")}`);
4743
4708
  let vite2 = getVite();
4744
4709
  function getBaseOptions({
4745
4710
  viteUserConfig
@@ -4818,7 +4783,7 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
4818
4783
  ctx.entryClientFilePath,
4819
4784
  ...Object.values(ctx.reactRouterConfig.routes).flatMap(
4820
4785
  (route) => {
4821
- let routeFilePath = path6.resolve(
4786
+ let routeFilePath = path5.resolve(
4822
4787
  ctx.reactRouterConfig.appDirectory,
4823
4788
  route.file
4824
4789
  );
@@ -4842,7 +4807,7 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
4842
4807
  ) : null;
4843
4808
  let routeChunkSuffix = routeChunkName ? `-${(0, import_kebabCase.default)(routeChunkName)}` : "";
4844
4809
  let assetsDir = (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi ? viteUserConfig?.environments?.client?.build?.assetsDir : null) ?? viteUserConfig?.build?.assetsDir ?? "assets";
4845
- return path6.posix.join(
4810
+ return path5.posix.join(
4846
4811
  assetsDir,
4847
4812
  `[name]${routeChunkSuffix}-[hash].js`
4848
4813
  );