@react-router/dev 7.3.0-pre.1 → 7.4.0-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,37 +1,55 @@
1
1
  # `@react-router/dev`
2
2
 
3
- ## 7.3.0-pre.1
3
+ ## 7.4.0-pre.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Generate types for `virtual:react-router/server-build` module ([#13152](https://github.com/remix-run/react-router/pull/13152))
4
8
 
5
9
  ### Patch Changes
6
10
 
11
+ - When `future.unstable_splitRouteModules` is set to `"enforce"`, allow both splittable and unsplittable root route exports since it's always in a single chunk. ([#13238](https://github.com/remix-run/react-router/pull/13238))
12
+ - When `future.unstable_viteEnvironmentApi` is enabled, allow plugins that override the default SSR environment (such as `@cloudflare/vite-plugin`) to be placed before or after the React Router plugin. ([#13183](https://github.com/remix-run/react-router/pull/13183))
13
+ - Fix conflicts with other Vite plugins that use the `configureServer` and/or `configurePreviewServer` hooks ([#13184](https://github.com/remix-run/react-router/pull/13184))
7
14
  - Updated dependencies:
8
- - `react-router@7.3.0-pre.1`
9
- - `@react-router/node@7.3.0-pre.1`
10
- - `@react-router/serve@7.3.0-pre.1`
15
+ - `react-router@7.4.0-pre.0`
16
+ - `@react-router/node@7.4.0-pre.0`
17
+ - `@react-router/serve@7.4.0-pre.0`
11
18
 
12
- ## 7.3.0-pre.0
19
+ ## 7.3.0
13
20
 
14
21
  ### Patch Changes
15
22
 
16
23
  - Fix support for custom client `build.rollupOptions.output.entryFileNames` ([#13098](https://github.com/remix-run/react-router/pull/13098))
24
+
17
25
  - Fix usage of `prerender` option when `serverBundles` option has been configured or provided by a preset, e.g. `vercelPreset` from `@vercel/react-router` ([#13082](https://github.com/remix-run/react-router/pull/13082))
26
+
18
27
  - Fix support for custom `build.assetsDir` ([#13077](https://github.com/remix-run/react-router/pull/13077))
28
+
19
29
  - Remove unused dependencies ([#13134](https://github.com/remix-run/react-router/pull/13134))
30
+
20
31
  - Stub all routes except root in "SPA Mode" server builds to avoid issues when route modules or their dependencies import non-SSR-friendly modules ([#13023](https://github.com/remix-run/react-router/pull/13023))
32
+
21
33
  - Fix errors with `future.unstable_viteEnvironmentApi` when the `ssr` environment has been configured by another plugin to be a custom `Vite.DevEnvironment` rather than the default `Vite.RunnableDevEnvironment` ([#13008](https://github.com/remix-run/react-router/pull/13008))
34
+
22
35
  - Remove unused Vite file system watcher ([#13133](https://github.com/remix-run/react-router/pull/13133))
36
+
23
37
  - Fix support for custom SSR build input when `serverBundles` option has been configured ([#13107](https://github.com/remix-run/react-router/pull/13107))
24
38
 
25
39
  Note that for consumers using the `future.unstable_viteEnvironmentApi` and `serverBundles` options together, hyphens are no longer supported in server bundle IDs since they also need to be valid Vite environment names.
26
40
 
27
41
  - Fix dev server when using HTTPS by stripping HTTP/2 pseudo headers from dev server requests ([#12830](https://github.com/remix-run/react-router/pull/12830))
42
+
28
43
  - Lazy load Cloudflare platform proxy on first dev server request when using the `cloudflareDevProxy` Vite plugin to avoid creating unnecessary workerd processes ([#13016](https://github.com/remix-run/react-router/pull/13016))
44
+
29
45
  - When `future.unstable_viteEnvironmentApi` is enabled and the `ssr` environment has `optimizeDeps.noDiscovery` disabled, define `optimizeDeps.entries` and `optimizeDeps.include` ([#13007](https://github.com/remix-run/react-router/pull/13007))
46
+
30
47
  - Fix duplicated entries in typegen for layout routes and their corresponding index route ([#13140](https://github.com/remix-run/react-router/pull/13140))
48
+
31
49
  - Updated dependencies:
32
- - `react-router@7.3.0-pre.0`
33
- - `@react-router/node@7.3.0-pre.0`
34
- - `@react-router/serve@7.3.0-pre.0`
50
+ - `react-router@7.3.0`
51
+ - `@react-router/node@7.3.0`
52
+ - `@react-router/serve@7.3.0`
35
53
 
36
54
  ## 7.2.0
37
55
 
package/dist/cli/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * @react-router/dev v7.3.0-pre.1
3
+ * @react-router/dev v7.4.0-pre.0
4
4
  *
5
5
  * Copyright (c) Remix Software Inc.
6
6
  *
@@ -860,6 +860,8 @@ async function writeAll(ctx) {
860
860
  });
861
861
  const registerPath = Path4.join(typegenDir, "+register.ts");
862
862
  import_node_fs3.default.writeFileSync(registerPath, register(ctx));
863
+ const virtualPath = Path4.join(typegenDir, "+virtual.ts");
864
+ import_node_fs3.default.writeFileSync(virtualPath, virtual);
863
865
  }
864
866
  function register(ctx) {
865
867
  const register2 = import_dedent2.default`
@@ -905,7 +907,7 @@ function register(ctx) {
905
907
  );
906
908
  return [register2, generate(typeParams).code].join("\n\n");
907
909
  }
908
- var import_node_fs3, import_dedent2, Path4, import_picocolors3;
910
+ var import_node_fs3, import_dedent2, Path4, import_picocolors3, virtual;
909
911
  var init_typegen = __esm({
910
912
  "typegen/index.ts"() {
911
913
  "use strict";
@@ -919,6 +921,22 @@ var init_typegen = __esm({
919
921
  init_paths();
920
922
  init_params();
921
923
  init_route();
924
+ virtual = import_dedent2.default`
925
+ declare module "virtual:react-router/server-build" {
926
+ import { ServerBuild } from "react-router";
927
+ export const assets: ServerBuild["assets"];
928
+ export const assetsBuildDirectory: ServerBuild["assetsBuildDirectory"];
929
+ export const basename: ServerBuild["basename"];
930
+ export const entry: ServerBuild["entry"];
931
+ export const future: ServerBuild["future"];
932
+ export const isSpaMode: ServerBuild["isSpaMode"];
933
+ export const prerender: ServerBuild["prerender"];
934
+ export const publicPath: ServerBuild["publicPath"];
935
+ export const routes: ServerBuild["routes"];
936
+ export const ssr: ServerBuild["ssr"];
937
+ export const unstable_getCriticalCss: ServerBuild["unstable_getCriticalCss"];
938
+ }
939
+ `;
922
940
  }
923
941
  });
924
942
 
@@ -1080,12 +1098,12 @@ async function resolveViteConfig({
1080
1098
  function extractPluginContext(viteConfig) {
1081
1099
  return viteConfig["__reactRouterPluginContext"];
1082
1100
  }
1083
- function isSeverBundleEnvironmentName(name) {
1101
+ function isSsrBundleEnvironmentName(name) {
1084
1102
  return name.startsWith(SSR_BUNDLE_PREFIX);
1085
1103
  }
1086
1104
  function getServerEnvironmentEntries(ctx, record) {
1087
1105
  return Object.entries(record).filter(
1088
- ([name]) => ctx.buildManifest?.serverBundles ? isSeverBundleEnvironmentName(name) : name === "ssr"
1106
+ ([name]) => ctx.buildManifest?.serverBundles ? isSsrBundleEnvironmentName(name) : name === "ssr"
1089
1107
  );
1090
1108
  }
1091
1109
  function getServerEnvironmentKeys(ctx, record) {
@@ -1179,13 +1197,8 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
1179
1197
  return mergeEnvironmentOptions(getBaseOptions({ viteUserConfig }), {
1180
1198
  resolve: {
1181
1199
  external: (
1182
- // This check is required to honor the "noExternal: true" config
1183
- // provided by vite-plugin-cloudflare within this repo. When compiling
1184
- // for Cloudflare, all server dependencies are externalized, but our
1185
- // `ssrExternals` config inadvertently overrides this. This doesn't
1186
- // impact consumers because for them `ssrExternals` is undefined and
1187
- // Cloudflare's "noExternal: true" config remains intact.
1188
- ctx.reactRouterConfig.future.unstable_viteEnvironmentApi && viteUserConfig.environments?.ssr?.resolve?.noExternal === true ? void 0 : ssrExternals
1200
+ // If `unstable_viteEnvironmentApi` is `true`, `resolve.external` is set in the `configEnvironment` hook
1201
+ ctx.reactRouterConfig.future.unstable_viteEnvironmentApi ? void 0 : ssrExternals
1189
1202
  ),
1190
1203
  conditions,
1191
1204
  externalConditions: conditions
@@ -1200,7 +1213,7 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
1200
1213
  copyPublicDir: false,
1201
1214
  // Assets in the public directory are only used by the client
1202
1215
  rollupOptions: {
1203
- input: (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi ? viteUserConfig.environments?.ssr?.build?.rollupOptions?.input : viteUserConfig.build?.rollupOptions?.input) ?? virtual.serverBuild.id,
1216
+ input: (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi ? viteUserConfig.environments?.ssr?.build?.rollupOptions?.input : viteUserConfig.build?.rollupOptions?.input) ?? virtual2.serverBuild.id,
1204
1217
  output: {
1205
1218
  entryFileNames: serverBuildFile,
1206
1219
  format: serverModuleFormat
@@ -1270,21 +1283,7 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
1270
1283
  environmentOptionsResolvers.ssr = ({ viteUserConfig }) => mergeEnvironmentOptions(getBaseServerOptions({ viteUserConfig }), {
1271
1284
  build: {
1272
1285
  outDir: getServerBuildDirectory(ctx.reactRouterConfig)
1273
- },
1274
- optimizeDeps: ctx.reactRouterConfig.future.unstable_viteEnvironmentApi && viteUserConfig.environments?.ssr?.optimizeDeps?.noDiscovery === false ? {
1275
- entries: [
1276
- vite2.normalizePath(ctx.entryServerFilePath),
1277
- ...Object.values(ctx.reactRouterConfig.routes).map(
1278
- (route) => resolveRelativeRouteFilePath(route, ctx.reactRouterConfig)
1279
- )
1280
- ],
1281
- include: [
1282
- "react",
1283
- "react/jsx-dev-runtime",
1284
- "react-dom/server",
1285
- "react-router"
1286
- ]
1287
- } : void 0
1286
+ }
1288
1287
  });
1289
1288
  }
1290
1289
  if (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi && viteCommand === "serve") {
@@ -1304,7 +1303,7 @@ function resolveEnvironmentsOptions(environmentResolvers, resolverOptions) {
1304
1303
  function isNonNullable(x) {
1305
1304
  return x != null;
1306
1305
  }
1307
- var import_node_crypto, path7, 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, CSS_DEV_HELPER_ENVIRONMENT_NAME, virtualHmrRuntime, virtualInjectHmrRuntime, resolveRelativeRouteFilePath, virtual, getServerBuildDirectory, getClientBuildDirectory, defaultEntriesDir, defaultEntries, REACT_REFRESH_HEADER;
1306
+ var import_node_crypto, path7, 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, CSS_DEV_HELPER_ENVIRONMENT_NAME, virtualHmrRuntime, virtualInjectHmrRuntime, virtual2, getServerBuildDirectory, getClientBuildDirectory, defaultEntriesDir, defaultEntries, REACT_REFRESH_HEADER;
1308
1307
  var init_plugin = __esm({
1309
1308
  "vite/plugin.ts"() {
1310
1309
  "use strict";
@@ -1354,13 +1353,7 @@ var init_plugin = __esm({
1354
1353
  CSS_DEV_HELPER_ENVIRONMENT_NAME = "__react_router_css_dev_helper__";
1355
1354
  virtualHmrRuntime = create("hmr-runtime");
1356
1355
  virtualInjectHmrRuntime = create("inject-hmr-runtime");
1357
- resolveRelativeRouteFilePath = (route, reactRouterConfig) => {
1358
- let vite2 = getVite();
1359
- let file = route.file;
1360
- let fullPath = path7.resolve(reactRouterConfig.appDirectory, file);
1361
- return vite2.normalizePath(fullPath);
1362
- };
1363
- virtual = {
1356
+ virtual2 = {
1364
1357
  serverBuild: create("server-build"),
1365
1358
  serverManifest: create("server-manifest"),
1366
1359
  browserManifest: create("browser-manifest")
package/dist/config.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v7.3.0-pre.1
2
+ * @react-router/dev v7.4.0-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.3.0-pre.1
2
+ * @react-router/dev v7.4.0-pre.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v7.3.0-pre.1
2
+ * @react-router/dev v7.4.0-pre.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
package/dist/vite.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v7.3.0-pre.1
2
+ * @react-router/dev v7.4.0-pre.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -825,6 +825,8 @@ async function writeAll(ctx) {
825
825
  });
826
826
  const registerPath = Path4.join(typegenDir, "+register.ts");
827
827
  import_node_fs2.default.writeFileSync(registerPath, register(ctx));
828
+ const virtualPath = Path4.join(typegenDir, "+virtual.ts");
829
+ import_node_fs2.default.writeFileSync(virtualPath, virtual);
828
830
  }
829
831
  function register(ctx) {
830
832
  const register2 = import_dedent2.default`
@@ -870,6 +872,22 @@ function register(ctx) {
870
872
  );
871
873
  return [register2, generate(typeParams).code].join("\n\n");
872
874
  }
875
+ var virtual = import_dedent2.default`
876
+ declare module "virtual:react-router/server-build" {
877
+ import { ServerBuild } from "react-router";
878
+ export const assets: ServerBuild["assets"];
879
+ export const assetsBuildDirectory: ServerBuild["assetsBuildDirectory"];
880
+ export const basename: ServerBuild["basename"];
881
+ export const entry: ServerBuild["entry"];
882
+ export const future: ServerBuild["future"];
883
+ export const isSpaMode: ServerBuild["isSpaMode"];
884
+ export const prerender: ServerBuild["prerender"];
885
+ export const publicPath: ServerBuild["publicPath"];
886
+ export const routes: ServerBuild["routes"];
887
+ export const ssr: ServerBuild["ssr"];
888
+ export const unstable_getCriticalCss: ServerBuild["unstable_getCriticalCss"];
889
+ }
890
+ `;
873
891
 
874
892
  // vite/node-adapter.ts
875
893
  var import_node_events = require("events");
@@ -1996,12 +2014,9 @@ function isSsrBundleEnvironmentName(name) {
1996
2014
  return name.startsWith(SSR_BUNDLE_PREFIX);
1997
2015
  }
1998
2016
  var CSS_DEV_HELPER_ENVIRONMENT_NAME = "__react_router_css_dev_helper__";
1999
- function isSeverBundleEnvironmentName(name) {
2000
- return name.startsWith(SSR_BUNDLE_PREFIX);
2001
- }
2002
2017
  function getServerEnvironmentEntries(ctx, record) {
2003
2018
  return Object.entries(record).filter(
2004
- ([name]) => ctx.buildManifest?.serverBundles ? isSeverBundleEnvironmentName(name) : name === "ssr"
2019
+ ([name]) => ctx.buildManifest?.serverBundles ? isSsrBundleEnvironmentName(name) : name === "ssr"
2005
2020
  );
2006
2021
  }
2007
2022
  function getServerEnvironmentValues(ctx, record) {
@@ -2014,7 +2029,7 @@ var isRouteVirtualModule = (id) => {
2014
2029
  return isRouteEntryModuleId(id) || isRouteChunkModuleId(id);
2015
2030
  };
2016
2031
  var isServerBuildVirtualModuleId = (id) => {
2017
- return id.split("?")[0] === virtual.serverBuild.id;
2032
+ return id.split("?")[0] === virtual2.serverBuild.id;
2018
2033
  };
2019
2034
  var getServerBuildFile = (viteManifest) => {
2020
2035
  let serverBuildIds = Object.keys(viteManifest).filter(
@@ -2044,13 +2059,13 @@ var resolveRelativeRouteFilePath = (route, reactRouterConfig) => {
2044
2059
  let fullPath = path6.resolve(reactRouterConfig.appDirectory, file);
2045
2060
  return vite2.normalizePath(fullPath);
2046
2061
  };
2047
- var virtual = {
2062
+ var virtual2 = {
2048
2063
  serverBuild: create("server-build"),
2049
2064
  serverManifest: create("server-manifest"),
2050
2065
  browserManifest: create("browser-manifest")
2051
2066
  };
2052
2067
  var invalidateVirtualModules = (viteDevServer) => {
2053
- Object.values(virtual).forEach((vmod2) => {
2068
+ Object.values(virtual2).forEach((vmod2) => {
2054
2069
  let mod = viteDevServer.moduleGraph.getModuleById(vmod2.resolvedId);
2055
2070
  if (mod) {
2056
2071
  viteDevServer.moduleGraph.invalidateModule(mod);
@@ -2322,7 +2337,7 @@ var reactRouterVitePlugin = () => {
2322
2337
  }
2323
2338
  }).join("\n")}
2324
2339
  export { default as assets } from ${JSON.stringify(
2325
- virtual.serverManifest.id
2340
+ virtual2.serverManifest.id
2326
2341
  )};
2327
2342
  export const assetsBuildDirectory = ${JSON.stringify(
2328
2343
  path6.relative(
@@ -2351,7 +2366,7 @@ var reactRouterVitePlugin = () => {
2351
2366
  }).join(",\n ")}
2352
2367
  };
2353
2368
  ${ctx.reactRouterConfig.future.unstable_viteEnvironmentApi && viteCommand === "serve" ? `
2354
- export const getCriticalCss = ({ pathname }) => {
2369
+ export const unstable_getCriticalCss = ({ pathname }) => {
2355
2370
  return {
2356
2371
  rel: "stylesheet",
2357
2372
  href: "${viteUserConfig.base ?? "/"}@react-router/critical.css?pathname=" + pathname,
@@ -2550,7 +2565,7 @@ var reactRouterVitePlugin = () => {
2550
2565
  }
2551
2566
  let reactRouterManifestForDev = {
2552
2567
  version: String(Math.random()),
2553
- url: combineURLs(ctx.publicPath, virtual.browserManifest.url),
2568
+ url: combineURLs(ctx.publicPath, virtual2.browserManifest.url),
2554
2569
  hmr: {
2555
2570
  runtime: combineURLs(ctx.publicPath, virtualInjectHmrRuntime.url)
2556
2571
  },
@@ -2740,6 +2755,41 @@ var reactRouterVitePlugin = () => {
2740
2755
  }
2741
2756
  };
2742
2757
  },
2758
+ configEnvironment(name, options) {
2759
+ if (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi && (ctx.buildManifest?.serverBundles ? isSsrBundleEnvironmentName(name) : name === "ssr")) {
2760
+ const vite2 = getVite();
2761
+ return {
2762
+ resolve: {
2763
+ external: (
2764
+ // This check is required to honor the "noExternal: true" config
2765
+ // provided by vite-plugin-cloudflare within this repo. When compiling
2766
+ // for Cloudflare, all server dependencies are pre-bundled, but our
2767
+ // `ssrExternals` config inadvertently overrides this. This doesn't
2768
+ // impact consumers because for them `ssrExternals` is undefined and
2769
+ // Cloudflare's "noExternal: true" config remains intact.
2770
+ options.resolve?.noExternal === true ? void 0 : ssrExternals
2771
+ )
2772
+ },
2773
+ optimizeDeps: options.optimizeDeps?.noDiscovery === false ? {
2774
+ entries: [
2775
+ vite2.normalizePath(ctx.entryServerFilePath),
2776
+ ...Object.values(ctx.reactRouterConfig.routes).map(
2777
+ (route) => resolveRelativeRouteFilePath(
2778
+ route,
2779
+ ctx.reactRouterConfig
2780
+ )
2781
+ )
2782
+ ],
2783
+ include: [
2784
+ "react",
2785
+ "react/jsx-dev-runtime",
2786
+ "react-dom/server",
2787
+ "react-router"
2788
+ ]
2789
+ } : void 0
2790
+ };
2791
+ }
2792
+ },
2743
2793
  async configResolved(resolvedViteConfig) {
2744
2794
  await import_es_module_lexer.init;
2745
2795
  viteConfig = resolvedViteConfig;
@@ -2772,6 +2822,9 @@ var reactRouterVitePlugin = () => {
2772
2822
  );
2773
2823
  }
2774
2824
  }
2825
+ const childCompilerPlugins = await asyncFlatten(
2826
+ childCompilerConfigFile.config.plugins ?? []
2827
+ );
2775
2828
  viteChildCompiler = await vite2.createServer({
2776
2829
  ...viteUserConfig,
2777
2830
  // Ensure child compiler cannot overwrite the default cache directory
@@ -2785,9 +2838,13 @@ var reactRouterVitePlugin = () => {
2785
2838
  configFile: false,
2786
2839
  envFile: false,
2787
2840
  plugins: [
2788
- ...(childCompilerConfigFile.config.plugins ?? []).flat().filter(
2841
+ childCompilerPlugins.filter(
2789
2842
  (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"
2790
- ),
2843
+ ).map((plugin2) => ({
2844
+ ...plugin2,
2845
+ configureServer: void 0,
2846
+ configurePreviewServer: void 0
2847
+ })),
2791
2848
  {
2792
2849
  name: "react-router:override-optimize-deps",
2793
2850
  config(userConfig) {
@@ -2916,14 +2973,15 @@ var reactRouterVitePlugin = () => {
2916
2973
  let vite2 = getVite();
2917
2974
  let ssrEnvironment = viteDevServer.environments.ssr;
2918
2975
  if (!vite2.isRunnableDevEnvironment(ssrEnvironment)) {
2976
+ next();
2919
2977
  return;
2920
2978
  }
2921
2979
  build = await ssrEnvironment.runner.import(
2922
- virtual.serverBuild.id
2980
+ virtual2.serverBuild.id
2923
2981
  );
2924
2982
  } else {
2925
2983
  build = await viteDevServer.ssrLoadModule(
2926
- virtual.serverBuild.id
2984
+ virtual2.serverBuild.id
2927
2985
  );
2928
2986
  }
2929
2987
  let handler = (0, import_react_router2.createRequestHandler)(build, "development");
@@ -3144,16 +3202,16 @@ var reactRouterVitePlugin = () => {
3144
3202
  name: "react-router:virtual-modules",
3145
3203
  enforce: "pre",
3146
3204
  resolveId(id) {
3147
- const vmod2 = Object.values(virtual).find((vmod3) => vmod3.id === id);
3205
+ const vmod2 = Object.values(virtual2).find((vmod3) => vmod3.id === id);
3148
3206
  if (vmod2) return vmod2.resolvedId;
3149
3207
  },
3150
3208
  async load(id) {
3151
3209
  switch (id) {
3152
- case virtual.serverBuild.resolvedId: {
3210
+ case virtual2.serverBuild.resolvedId: {
3153
3211
  let routeIds = getServerBundleRouteIds(this, ctx);
3154
3212
  return await getServerEntry({ routeIds });
3155
3213
  }
3156
- case virtual.serverManifest.resolvedId: {
3214
+ case virtual2.serverManifest.resolvedId: {
3157
3215
  let routeIds = getServerBundleRouteIds(this, ctx);
3158
3216
  let reactRouterManifest = viteCommand === "build" ? (await generateReactRouterManifestsForBuild({
3159
3217
  routeIds
@@ -3171,7 +3229,7 @@ var reactRouterVitePlugin = () => {
3171
3229
  es6: true
3172
3230
  })};`;
3173
3231
  }
3174
- case virtual.browserManifest.resolvedId: {
3232
+ case virtual2.browserManifest.resolvedId: {
3175
3233
  if (viteCommand === "build") {
3176
3234
  throw new Error("This module only exists in development");
3177
3235
  }
@@ -3985,6 +4043,9 @@ var resolveRouteFileCode = async (ctx, input) => {
3985
4043
  input.readRouteFile
3986
4044
  );
3987
4045
  };
4046
+ function isRootRouteModuleId(ctx, id) {
4047
+ return normalizeRelativeFilePath(id, ctx.reactRouterConfig) === ctx.reactRouterConfig.routes.root.file;
4048
+ }
3988
4049
  async function detectRouteChunksIfEnabled(cache, ctx, id, input) {
3989
4050
  function noRouteChunks() {
3990
4051
  return {
@@ -4000,7 +4061,7 @@ async function detectRouteChunksIfEnabled(cache, ctx, id, input) {
4000
4061
  if (!ctx.reactRouterConfig.future.unstable_splitRouteModules) {
4001
4062
  return noRouteChunks();
4002
4063
  }
4003
- if (normalizeRelativeFilePath(id, ctx.reactRouterConfig) === ctx.reactRouterConfig.routes.root.file) {
4064
+ if (isRootRouteModuleId(ctx, id)) {
4004
4065
  return noRouteChunks();
4005
4066
  }
4006
4067
  let code = await resolveRouteFileCode(ctx, input);
@@ -4023,6 +4084,9 @@ function validateRouteChunks({
4023
4084
  id,
4024
4085
  valid
4025
4086
  }) {
4087
+ if (isRootRouteModuleId(ctx, id)) {
4088
+ return;
4089
+ }
4026
4090
  let invalidChunks = Object.entries(valid).filter(([_, isValid]) => !isValid).map(([chunkName]) => chunkName);
4027
4091
  if (invalidChunks.length === 0) {
4028
4092
  return;
@@ -4194,13 +4258,8 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
4194
4258
  return mergeEnvironmentOptions(getBaseOptions({ viteUserConfig }), {
4195
4259
  resolve: {
4196
4260
  external: (
4197
- // This check is required to honor the "noExternal: true" config
4198
- // provided by vite-plugin-cloudflare within this repo. When compiling
4199
- // for Cloudflare, all server dependencies are externalized, but our
4200
- // `ssrExternals` config inadvertently overrides this. This doesn't
4201
- // impact consumers because for them `ssrExternals` is undefined and
4202
- // Cloudflare's "noExternal: true" config remains intact.
4203
- ctx.reactRouterConfig.future.unstable_viteEnvironmentApi && viteUserConfig.environments?.ssr?.resolve?.noExternal === true ? void 0 : ssrExternals
4261
+ // If `unstable_viteEnvironmentApi` is `true`, `resolve.external` is set in the `configEnvironment` hook
4262
+ ctx.reactRouterConfig.future.unstable_viteEnvironmentApi ? void 0 : ssrExternals
4204
4263
  ),
4205
4264
  conditions,
4206
4265
  externalConditions: conditions
@@ -4215,7 +4274,7 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
4215
4274
  copyPublicDir: false,
4216
4275
  // Assets in the public directory are only used by the client
4217
4276
  rollupOptions: {
4218
- input: (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi ? viteUserConfig.environments?.ssr?.build?.rollupOptions?.input : viteUserConfig.build?.rollupOptions?.input) ?? virtual.serverBuild.id,
4277
+ input: (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi ? viteUserConfig.environments?.ssr?.build?.rollupOptions?.input : viteUserConfig.build?.rollupOptions?.input) ?? virtual2.serverBuild.id,
4219
4278
  output: {
4220
4279
  entryFileNames: serverBuildFile,
4221
4280
  format: serverModuleFormat
@@ -4285,21 +4344,7 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
4285
4344
  environmentOptionsResolvers.ssr = ({ viteUserConfig }) => mergeEnvironmentOptions(getBaseServerOptions({ viteUserConfig }), {
4286
4345
  build: {
4287
4346
  outDir: getServerBuildDirectory(ctx.reactRouterConfig)
4288
- },
4289
- optimizeDeps: ctx.reactRouterConfig.future.unstable_viteEnvironmentApi && viteUserConfig.environments?.ssr?.optimizeDeps?.noDiscovery === false ? {
4290
- entries: [
4291
- vite2.normalizePath(ctx.entryServerFilePath),
4292
- ...Object.values(ctx.reactRouterConfig.routes).map(
4293
- (route) => resolveRelativeRouteFilePath(route, ctx.reactRouterConfig)
4294
- )
4295
- ],
4296
- include: [
4297
- "react",
4298
- "react/jsx-dev-runtime",
4299
- "react-dom/server",
4300
- "react-router"
4301
- ]
4302
- } : void 0
4347
+ }
4303
4348
  });
4304
4349
  }
4305
4350
  if (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi && viteCommand === "serve") {
@@ -4329,6 +4374,12 @@ async function getEnvironmentsOptions(ctx, viteCommand, resolverOptions) {
4329
4374
  function isNonNullable(x) {
4330
4375
  return x != null;
4331
4376
  }
4377
+ async function asyncFlatten(arr) {
4378
+ do {
4379
+ arr = (await Promise.all(arr)).flat(Infinity);
4380
+ } while (arr.some((v2) => v2?.then));
4381
+ return arr;
4382
+ }
4332
4383
  // Annotate the CommonJS export names for ESM import in node:
4333
4384
  0 && (module.exports = {
4334
4385
  reactRouter
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-router/dev",
3
- "version": "7.3.0-pre.1",
3
+ "version": "7.4.0-pre.0",
4
4
  "description": "Dev tools and CLI for React Router",
5
5
  "homepage": "https://reactrouter.com",
6
6
  "bugs": {
@@ -86,7 +86,7 @@
86
86
  "set-cookie-parser": "^2.6.0",
87
87
  "valibot": "^0.41.0",
88
88
  "vite-node": "3.0.0-beta.2",
89
- "@react-router/node": "7.3.0-pre.1"
89
+ "@react-router/node": "7.4.0-pre.0"
90
90
  },
91
91
  "devDependencies": {
92
92
  "@types/babel__core": "^7.20.5",
@@ -110,15 +110,15 @@
110
110
  "vite": "^6.1.0",
111
111
  "wireit": "0.14.9",
112
112
  "wrangler": "^3.109.2",
113
- "@react-router/serve": "7.3.0-pre.1",
114
- "react-router": "^7.3.0-pre.1"
113
+ "@react-router/serve": "7.4.0-pre.0",
114
+ "react-router": "^7.4.0-pre.0"
115
115
  },
116
116
  "peerDependencies": {
117
117
  "typescript": "^5.1.0",
118
118
  "vite": "^5.1.0 || ^6.0.0",
119
119
  "wrangler": "^3.28.2",
120
- "@react-router/serve": "^7.3.0-pre.1",
121
- "react-router": "^7.3.0-pre.1"
120
+ "@react-router/serve": "^7.4.0-pre.0",
121
+ "react-router": "^7.4.0-pre.0"
122
122
  },
123
123
  "peerDependenciesMeta": {
124
124
  "@react-router/serve": {