@react-router/dev 7.6.1 → 7.6.3-pre.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,79 @@
1
1
  # `@react-router/dev`
2
2
 
3
+ ## 7.6.3-pre.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Add Vite 7 support ([#13748](https://github.com/remix-run/react-router/pull/13748))
8
+ - Skip `package.json` resolution checks when a custom `entry.server.(j|t)sx` file is provided. ([#13744](https://github.com/remix-run/react-router/pull/13744))
9
+ - Add validation for a route's id not being 'root' ([#13792](https://github.com/remix-run/react-router/pull/13792))
10
+ - Updated dependencies:
11
+ - `@react-router/node@7.6.3-pre.0`
12
+ - `react-router@7.6.3-pre.0`
13
+ - `@react-router/serve@7.6.3-pre.0`
14
+
15
+ ## 7.6.2
16
+
17
+ ### Patch Changes
18
+
19
+ - Avoid additional `with-props` chunk in Framework Mode by moving route module component prop logic from the Vite plugin to `react-router` ([#13650](https://github.com/remix-run/react-router/pull/13650))
20
+
21
+ - When `future.unstable_viteEnvironmentApi` is enabled and an absolute Vite `base` has been configured, ensure critical CSS is handled correctly during development ([#13598](https://github.com/remix-run/react-router/pull/13598))
22
+
23
+ - Update `vite-node` ([#13673](https://github.com/remix-run/react-router/pull/13673))
24
+
25
+ - Fix typegen for non-{.js,.jsx,.ts,.tsx} routes like .mdx ([#12453](https://github.com/remix-run/react-router/pull/12453))
26
+
27
+ - Fix href types for optional dynamic params ([#13725](https://github.com/remix-run/react-router/pull/13725))
28
+
29
+ 7.6.1 introduced fixes for `href` when using optional static segments,
30
+ but those fixes caused regressions with how optional dynamic params worked in 7.6.0:
31
+
32
+ ```ts
33
+ // 7.6.0
34
+ href("/users/:id?"); // ✅
35
+ href("/users/:id?", { id: 1 }); // ✅
36
+
37
+ // 7.6.1
38
+ href("/users/:id?"); // ❌
39
+ href("/users/:id?", { id: 1 }); // ❌
40
+ ```
41
+
42
+ Now, optional static segments are expanded into different paths for `href`, but optional dynamic params are not.
43
+ This way `href` can unambiguously refer to an exact URL path, all while keeping the number of path options to a minimum.
44
+
45
+ ```ts
46
+ // 7.6.2
47
+
48
+ // path: /users/:id?/edit?
49
+ href("
50
+ // ^ suggestions when cursor is here:
51
+ //
52
+ // /users/:id?
53
+ // /users/:id?/edit
54
+ ```
55
+
56
+ Additionally, you can pass `params` from component props without needing to narrow them manually:
57
+
58
+ ```ts
59
+ declare const params: { id?: number };
60
+
61
+ // 7.6.0
62
+ href("/users/:id?", params);
63
+
64
+ // 7.6.1
65
+ href("/users/:id?", params); // ❌
66
+ "id" in params ? href("/users/:id", params) : href("/users"); // works... but is annoying
67
+
68
+ // 7.6.2
69
+ href("/users/:id?", params); // restores behavior of 7.6.0
70
+ ```
71
+
72
+ - Updated dependencies:
73
+ - `react-router@7.6.2`
74
+ - `@react-router/node@7.6.2`
75
+ - `@react-router/serve@7.6.2`
76
+
3
77
  ## 7.6.1
4
78
 
5
79
  ### Patch Changes
package/dist/cli/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * @react-router/dev v7.6.1
3
+ * @react-router/dev v7.6.3-pre.0
4
4
  *
5
5
  * Copyright (c) Remix Software Inc.
6
6
  *
@@ -130,6 +130,11 @@ async function createContext({
130
130
  }) {
131
131
  await preloadVite();
132
132
  const vite2 = getVite();
133
+ const [{ ViteNodeServer }, { ViteNodeRunner }, { installSourcemapsSupport }] = await Promise.all([
134
+ import("vite-node/server"),
135
+ import("vite-node/client"),
136
+ import("vite-node/source-map")
137
+ ]);
133
138
  const devServer = await vite2.createServer({
134
139
  root,
135
140
  mode,
@@ -159,11 +164,11 @@ async function createContext({
159
164
  plugins: []
160
165
  });
161
166
  await devServer.pluginContainer.buildStart({});
162
- const server = new import_server.ViteNodeServer(devServer);
163
- (0, import_source_map.installSourcemapsSupport)({
167
+ const server = new ViteNodeServer(devServer);
168
+ installSourcemapsSupport({
164
169
  getSourceMap: (source) => server.getSourceMap(source)
165
170
  });
166
- const runner = new import_client.ViteNodeRunner({
171
+ const runner = new ViteNodeRunner({
167
172
  root: devServer.config.root,
168
173
  base: devServer.config.base,
169
174
  fetchModule(id) {
@@ -175,13 +180,9 @@ async function createContext({
175
180
  });
176
181
  return { devServer, server, runner };
177
182
  }
178
- var import_server, import_client, import_source_map;
179
183
  var init_vite_node = __esm({
180
184
  "vite/vite-node.ts"() {
181
185
  "use strict";
182
- import_server = require("vite-node/server");
183
- import_client = require("vite-node/client");
184
- import_source_map = require("vite-node/source-map");
185
186
  init_vite();
186
187
  init_ssr_externals();
187
188
  }
@@ -272,7 +273,12 @@ var init_routes = __esm({
272
273
  return !(typeof value === "object" && value !== null && "then" in value && "catch" in value);
273
274
  }, "Invalid type: Expected object but received a promise. Did you forget to await?"),
274
275
  v.object({
275
- id: v.optional(v.string()),
276
+ id: v.optional(
277
+ v.pipe(
278
+ v.string(),
279
+ v.notValue("root", "A route cannot use the reserved id 'root'.")
280
+ )
281
+ ),
276
282
  path: v.optional(v.string()),
277
283
  index: v.optional(v.boolean()),
278
284
  caseSensitive: v.optional(v.boolean()),
@@ -928,7 +934,7 @@ function generateRoutes(ctx) {
928
934
  lineages.set(route.id, lineage2);
929
935
  const fullpath2 = fullpath(lineage2);
930
936
  if (!fullpath2) continue;
931
- const pages = explodeOptionalSegments(fullpath2);
937
+ const pages = expand(fullpath2);
932
938
  pages.forEach((page) => allPages.add(page));
933
939
  lineage2.forEach(({ id }) => {
934
940
  let routePages = routeToPages.get(id);
@@ -1136,9 +1142,13 @@ function getRouteAnnotations({
1136
1142
  }
1137
1143
  function relativeImportSource(from, to) {
1138
1144
  let path8 = Path3.relative(Path3.dirname(from), to);
1145
+ let extension = Path3.extname(path8);
1139
1146
  path8 = Path3.join(Path3.dirname(path8), Pathe.filename(path8));
1140
1147
  if (!path8.startsWith("../")) path8 = "./" + path8;
1141
- return path8 + ".js";
1148
+ if (!extension || /\.(js|ts)x?$/.test(extension)) {
1149
+ extension = ".js";
1150
+ }
1151
+ return path8 + extension;
1142
1152
  }
1143
1153
  function rootDirsPath(ctx, typesPath) {
1144
1154
  const rel = Path3.relative(typesDirectory(ctx), typesPath);
@@ -1157,28 +1167,27 @@ function paramsType(path8) {
1157
1167
  })
1158
1168
  );
1159
1169
  }
1160
- function explodeOptionalSegments(path8) {
1161
- let segments = path8.split("/");
1162
- if (segments.length === 0) return [];
1163
- let [first, ...rest] = segments;
1164
- let isOptional = first.endsWith("?");
1165
- let required = first.replace(/\?$/, "");
1166
- if (rest.length === 0) {
1167
- return isOptional ? [required, ""] : [required];
1168
- }
1169
- let restExploded = explodeOptionalSegments(rest.join("/"));
1170
- let result = [];
1171
- result.push(
1172
- ...restExploded.map(
1173
- (subpath) => subpath === "" ? required : [required, subpath].join("/")
1174
- )
1175
- );
1176
- if (isOptional) {
1177
- result.push(...restExploded);
1178
- }
1179
- return result.map(
1180
- (exploded) => path8.startsWith("/") && exploded === "" ? "/" : exploded
1181
- );
1170
+ function expand(fullpath2) {
1171
+ function recurse(segments2, index) {
1172
+ if (index === segments2.length) return [""];
1173
+ const segment = segments2[index];
1174
+ const isOptional = segment.endsWith("?");
1175
+ const isDynamic = segment.startsWith(":");
1176
+ const required = segment.replace(/\?$/, "");
1177
+ const keep = !isOptional || isDynamic;
1178
+ const kept = isDynamic ? segment : required;
1179
+ const withoutSegment = recurse(segments2, index + 1);
1180
+ const withSegment = withoutSegment.map((rest) => [kept, rest].join("/"));
1181
+ if (keep) return withSegment;
1182
+ return [...withoutSegment, ...withSegment];
1183
+ }
1184
+ const segments = fullpath2.split("/");
1185
+ const expanded = /* @__PURE__ */ new Set();
1186
+ for (let result of recurse(segments, 0)) {
1187
+ if (result !== "/") result = result.replace(/\/$/, "");
1188
+ expanded.add(result);
1189
+ }
1190
+ return expanded;
1182
1191
  }
1183
1192
  var import_dedent, Path3, Pathe, t2;
1184
1193
  var init_generate = __esm({
@@ -1392,14 +1401,10 @@ var init_route_chunks = __esm({
1392
1401
  });
1393
1402
 
1394
1403
  // vite/with-props.ts
1395
- var import_dedent2, vmod;
1396
1404
  var init_with_props = __esm({
1397
1405
  "vite/with-props.ts"() {
1398
1406
  "use strict";
1399
- import_dedent2 = __toESM(require("dedent"));
1400
1407
  init_babel();
1401
- init_virtual_module();
1402
- vmod = create("with-props");
1403
1408
  }
1404
1409
  });
1405
1410
 
@@ -1449,7 +1454,7 @@ async function cleanBuildDirectory(viteConfig, ctx) {
1449
1454
  return !relativePath.startsWith("..") && !path6.isAbsolute(relativePath);
1450
1455
  };
1451
1456
  if (viteConfig.build.emptyOutDir ?? isWithinRoot()) {
1452
- await fse.remove(buildDirectory);
1457
+ await (0, import_promises2.rm)(buildDirectory, { force: true, recursive: true });
1453
1458
  }
1454
1459
  }
1455
1460
  async function cleanViteManifests(environmentsOptions, ctx) {
@@ -1462,15 +1467,15 @@ async function cleanViteManifests(environmentsOptions, ctx) {
1462
1467
  );
1463
1468
  await Promise.all(
1464
1469
  viteManifestPaths.map(async (viteManifestPath) => {
1465
- let manifestExists = await fse.pathExists(viteManifestPath);
1470
+ let manifestExists = (0, import_node_fs3.existsSync)(viteManifestPath);
1466
1471
  if (!manifestExists) return;
1467
1472
  if (!ctx.viteManifestEnabled) {
1468
- await fse.remove(viteManifestPath);
1473
+ await (0, import_promises2.rm)(viteManifestPath, { force: true, recursive: true });
1469
1474
  }
1470
1475
  let viteDir = path6.dirname(viteManifestPath);
1471
- let viteDirFiles = await fse.readdir(viteDir);
1476
+ let viteDirFiles = await (0, import_promises2.readdir)(viteDir, { recursive: true });
1472
1477
  if (viteDirFiles.length === 0) {
1473
- await fse.remove(viteDir);
1478
+ await (0, import_promises2.rm)(viteDir, { force: true, recursive: true });
1474
1479
  }
1475
1480
  })
1476
1481
  );
@@ -1536,13 +1541,13 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
1536
1541
  },
1537
1542
  build: {
1538
1543
  // We move SSR-only assets to client assets. Note that the
1539
- // SSR build can also emit code-split JS files (e.g. by
1544
+ // SSR build can also emit code-split JS files (e.g., by
1540
1545
  // dynamic import) under the same assets directory
1541
1546
  // regardless of "ssrEmitAssets" option, so we also need to
1542
- // keep these JS files have to be kept as-is.
1547
+ // keep these JS files to be kept as-is.
1543
1548
  ssrEmitAssets: true,
1544
1549
  copyPublicDir: false,
1545
- // Assets in the public directory are only used by the client
1550
+ // The client only uses assets in the public directory
1546
1551
  rollupOptions: {
1547
1552
  input: (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi ? viteUserConfig.environments?.ssr?.build?.rollupOptions?.input : viteUserConfig.build?.rollupOptions?.input) ?? virtual.serverBuild.id,
1548
1553
  output: {
@@ -1566,7 +1571,7 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
1566
1571
  route.file
1567
1572
  );
1568
1573
  let isRootRoute = route.file === ctx.reactRouterConfig.routes.root.file;
1569
- let code = fse.readFileSync(routeFilePath, "utf-8");
1574
+ let code = (0, import_node_fs3.readFileSync)(routeFilePath, "utf-8");
1570
1575
  return [
1571
1576
  `${routeFilePath}${BUILD_CLIENT_ROUTE_QUERY_STRING}`,
1572
1577
  ...ctx.reactRouterConfig.future.unstable_splitRouteModules && !isRootRoute ? routeChunkExportNames.map(
@@ -1635,18 +1640,19 @@ function resolveEnvironmentsOptions(environmentResolvers, resolverOptions) {
1635
1640
  function isNonNullable(x) {
1636
1641
  return x != null;
1637
1642
  }
1638
- var import_node_crypto, fs4, path6, url, fse, babel2, import_react_router2, import_es_module_lexer, import_pick3, import_jsesc, import_picocolors4, import_kebabCase, CLIENT_NON_COMPONENT_EXPORTS, CLIENT_ROUTE_EXPORTS, BUILD_CLIENT_ROUTE_QUERY_STRING, SSR_BUNDLE_PREFIX, virtualHmrRuntime, virtualInjectHmrRuntime, virtual, getServerBuildDirectory, getClientBuildDirectory, defaultEntriesDir, defaultEntries, REACT_REFRESH_HEADER;
1643
+ var import_node_crypto, import_node_fs3, import_promises2, path6, url, babel2, import_react_router2, import_es_module_lexer, import_tinyglobby, import_pick3, import_jsesc, import_picocolors4, import_kebabCase, CLIENT_NON_COMPONENT_EXPORTS, CLIENT_ROUTE_EXPORTS, BUILD_CLIENT_ROUTE_QUERY_STRING, SSR_BUNDLE_PREFIX, virtualHmrRuntime, virtualInjectHmrRuntime, virtual, getServerBuildDirectory, getClientBuildDirectory, defaultEntriesDir, defaultEntries, REACT_REFRESH_HEADER;
1639
1644
  var init_plugin = __esm({
1640
1645
  "vite/plugin.ts"() {
1641
1646
  "use strict";
1642
1647
  import_node_crypto = require("crypto");
1643
- fs4 = __toESM(require("fs"));
1648
+ import_node_fs3 = require("fs");
1649
+ import_promises2 = require("fs/promises");
1644
1650
  path6 = __toESM(require("path"));
1645
1651
  url = __toESM(require("url"));
1646
- fse = __toESM(require("fs-extra"));
1647
1652
  babel2 = __toESM(require("@babel/core"));
1648
1653
  import_react_router2 = require("react-router");
1649
1654
  import_es_module_lexer = require("es-module-lexer");
1655
+ import_tinyglobby = require("tinyglobby");
1650
1656
  import_pick3 = __toESM(require("lodash/pick"));
1651
1657
  import_jsesc = __toESM(require("jsesc"));
1652
1658
  import_picocolors4 = __toESM(require("picocolors"));
@@ -1702,7 +1708,9 @@ var init_plugin = __esm({
1702
1708
  "config",
1703
1709
  "defaults"
1704
1710
  );
1705
- defaultEntries = fse.readdirSync(defaultEntriesDir).map((filename2) => path6.join(defaultEntriesDir, filename2));
1711
+ defaultEntries = (0, import_node_fs3.readdirSync)(defaultEntriesDir).map(
1712
+ (filename2) => path6.join(defaultEntriesDir, filename2)
1713
+ );
1706
1714
  invariant(defaultEntries.length > 0, "No default entries found");
1707
1715
  REACT_REFRESH_HEADER = `
1708
1716
  import RefreshRuntime from "${virtualHmrRuntime.id}";
@@ -1802,7 +1810,7 @@ async function viteAppBuild(root, {
1802
1810
  },
1803
1811
  configResolved(config) {
1804
1812
  let hasReactRouterPlugin = config.plugins.find(
1805
- (plugin2) => plugin2.name === "react-router"
1813
+ (plugin) => plugin.name === "react-router"
1806
1814
  );
1807
1815
  if (!hasReactRouterPlugin) {
1808
1816
  throw new Error(
@@ -1941,7 +1949,7 @@ async function dev(root, {
1941
1949
  clearScreen,
1942
1950
  logLevel
1943
1951
  });
1944
- if (!server.config.plugins.find((plugin2) => plugin2.name === "react-router")) {
1952
+ if (!server.config.plugins.find((plugin) => plugin.name === "react-router")) {
1945
1953
  console.error(
1946
1954
  import_picocolors6.default.red("React Router Vite plugin not found in Vite config")
1947
1955
  );
@@ -1982,8 +1990,9 @@ var import_semver = __toESM(require("semver"));
1982
1990
  var import_picocolors8 = __toESM(require("picocolors"));
1983
1991
 
1984
1992
  // cli/commands.ts
1993
+ var import_node_fs4 = require("fs");
1994
+ var import_promises3 = require("fs/promises");
1985
1995
  var path7 = __toESM(require("path"));
1986
- var import_fs_extra = __toESM(require("fs-extra"));
1987
1996
  var import_package_json2 = __toESM(require("@npmcli/package-json"));
1988
1997
  var import_exit_hook = __toESM(require("exit-hook"));
1989
1998
  var import_picocolors7 = __toESM(require("picocolors"));
@@ -2157,21 +2166,21 @@ async function generateEntry(entry, rootDirectory, flags = {}) {
2157
2166
  let useTypeScript = flags.typescript ?? true;
2158
2167
  let outputExtension = useTypeScript ? "tsx" : "jsx";
2159
2168
  let outputEntry = `${entry}.${outputExtension}`;
2160
- let outputFile2 = path7.resolve(appDirectory, outputEntry);
2169
+ let outputFile = path7.resolve(appDirectory, outputEntry);
2161
2170
  if (!useTypeScript) {
2162
2171
  let javascript = transpile(contents, {
2163
2172
  cwd: rootDirectory,
2164
2173
  filename: isServerEntry ? defaultEntryServer : defaultEntryClient
2165
2174
  });
2166
- await import_fs_extra.default.writeFile(outputFile2, javascript, "utf-8");
2175
+ await (0, import_promises3.writeFile)(outputFile, javascript, "utf-8");
2167
2176
  } else {
2168
- await import_fs_extra.default.writeFile(outputFile2, contents, "utf-8");
2177
+ await (0, import_promises3.writeFile)(outputFile, contents, "utf-8");
2169
2178
  }
2170
2179
  console.log(
2171
2180
  import_picocolors7.default.blue(
2172
2181
  `Entry file ${entry} created at ${path7.relative(
2173
2182
  rootDirectory,
2174
- outputFile2
2183
+ outputFile
2175
2184
  )}.`
2176
2185
  )
2177
2186
  );
@@ -2185,7 +2194,7 @@ function resolveRootDirectory(root, flags) {
2185
2194
  async function checkForEntry(rootDirectory, appDirectory, entries2) {
2186
2195
  for (let entry of entries2) {
2187
2196
  let entryPath = path7.resolve(appDirectory, entry);
2188
- let exists = await import_fs_extra.default.pathExists(entryPath);
2197
+ let exists = (0, import_node_fs4.existsSync)(entryPath);
2189
2198
  if (exists) {
2190
2199
  let relative7 = path7.relative(rootDirectory, entryPath);
2191
2200
  console.error(import_picocolors7.default.red(`Entry file ${relative7} already exists.`));
@@ -2195,12 +2204,12 @@ async function checkForEntry(rootDirectory, appDirectory, entries2) {
2195
2204
  }
2196
2205
  async function createServerEntry(rootDirectory, appDirectory, inputFile) {
2197
2206
  await checkForEntry(rootDirectory, appDirectory, serverEntries);
2198
- let contents = await import_fs_extra.default.readFile(inputFile, "utf-8");
2207
+ let contents = await (0, import_promises3.readFile)(inputFile, "utf-8");
2199
2208
  return contents;
2200
2209
  }
2201
2210
  async function createClientEntry(rootDirectory, appDirectory, inputFile) {
2202
2211
  await checkForEntry(rootDirectory, appDirectory, clientEntries);
2203
- let contents = await import_fs_extra.default.readFile(inputFile, "utf-8");
2212
+ let contents = await (0, import_promises3.readFile)(inputFile, "utf-8");
2204
2213
  return contents;
2205
2214
  }
2206
2215
  async function typegen(root, flags) {
package/dist/config.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v7.6.1
2
+ * @react-router/dev v7.6.3-pre.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
package/dist/routes.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v7.6.1
2
+ * @react-router/dev v7.6.3-pre.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -74,7 +74,12 @@ var routeConfigEntrySchema = v.pipe(
74
74
  return !(typeof value === "object" && value !== null && "then" in value && "catch" in value);
75
75
  }, "Invalid type: Expected object but received a promise. Did you forget to await?"),
76
76
  v.object({
77
- id: v.optional(v.string()),
77
+ id: v.optional(
78
+ v.pipe(
79
+ v.string(),
80
+ v.notValue("root", "A route cannot use the reserved id 'root'.")
81
+ )
82
+ ),
78
83
  path: v.optional(v.string()),
79
84
  index: v.optional(v.boolean()),
80
85
  caseSensitive: v.optional(v.boolean()),
@@ -1,6 +1,6 @@
1
1
  import { UNSAFE_MiddlewareEnabled, unstable_InitialContext, AppLoadContext } from 'react-router';
2
2
  import { Plugin } from 'vite';
3
- import { GetPlatformProxyOptions, PlatformProxy } from 'wrangler';
3
+ import { PlatformProxy, GetPlatformProxyOptions } from 'wrangler';
4
4
 
5
5
  type MaybePromise<T> = T | Promise<T>;
6
6
  type CfProperties = Record<string, unknown>;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v7.6.1
2
+ * @react-router/dev v7.6.3-pre.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -174,11 +174,6 @@ var import_node_fs = __toESM(require("fs"));
174
174
  var import_node_child_process = require("child_process");
175
175
  var import_package_json = __toESM(require("@npmcli/package-json"));
176
176
 
177
- // vite/vite-node.ts
178
- var import_server = require("vite-node/server");
179
- var import_client = require("vite-node/client");
180
- var import_source_map = require("vite-node/source-map");
181
-
182
177
  // vite/ssr-externals.ts
183
178
  var ssrExternals = isReactRouterRepo() ? [
184
179
  // This is only needed within this repo because these packages
@@ -202,6 +197,11 @@ async function createContext({
202
197
  }) {
203
198
  await preloadVite();
204
199
  const vite2 = getVite();
200
+ const [{ ViteNodeServer }, { ViteNodeRunner }, { installSourcemapsSupport }] = await Promise.all([
201
+ import("vite-node/server"),
202
+ import("vite-node/client"),
203
+ import("vite-node/source-map")
204
+ ]);
205
205
  const devServer = await vite2.createServer({
206
206
  root,
207
207
  mode,
@@ -231,11 +231,11 @@ async function createContext({
231
231
  plugins: []
232
232
  });
233
233
  await devServer.pluginContainer.buildStart({});
234
- const server = new import_server.ViteNodeServer(devServer);
235
- (0, import_source_map.installSourcemapsSupport)({
234
+ const server = new ViteNodeServer(devServer);
235
+ installSourcemapsSupport({
236
236
  getSourceMap: (source) => server.getSourceMap(source)
237
237
  });
238
- const runner = new import_client.ViteNodeRunner({
238
+ const runner = new ViteNodeRunner({
239
239
  root: devServer.config.root,
240
240
  base: devServer.config.base,
241
241
  fetchModule(id) {
@@ -269,7 +269,12 @@ var routeConfigEntrySchema = v.pipe(
269
269
  return !(typeof value === "object" && value !== null && "then" in value && "catch" in value);
270
270
  }, "Invalid type: Expected object but received a promise. Did you forget to await?"),
271
271
  v.object({
272
- id: v.optional(v.string()),
272
+ id: v.optional(
273
+ v.pipe(
274
+ v.string(),
275
+ v.notValue("root", "A route cannot use the reserved id 'root'.")
276
+ )
277
+ ),
273
278
  path: v.optional(v.string()),
274
279
  index: v.optional(v.boolean()),
275
280
  caseSensitive: v.optional(v.boolean()),
package/dist/vite.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v7.6.1
2
+ * @react-router/dev v7.6.3-pre.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -46,13 +46,14 @@ module.exports = __toCommonJS(vite_exports);
46
46
 
47
47
  // vite/plugin.ts
48
48
  var import_node_crypto = require("crypto");
49
- var fs3 = __toESM(require("fs"));
49
+ var import_node_fs2 = require("fs");
50
+ var import_promises2 = require("fs/promises");
50
51
  var path5 = __toESM(require("path"));
51
52
  var url = __toESM(require("url"));
52
- var fse = __toESM(require("fs-extra"));
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"));
@@ -68,11 +69,6 @@ var import_node_fs = __toESM(require("fs"));
68
69
  var import_node_child_process = require("child_process");
69
70
  var import_package_json = __toESM(require("@npmcli/package-json"));
70
71
 
71
- // vite/vite-node.ts
72
- var import_server = require("vite-node/server");
73
- var import_client = require("vite-node/client");
74
- var import_source_map = require("vite-node/source-map");
75
-
76
72
  // vite/vite.ts
77
73
  var import_pathe2 = __toESM(require("pathe"));
78
74
 
@@ -140,6 +136,11 @@ async function createContext({
140
136
  }) {
141
137
  await preloadVite();
142
138
  const vite2 = getVite();
139
+ const [{ ViteNodeServer }, { ViteNodeRunner }, { installSourcemapsSupport }] = await Promise.all([
140
+ import("vite-node/server"),
141
+ import("vite-node/client"),
142
+ import("vite-node/source-map")
143
+ ]);
143
144
  const devServer = await vite2.createServer({
144
145
  root,
145
146
  mode,
@@ -169,11 +170,11 @@ async function createContext({
169
170
  plugins: []
170
171
  });
171
172
  await devServer.pluginContainer.buildStart({});
172
- const server = new import_server.ViteNodeServer(devServer);
173
- (0, import_source_map.installSourcemapsSupport)({
173
+ const server = new ViteNodeServer(devServer);
174
+ installSourcemapsSupport({
174
175
  getSourceMap: (source) => server.getSourceMap(source)
175
176
  });
176
- const runner = new import_client.ViteNodeRunner({
177
+ const runner = new ViteNodeRunner({
177
178
  root: devServer.config.root,
178
179
  base: devServer.config.base,
179
180
  fetchModule(id) {
@@ -207,7 +208,12 @@ var routeConfigEntrySchema = v.pipe(
207
208
  return !(typeof value === "object" && value !== null && "then" in value && "catch" in value);
208
209
  }, "Invalid type: Expected object but received a promise. Did you forget to await?"),
209
210
  v.object({
210
- id: v.optional(v.string()),
211
+ id: v.optional(
212
+ v.pipe(
213
+ v.string(),
214
+ v.notValue("root", "A route cannot use the reserved id 'root'.")
215
+ )
216
+ ),
211
217
  path: v.optional(v.string()),
212
218
  index: v.optional(v.boolean()),
213
219
  caseSensitive: v.optional(v.boolean()),
@@ -684,22 +690,22 @@ async function resolveEntryFiles({
684
690
  let userEntryServerFile = findEntry(appDirectory, "entry.server");
685
691
  let entryServerFile;
686
692
  let entryClientFile = userEntryClientFile || "entry.client.tsx";
687
- let packageJsonPath = findEntry(rootDirectory, "package", {
688
- extensions: [".json"],
689
- absolute: true,
690
- walkParents: true
691
- });
692
- if (!packageJsonPath) {
693
- throw new Error(
694
- `Could not find package.json in ${rootDirectory} or any of its parent directories`
695
- );
696
- }
697
- let packageJsonDirectory = import_pathe3.default.dirname(packageJsonPath);
698
- let pkgJson = await import_package_json.default.load(packageJsonDirectory);
699
- let deps = pkgJson.content.dependencies ?? {};
700
693
  if (userEntryServerFile) {
701
694
  entryServerFile = userEntryServerFile;
702
695
  } else {
696
+ let packageJsonPath = findEntry(rootDirectory, "package", {
697
+ extensions: [".json"],
698
+ absolute: true,
699
+ walkParents: true
700
+ });
701
+ if (!packageJsonPath) {
702
+ throw new Error(
703
+ `Could not find package.json in ${rootDirectory} or any of its parent directories. Please add a package.json, or provide a custom entry.server.tsx/jsx file in your app directory.`
704
+ );
705
+ }
706
+ let packageJsonDirectory = import_pathe3.default.dirname(packageJsonPath);
707
+ let pkgJson = await import_package_json.default.load(packageJsonDirectory);
708
+ let deps = pkgJson.content.dependencies ?? {};
703
709
  if (!deps["@react-router/node"]) {
704
710
  throw new Error(
705
711
  `Could not determine server runtime. Please install @react-router/node, or provide a custom entry.server.tsx/jsx file in your app directory.`
@@ -915,7 +921,7 @@ function generateRoutes(ctx) {
915
921
  lineages.set(route.id, lineage2);
916
922
  const fullpath2 = fullpath(lineage2);
917
923
  if (!fullpath2) continue;
918
- const pages = explodeOptionalSegments(fullpath2);
924
+ const pages = expand(fullpath2);
919
925
  pages.forEach((page) => allPages.add(page));
920
926
  lineage2.forEach(({ id }) => {
921
927
  let routePages = routeToPages.get(id);
@@ -1123,9 +1129,13 @@ function getRouteAnnotations({
1123
1129
  }
1124
1130
  function relativeImportSource(from, to) {
1125
1131
  let path6 = Path3.relative(Path3.dirname(from), to);
1132
+ let extension = Path3.extname(path6);
1126
1133
  path6 = Path3.join(Path3.dirname(path6), Pathe.filename(path6));
1127
1134
  if (!path6.startsWith("../")) path6 = "./" + path6;
1128
- return path6 + ".js";
1135
+ if (!extension || /\.(js|ts)x?$/.test(extension)) {
1136
+ extension = ".js";
1137
+ }
1138
+ return path6 + extension;
1129
1139
  }
1130
1140
  function rootDirsPath(ctx, typesPath) {
1131
1141
  const rel = Path3.relative(typesDirectory(ctx), typesPath);
@@ -1144,28 +1154,27 @@ function paramsType(path6) {
1144
1154
  })
1145
1155
  );
1146
1156
  }
1147
- function explodeOptionalSegments(path6) {
1148
- let segments = path6.split("/");
1149
- if (segments.length === 0) return [];
1150
- let [first, ...rest] = segments;
1151
- let isOptional = first.endsWith("?");
1152
- let required = first.replace(/\?$/, "");
1153
- if (rest.length === 0) {
1154
- return isOptional ? [required, ""] : [required];
1157
+ function expand(fullpath2) {
1158
+ function recurse(segments2, index) {
1159
+ if (index === segments2.length) return [""];
1160
+ const segment = segments2[index];
1161
+ const isOptional = segment.endsWith("?");
1162
+ const isDynamic = segment.startsWith(":");
1163
+ const required = segment.replace(/\?$/, "");
1164
+ const keep = !isOptional || isDynamic;
1165
+ const kept = isDynamic ? segment : required;
1166
+ const withoutSegment = recurse(segments2, index + 1);
1167
+ const withSegment = withoutSegment.map((rest) => [kept, rest].join("/"));
1168
+ if (keep) return withSegment;
1169
+ return [...withoutSegment, ...withSegment];
1155
1170
  }
1156
- let restExploded = explodeOptionalSegments(rest.join("/"));
1157
- let result = [];
1158
- result.push(
1159
- ...restExploded.map(
1160
- (subpath) => subpath === "" ? required : [required, subpath].join("/")
1161
- )
1162
- );
1163
- if (isOptional) {
1164
- result.push(...restExploded);
1171
+ const segments = fullpath2.split("/");
1172
+ const expanded = /* @__PURE__ */ new Set();
1173
+ for (let result of recurse(segments, 0)) {
1174
+ if (result !== "/") result = result.replace(/\/$/, "");
1175
+ expanded.add(result);
1165
1176
  }
1166
- return result.map(
1167
- (exploded) => path6.startsWith("/") && exploded === "" ? "/" : exploded
1168
- );
1177
+ return expanded;
1169
1178
  }
1170
1179
 
1171
1180
  // typegen/index.ts
@@ -2207,59 +2216,11 @@ function getRouteChunkNameFromModuleId(id) {
2207
2216
  }
2208
2217
 
2209
2218
  // vite/with-props.ts
2210
- var import_dedent2 = __toESM(require("dedent"));
2211
- var vmod = create("with-props");
2212
- var NAMED_COMPONENT_EXPORTS = ["HydrateFallback", "ErrorBoundary"];
2213
- var plugin = {
2214
- name: "react-router-with-props",
2215
- enforce: "pre",
2216
- resolveId(id) {
2217
- if (id === vmod.id) return vmod.resolvedId;
2218
- },
2219
- async load(id) {
2220
- if (id !== vmod.resolvedId) return;
2221
- return import_dedent2.default`
2222
- import { createElement as h } from "react";
2223
- import { useActionData, useLoaderData, useMatches, useParams, useRouteError } from "react-router";
2224
-
2225
- export function withComponentProps(Component) {
2226
- return function Wrapped() {
2227
- const props = {
2228
- params: useParams(),
2229
- loaderData: useLoaderData(),
2230
- actionData: useActionData(),
2231
- matches: useMatches(),
2232
- };
2233
- return h(Component, props);
2234
- };
2235
- }
2236
-
2237
- export function withHydrateFallbackProps(HydrateFallback) {
2238
- return function Wrapped() {
2239
- const props = {
2240
- params: useParams(),
2241
- loaderData: useLoaderData(),
2242
- actionData: useActionData(),
2243
- };
2244
- return h(HydrateFallback, props);
2245
- };
2246
- }
2247
-
2248
- export function withErrorBoundaryProps(ErrorBoundary) {
2249
- return function Wrapped() {
2250
- const props = {
2251
- params: useParams(),
2252
- loaderData: useLoaderData(),
2253
- actionData: useActionData(),
2254
- error: useRouteError(),
2255
- };
2256
- return h(ErrorBoundary, props);
2257
- };
2258
- }
2259
- `;
2260
- }
2261
- };
2262
- var transform = (ast) => {
2219
+ var namedComponentExports = ["HydrateFallback", "ErrorBoundary"];
2220
+ function isNamedComponentExport(name) {
2221
+ return namedComponentExports.includes(name);
2222
+ }
2223
+ var decorateComponentExportsWithProps = (ast) => {
2263
2224
  const hocs = [];
2264
2225
  function getHocUid(path6, hocName) {
2265
2226
  const uid = path6.scope.generateUidIdentifier(hocName);
@@ -2272,7 +2233,7 @@ var transform = (ast) => {
2272
2233
  const declaration = path6.get("declaration");
2273
2234
  const expr = declaration.isExpression() ? declaration.node : declaration.isFunctionDeclaration() ? toFunctionExpression(declaration.node) : void 0;
2274
2235
  if (expr) {
2275
- const uid = getHocUid(path6, "withComponentProps");
2236
+ const uid = getHocUid(path6, "UNSAFE_withComponentProps");
2276
2237
  declaration.replaceWith(t.callExpression(uid, [expr]));
2277
2238
  }
2278
2239
  return;
@@ -2287,8 +2248,8 @@ var transform = (ast) => {
2287
2248
  if (!expr) return;
2288
2249
  if (!id.isIdentifier()) return;
2289
2250
  const { name } = id.node;
2290
- if (!NAMED_COMPONENT_EXPORTS.includes(name)) return;
2291
- const uid = getHocUid(path6, `with${name}Props`);
2251
+ if (!isNamedComponentExport(name)) return;
2252
+ const uid = getHocUid(path6, `UNSAFE_with${name}Props`);
2292
2253
  init.replaceWith(t.callExpression(uid, [expr]));
2293
2254
  });
2294
2255
  return;
@@ -2297,8 +2258,8 @@ var transform = (ast) => {
2297
2258
  const { id } = decl.node;
2298
2259
  if (!id) return;
2299
2260
  const { name } = id;
2300
- if (!NAMED_COMPONENT_EXPORTS.includes(name)) return;
2301
- const uid = getHocUid(path6, `with${name}Props`);
2261
+ if (!isNamedComponentExport(name)) return;
2262
+ const uid = getHocUid(path6, `UNSAFE_with${name}Props`);
2302
2263
  decl.replaceWith(
2303
2264
  t.variableDeclaration("const", [
2304
2265
  t.variableDeclarator(
@@ -2317,7 +2278,7 @@ var transform = (ast) => {
2317
2278
  hocs.map(
2318
2279
  ([name, identifier]) => t.importSpecifier(identifier, t.identifier(name))
2319
2280
  ),
2320
- t.stringLiteral(vmod.id)
2281
+ t.stringLiteral("react-router")
2321
2282
  )
2322
2283
  );
2323
2284
  }
@@ -2414,8 +2375,8 @@ var virtual = {
2414
2375
  browserManifest: create("browser-manifest")
2415
2376
  };
2416
2377
  var invalidateVirtualModules = (viteDevServer) => {
2417
- Object.values(virtual).forEach((vmod2) => {
2418
- let mod = viteDevServer.moduleGraph.getModuleById(vmod2.resolvedId);
2378
+ Object.values(virtual).forEach((vmod) => {
2379
+ let mod = viteDevServer.moduleGraph.getModuleById(vmod.resolvedId);
2419
2380
  if (mod) {
2420
2381
  viteDevServer.moduleGraph.invalidateModule(mod);
2421
2382
  }
@@ -2492,8 +2453,8 @@ function dedupe(array2) {
2492
2453
  return [...new Set(array2)];
2493
2454
  }
2494
2455
  var writeFileSafe = async (file, contents) => {
2495
- await fse.ensureDir(path5.dirname(file));
2496
- await fse.writeFile(file, contents);
2456
+ await (0, import_promises2.mkdir)(path5.dirname(file), { recursive: true });
2457
+ await (0, import_promises2.writeFile)(file, contents);
2497
2458
  };
2498
2459
  var getExportNames = (code) => {
2499
2460
  let [, exportSpecifiers] = (0, import_es_module_lexer.parse)(code);
@@ -2527,7 +2488,7 @@ var compileRouteFile = async (viteChildCompiler, ctx, routeFile, readRouteFile)
2527
2488
  };
2528
2489
  let [id, code] = await Promise.all([
2529
2490
  resolveId(),
2530
- readRouteFile?.() ?? fse.readFile(routePath, "utf-8"),
2491
+ readRouteFile?.() ?? (0, import_promises2.readFile)(routePath, "utf-8"),
2531
2492
  // pluginContainer.transform(...) fails if we don't do this first:
2532
2493
  moduleGraph.ensureEntryFromUrl(url2, ssr)
2533
2494
  ]);
@@ -2589,7 +2550,9 @@ var defaultEntriesDir = path5.resolve(
2589
2550
  "config",
2590
2551
  "defaults"
2591
2552
  );
2592
- var defaultEntries = fse.readdirSync(defaultEntriesDir).map((filename2) => path5.join(defaultEntriesDir, filename2));
2553
+ var defaultEntries = (0, import_node_fs2.readdirSync)(defaultEntriesDir).map(
2554
+ (filename2) => path5.join(defaultEntriesDir, filename2)
2555
+ );
2593
2556
  invariant(defaultEntries.length > 0, "No default entries found");
2594
2557
  var reactRouterDevLoadContext = () => void 0;
2595
2558
  var reactRouterVitePlugin = () => {
@@ -2649,7 +2612,7 @@ var reactRouterVitePlugin = () => {
2649
2612
  };
2650
2613
  let pluginIndex = (pluginName) => {
2651
2614
  invariant(viteConfig);
2652
- return viteConfig.plugins.findIndex((plugin2) => plugin2.name === pluginName);
2615
+ return viteConfig.plugins.findIndex((plugin) => plugin.name === pluginName);
2653
2616
  };
2654
2617
  let getServerEntry = async ({ routeIds }) => {
2655
2618
  invariant(viteConfig, "viteconfig required to generate the server entry");
@@ -2726,7 +2689,7 @@ var reactRouterVitePlugin = () => {
2726
2689
  ` : ""}`;
2727
2690
  };
2728
2691
  let loadViteManifest = async (directory) => {
2729
- let manifestContents = await fse.readFile(
2692
+ let manifestContents = await (0, import_promises2.readFile)(
2730
2693
  path5.resolve(directory, ".vite", "manifest.json"),
2731
2694
  "utf-8"
2732
2695
  );
@@ -2748,7 +2711,7 @@ var reactRouterVitePlugin = () => {
2748
2711
  };
2749
2712
  let generateSriManifest = async (ctx2) => {
2750
2713
  let clientBuildDirectory = getClientBuildDirectory(ctx2.reactRouterConfig);
2751
- let entries = fs3.readdirSync(clientBuildDirectory, {
2714
+ let entries = (0, import_node_fs2.readdirSync)(clientBuildDirectory, {
2752
2715
  withFileTypes: true,
2753
2716
  recursive: true
2754
2717
  });
@@ -2758,7 +2721,7 @@ var reactRouterVitePlugin = () => {
2758
2721
  const entryNormalizedPath = "parentPath" in entry && typeof entry.parentPath === "string" ? entry.parentPath : entry.path;
2759
2722
  let contents;
2760
2723
  try {
2761
- contents = await fse.readFile(
2724
+ contents = await (0, import_promises2.readFile)(
2762
2725
  path5.join(entryNormalizedPath, entry.name),
2763
2726
  "utf-8"
2764
2727
  );
@@ -3014,6 +2977,7 @@ var reactRouterVitePlugin = () => {
3014
2977
  config: async (_viteUserConfig, _viteConfigEnv) => {
3015
2978
  await preloadVite();
3016
2979
  let vite2 = getVite();
2980
+ let viteMajorVersion = parseInt(vite2.version.split(".")[0], 10);
3017
2981
  viteUserConfig = _viteUserConfig;
3018
2982
  viteConfigEnv = _viteConfigEnv;
3019
2983
  viteCommand = viteConfigEnv.command;
@@ -3043,7 +3007,7 @@ var reactRouterVitePlugin = () => {
3043
3007
  vite2.loadEnv(
3044
3008
  viteConfigEnv.mode,
3045
3009
  viteUserConfig.envDir ?? ctx.rootDirectory,
3046
- // We override default prefix of "VITE_" with a blank string since
3010
+ // We override the default prefix of "VITE_" with a blank string since
3047
3011
  // we're targeting the server, so we want to load all environment
3048
3012
  // variables, not just those explicitly marked for the client
3049
3013
  ""
@@ -3072,7 +3036,13 @@ var reactRouterVitePlugin = () => {
3072
3036
  ...Object.values(ctx.reactRouterConfig.routes).map(
3073
3037
  (route) => resolveRelativeRouteFilePath(route, ctx.reactRouterConfig)
3074
3038
  )
3075
- ] : [],
3039
+ ].map(
3040
+ (entry) => (
3041
+ // In Vite 7, the `optimizeDeps.entries` option only accepts glob patterns.
3042
+ // In prior versions, absolute file paths were treated differently.
3043
+ viteMajorVersion >= 7 ? (0, import_tinyglobby.escapePath)(entry) : entry
3044
+ )
3045
+ ) : [],
3076
3046
  include: [
3077
3047
  // Pre-bundle React dependencies to avoid React duplicates,
3078
3048
  // even if React dependencies are not direct dependencies.
@@ -3107,7 +3077,7 @@ var reactRouterVitePlugin = () => {
3107
3077
  conditions: viteCommand === "build" ? viteClientConditions : ["development", ...viteClientConditions]
3108
3078
  },
3109
3079
  base: viteUserConfig.base,
3110
- // When consumer provides an allow list for files that can be read by
3080
+ // When consumer provides an allowlist for files that can be read by
3111
3081
  // the server, ensure that the default entry files are included.
3112
3082
  // If we don't do this and a default entry file is used, the server
3113
3083
  // will throw an error that the file is not allowed to be read.
@@ -3235,9 +3205,9 @@ var reactRouterVitePlugin = () => {
3235
3205
  envFile: false,
3236
3206
  plugins: [
3237
3207
  childCompilerPlugins.filter(
3238
- (plugin2) => typeof plugin2 === "object" && plugin2 !== null && "name" in plugin2 && plugin2.name !== "react-router" && plugin2.name !== "react-router:route-exports" && plugin2.name !== "react-router:hmr-updates"
3239
- ).map((plugin2) => ({
3240
- ...plugin2,
3208
+ (plugin) => typeof plugin === "object" && plugin !== null && "name" in plugin && plugin.name !== "react-router" && plugin.name !== "react-router:route-exports" && plugin.name !== "react-router:hmr-updates"
3209
+ ).map((plugin) => ({
3210
+ ...plugin,
3241
3211
  configureServer: void 0,
3242
3212
  configurePreviewServer: void 0
3243
3213
  }))
@@ -3319,7 +3289,7 @@ var reactRouterVitePlugin = () => {
3319
3289
  if (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi) {
3320
3290
  viteDevServer.middlewares.use(async (req, res, next) => {
3321
3291
  let [reqPathname, reqSearch] = (req.url ?? "").split("?");
3322
- if (reqPathname === `${ctx.publicPath}@react-router/critical.css`) {
3292
+ if (reqPathname.endsWith("/@react-router/critical.css")) {
3323
3293
  let pathname = new URLSearchParams(reqSearch).get("pathname");
3324
3294
  if (!pathname) {
3325
3295
  return next("No pathname provided");
@@ -3399,15 +3369,15 @@ var reactRouterVitePlugin = () => {
3399
3369
  let src = path5.join(serverBuildDirectory, ssrAssetPath);
3400
3370
  let dest = path5.join(clientBuildDirectory, ssrAssetPath);
3401
3371
  if (!userSsrEmitAssets) {
3402
- if (!fse.existsSync(dest)) {
3403
- await fse.move(src, dest);
3372
+ if (!(0, import_node_fs2.existsSync)(dest)) {
3373
+ await (0, import_promises2.rename)(src, dest);
3404
3374
  movedAssetPaths.push(dest);
3405
3375
  } else {
3406
- await fse.remove(src);
3376
+ await (0, import_promises2.rm)(src, { force: true, recursive: true });
3407
3377
  removedAssetPaths.push(dest);
3408
3378
  }
3409
- } else if (!fse.existsSync(dest)) {
3410
- await fse.copy(src, dest);
3379
+ } else if (!(0, import_node_fs2.existsSync)(dest)) {
3380
+ await (0, import_promises2.cp)(src, dest, { recursive: true });
3411
3381
  copiedAssetPaths.push(dest);
3412
3382
  }
3413
3383
  }
@@ -3418,7 +3388,7 @@ var reactRouterVitePlugin = () => {
3418
3388
  await Promise.all(
3419
3389
  ssrCssPaths.map(async (cssPath) => {
3420
3390
  let src = path5.join(serverBuildDirectory, cssPath);
3421
- await fse.remove(src);
3391
+ await (0, import_promises2.rm)(src, { force: true, recursive: true });
3422
3392
  removedAssetPaths.push(src);
3423
3393
  })
3424
3394
  );
@@ -3429,9 +3399,9 @@ var reactRouterVitePlugin = () => {
3429
3399
  await Promise.all(
3430
3400
  Array.from(cleanedAssetDirs).map(async (dir) => {
3431
3401
  try {
3432
- const files = await fse.readdir(dir);
3402
+ const files = await (0, import_promises2.readdir)(dir, { recursive: true });
3433
3403
  if (files.length === 0) {
3434
- await fse.remove(dir);
3404
+ await (0, import_promises2.rm)(dir, { force: true, recursive: true });
3435
3405
  }
3436
3406
  } catch {
3437
3407
  }
@@ -3495,7 +3465,7 @@ var reactRouterVitePlugin = () => {
3495
3465
  "due to ssr:false"
3496
3466
  ].join(" ")
3497
3467
  );
3498
- fse.removeSync(serverBuildDirectory);
3468
+ (0, import_node_fs2.rmSync)(serverBuildDirectory, { force: true, recursive: true });
3499
3469
  }
3500
3470
  }
3501
3471
  },
@@ -3513,7 +3483,7 @@ var reactRouterVitePlugin = () => {
3513
3483
  // primarily ensures code is never duplicated across a route module and
3514
3484
  // its chunks. If we didn't have this plugin, any app that explicitly
3515
3485
  // imports a route module would result in duplicate code since the app
3516
- // would contain code for both the unprocessed route module as well as its
3486
+ // would contain code for both the unprocessed route module and its
3517
3487
  // individual chunks. This is because, since they have different module
3518
3488
  // IDs, they are treated as completely separate modules even though they
3519
3489
  // all reference the same underlying file. This plugin addresses this by
@@ -3627,8 +3597,8 @@ var reactRouterVitePlugin = () => {
3627
3597
  name: "react-router:virtual-modules",
3628
3598
  enforce: "pre",
3629
3599
  resolveId(id) {
3630
- const vmod2 = Object.values(virtual).find((vmod3) => vmod3.id === id);
3631
- if (vmod2) return vmod2.resolvedId;
3600
+ const vmod = Object.values(virtual).find((vmod2) => vmod2.id === id);
3601
+ if (vmod) return vmod.resolvedId;
3632
3602
  },
3633
3603
  async load(id) {
3634
3604
  switch (id) {
@@ -3739,7 +3709,6 @@ var reactRouterVitePlugin = () => {
3739
3709
  }
3740
3710
  }
3741
3711
  },
3742
- plugin,
3743
3712
  {
3744
3713
  name: "react-router:route-exports",
3745
3714
  async transform(code, id, options) {
@@ -3776,7 +3745,7 @@ var reactRouterVitePlugin = () => {
3776
3745
  if (!options?.ssr) {
3777
3746
  removeExports(ast, SERVER_ONLY_ROUTE_EXPORTS);
3778
3747
  }
3779
- transform(ast);
3748
+ decorateComponentExportsWithProps(ast);
3780
3749
  return generate(ast, {
3781
3750
  sourceMaps: true,
3782
3751
  filename: id,
@@ -3820,11 +3789,8 @@ var reactRouterVitePlugin = () => {
3820
3789
  );
3821
3790
  return [
3822
3791
  "const exports = {}",
3823
- await fse.readFile(reactRefreshRuntimePath, "utf8"),
3824
- await fse.readFile(
3825
- require.resolve("./static/refresh-utils.cjs"),
3826
- "utf8"
3827
- ),
3792
+ await (0, import_promises2.readFile)(reactRefreshRuntimePath, "utf8"),
3793
+ await (0, import_promises2.readFile)(require.resolve("./static/refresh-utils.cjs"), "utf8"),
3828
3794
  "export default exports"
3829
3795
  ].join("\n");
3830
3796
  }
@@ -3907,10 +3873,10 @@ var reactRouterVitePlugin = () => {
3907
3873
  {
3908
3874
  name: "react-router-server-change-trigger-client-hmr",
3909
3875
  // This hook is only available in Vite v6+ so this is a no-op in v5.
3910
- // Previously the server and client modules were shared in a single module
3876
+ // Previously, the server and client modules were shared in a single module
3911
3877
  // graph. This meant that changes to server code automatically resulted in
3912
- // client HMR updates. In Vite v6+ these module graphs are separate from
3913
- // each other so we need to manually trigger client HMR updates if server
3878
+ // client HMR updates. In Vite v6+, these module graphs are separate from
3879
+ // each other, so we need to manually trigger client HMR updates if server
3914
3880
  // code has changed.
3915
3881
  hotUpdate({ server, modules }) {
3916
3882
  if (this.environment.name !== "ssr" && modules.length <= 0) {
@@ -4104,7 +4070,7 @@ async function handleSpaMode(viteConfig, reactRouterConfig, serverBuildDirectory
4104
4070
  "SPA Mode: Did you forget to include `<Scripts/>` in your root route? Your pre-rendered HTML cannot hydrate without `<Scripts />`."
4105
4071
  );
4106
4072
  }
4107
- await fse.writeFile(path5.join(clientBuildDirectory, filename2), html);
4073
+ await (0, import_promises2.writeFile)(path5.join(clientBuildDirectory, filename2), html);
4108
4074
  let prettyDir = path5.relative(process.cwd(), clientBuildDirectory);
4109
4075
  let prettyPath = path5.join(prettyDir, filename2);
4110
4076
  if (build.prerender.length > 0) {
@@ -4235,8 +4201,8 @@ ${normalizedPath}`
4235
4201
  }
4236
4202
  let outdir = path5.relative(process.cwd(), clientBuildDirectory);
4237
4203
  let outfile = path5.join(outdir, ...normalizedPath.split("/"));
4238
- await fse.ensureDir(path5.dirname(outfile));
4239
- await fse.outputFile(outfile, data);
4204
+ await (0, import_promises2.mkdir)(path5.dirname(outfile), { recursive: true });
4205
+ await (0, import_promises2.writeFile)(outfile, data);
4240
4206
  viteConfig.logger.info(
4241
4207
  `Prerender (data): ${prerenderPath} -> ${import_picocolors3.default.bold(outfile)}`
4242
4208
  );
@@ -4274,8 +4240,8 @@ ${html}`
4274
4240
  }
4275
4241
  let outdir = path5.relative(process.cwd(), clientBuildDirectory);
4276
4242
  let outfile = path5.join(outdir, ...normalizedPath.split("/"), "index.html");
4277
- await fse.ensureDir(path5.dirname(outfile));
4278
- await fse.outputFile(outfile, html);
4243
+ await (0, import_promises2.mkdir)(path5.dirname(outfile), { recursive: true });
4244
+ await (0, import_promises2.writeFile)(outfile, html);
4279
4245
  viteConfig.logger.info(
4280
4246
  `Prerender (html): ${prerenderPath} -> ${import_picocolors3.default.bold(outfile)}`
4281
4247
  );
@@ -4293,8 +4259,8 @@ ${content.toString("utf8")}`
4293
4259
  }
4294
4260
  let outdir = path5.relative(process.cwd(), clientBuildDirectory);
4295
4261
  let outfile = path5.join(outdir, ...normalizedPath.split("/"));
4296
- await fse.ensureDir(path5.dirname(outfile));
4297
- await fse.outputFile(outfile, content);
4262
+ await (0, import_promises2.mkdir)(path5.dirname(outfile), { recursive: true });
4263
+ await (0, import_promises2.writeFile)(outfile, content);
4298
4264
  viteConfig.logger.info(
4299
4265
  `Prerender (resource): ${prerenderPath} -> ${import_picocolors3.default.bold(outfile)}`
4300
4266
  );
@@ -4547,7 +4513,7 @@ async function cleanBuildDirectory(viteConfig, ctx) {
4547
4513
  return !relativePath.startsWith("..") && !path5.isAbsolute(relativePath);
4548
4514
  };
4549
4515
  if (viteConfig.build.emptyOutDir ?? isWithinRoot()) {
4550
- await fse.remove(buildDirectory);
4516
+ await (0, import_promises2.rm)(buildDirectory, { force: true, recursive: true });
4551
4517
  }
4552
4518
  }
4553
4519
  async function cleanViteManifests(environmentsOptions, ctx) {
@@ -4560,15 +4526,15 @@ async function cleanViteManifests(environmentsOptions, ctx) {
4560
4526
  );
4561
4527
  await Promise.all(
4562
4528
  viteManifestPaths.map(async (viteManifestPath) => {
4563
- let manifestExists = await fse.pathExists(viteManifestPath);
4529
+ let manifestExists = (0, import_node_fs2.existsSync)(viteManifestPath);
4564
4530
  if (!manifestExists) return;
4565
4531
  if (!ctx.viteManifestEnabled) {
4566
- await fse.remove(viteManifestPath);
4532
+ await (0, import_promises2.rm)(viteManifestPath, { force: true, recursive: true });
4567
4533
  }
4568
4534
  let viteDir = path5.dirname(viteManifestPath);
4569
- let viteDirFiles = await fse.readdir(viteDir);
4535
+ let viteDirFiles = await (0, import_promises2.readdir)(viteDir, { recursive: true });
4570
4536
  if (viteDirFiles.length === 0) {
4571
- await fse.remove(viteDir);
4537
+ await (0, import_promises2.rm)(viteDir, { force: true, recursive: true });
4572
4538
  }
4573
4539
  })
4574
4540
  );
@@ -4704,13 +4670,13 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
4704
4670
  },
4705
4671
  build: {
4706
4672
  // We move SSR-only assets to client assets. Note that the
4707
- // SSR build can also emit code-split JS files (e.g. by
4673
+ // SSR build can also emit code-split JS files (e.g., by
4708
4674
  // dynamic import) under the same assets directory
4709
4675
  // regardless of "ssrEmitAssets" option, so we also need to
4710
- // keep these JS files have to be kept as-is.
4676
+ // keep these JS files to be kept as-is.
4711
4677
  ssrEmitAssets: true,
4712
4678
  copyPublicDir: false,
4713
- // Assets in the public directory are only used by the client
4679
+ // The client only uses assets in the public directory
4714
4680
  rollupOptions: {
4715
4681
  input: (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi ? viteUserConfig.environments?.ssr?.build?.rollupOptions?.input : viteUserConfig.build?.rollupOptions?.input) ?? virtual.serverBuild.id,
4716
4682
  output: {
@@ -4734,7 +4700,7 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
4734
4700
  route.file
4735
4701
  );
4736
4702
  let isRootRoute = route.file === ctx.reactRouterConfig.routes.root.file;
4737
- let code = fse.readFileSync(routeFilePath, "utf-8");
4703
+ let code = (0, import_node_fs2.readFileSync)(routeFilePath, "utf-8");
4738
4704
  return [
4739
4705
  `${routeFilePath}${BUILD_CLIENT_ROUTE_QUERY_STRING}`,
4740
4706
  ...ctx.reactRouterConfig.future.unstable_splitRouteModules && !isRootRoute ? routeChunkExportNames.map(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-router/dev",
3
- "version": "7.6.1",
3
+ "version": "7.6.3-pre.0",
4
4
  "description": "Dev tools and CLI for React Router",
5
5
  "homepage": "https://reactrouter.com",
6
6
  "bugs": {
@@ -75,7 +75,6 @@
75
75
  "dedent": "^1.5.3",
76
76
  "es-module-lexer": "^1.3.1",
77
77
  "exit-hook": "2.2.1",
78
- "fs-extra": "^10.0.0",
79
78
  "jsesc": "3.0.2",
80
79
  "lodash": "^4.17.21",
81
80
  "pathe": "^1.1.2",
@@ -84,9 +83,10 @@
84
83
  "react-refresh": "^0.14.0",
85
84
  "semver": "^7.3.7",
86
85
  "set-cookie-parser": "^2.6.0",
86
+ "tinyglobby": "^0.2.14",
87
87
  "valibot": "^0.41.0",
88
- "vite-node": "3.0.0-beta.2",
89
- "@react-router/node": "7.6.1"
88
+ "vite-node": "^3.1.4",
89
+ "@react-router/node": "7.6.3-pre.0"
90
90
  },
91
91
  "devDependencies": {
92
92
  "@types/babel__core": "^7.20.5",
@@ -94,7 +94,6 @@
94
94
  "@types/babel__traverse": "^7.20.5",
95
95
  "@types/dedent": "^0.7.0",
96
96
  "@types/express": "^4.17.9",
97
- "@types/fs-extra": "^8.1.2",
98
97
  "@types/jsesc": "^3.0.1",
99
98
  "@types/lodash": "^4.14.182",
100
99
  "@types/node": "^20.0.0",
@@ -110,15 +109,15 @@
110
109
  "vite": "^6.1.0",
111
110
  "wireit": "0.14.9",
112
111
  "wrangler": "^4.2.0",
113
- "@react-router/serve": "7.6.1",
114
- "react-router": "^7.6.1"
112
+ "@react-router/serve": "7.6.3-pre.0",
113
+ "react-router": "^7.6.3-pre.0"
115
114
  },
116
115
  "peerDependencies": {
117
116
  "typescript": "^5.1.0",
118
- "vite": "^5.1.0 || ^6.0.0",
117
+ "vite": "^5.1.0 || ^6.0.0 || ^7.0.0",
119
118
  "wrangler": "^3.28.2 || ^4.0.0",
120
- "@react-router/serve": "^7.6.1",
121
- "react-router": "^7.6.1"
119
+ "@react-router/serve": "^7.6.3-pre.0",
120
+ "react-router": "^7.6.3-pre.0"
122
121
  },
123
122
  "peerDependenciesMeta": {
124
123
  "@react-router/serve": {