@react-router/dev 0.0.0-experimental-818f8e08d → 0.0.0-experimental-e56aa53bc

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,24 +1,5 @@
1
1
  # `@react-router/dev`
2
2
 
3
- ## 7.5.3
4
-
5
- ### Patch Changes
6
-
7
- - Updated dependencies:
8
- - `react-router@7.5.3`
9
- - `@react-router/node@7.5.3`
10
- - `@react-router/serve@7.5.3`
11
-
12
- ## 7.5.2
13
-
14
- ### Patch Changes
15
-
16
- - Adjust approach for Prerendering/SPA Mode via headers ([#13453](https://github.com/remix-run/react-router/pull/13453))
17
- - Updated dependencies:
18
- - `react-router@7.5.2`
19
- - `@react-router/node@7.5.2`
20
- - `@react-router/serve@7.5.2`
21
-
22
3
  ## 7.5.1
23
4
 
24
5
  ### Patch Changes
package/dist/cli/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * @react-router/dev v0.0.0-experimental-818f8e08d
3
+ * @react-router/dev v0.0.0-experimental-e56aa53bc
4
4
  *
5
5
  * Copyright (c) Remix Software Inc.
6
6
  *
@@ -143,15 +143,6 @@ async function createContext({
143
143
  optimizeDeps: {
144
144
  noDiscovery: true
145
145
  },
146
- css: {
147
- // This empty PostCSS config object prevents the PostCSS config file from
148
- // being loaded. We don't need it in a React Router config context, and
149
- // there's also an issue in Vite 5 when using a .ts PostCSS config file in
150
- // an ESM project: https://github.com/vitejs/vite/issues/15869. Consumers
151
- // can work around this in their own Vite config file, but they can't
152
- // configure this internal usage of vite-node.
153
- postcss: {}
154
- },
155
146
  configFile: false,
156
147
  envFile: false,
157
148
  plugins: []
@@ -348,17 +339,12 @@ async function resolveConfig({
348
339
  serverModuleFormat: "esm",
349
340
  ssr: true
350
341
  };
351
- let userAndPresetConfigs = mergeReactRouterConfig(
352
- ...presets,
353
- reactRouterUserConfig
354
- );
355
342
  let {
356
343
  appDirectory: userAppDirectory,
357
344
  basename: basename2,
358
345
  buildDirectory: userBuildDirectory,
359
346
  buildEnd,
360
347
  prerender,
361
- routeDiscovery: userRouteDiscovery,
362
348
  serverBuildFile,
363
349
  serverBundles,
364
350
  serverModuleFormat,
@@ -366,7 +352,7 @@ async function resolveConfig({
366
352
  } = {
367
353
  ...defaults,
368
354
  // Default values should be completely overridden by user/preset config, not merged
369
- ...userAndPresetConfigs
355
+ ...mergeReactRouterConfig(...presets, reactRouterUserConfig)
370
356
  };
371
357
  if (!ssr && serverBundles) {
372
358
  serverBundles = void 0;
@@ -377,32 +363,6 @@ async function resolveConfig({
377
363
  "The `prerender` config must be a boolean, an array of string paths, or a function returning a boolean or array of string paths"
378
364
  );
379
365
  }
380
- let routeDiscovery;
381
- if (userRouteDiscovery == null) {
382
- if (ssr) {
383
- routeDiscovery = {
384
- mode: "lazy",
385
- manifestPath: "/__manifest"
386
- };
387
- } else {
388
- routeDiscovery = { mode: "initial" };
389
- }
390
- } else if (userRouteDiscovery.mode === "initial") {
391
- routeDiscovery = userRouteDiscovery;
392
- } else if (userRouteDiscovery.mode === "lazy") {
393
- if (!ssr) {
394
- return err(
395
- 'The `routeDiscovery.mode` config cannot be set to "lazy" when setting `ssr:false`'
396
- );
397
- }
398
- let { manifestPath } = userRouteDiscovery;
399
- if (manifestPath != null && !manifestPath.startsWith("/")) {
400
- return err(
401
- 'The `routeDiscovery.manifestPath` config must be a root-relative pathname beginning with a slash (i.e., "/__manifest")'
402
- );
403
- }
404
- routeDiscovery = userRouteDiscovery;
405
- }
406
366
  let appDirectory = import_pathe3.default.resolve(root, userAppDirectory || "app");
407
367
  let buildDirectory = import_pathe3.default.resolve(root, userBuildDirectory);
408
368
  let rootRouteFile = findEntry(appDirectory, "root");
@@ -470,7 +430,6 @@ async function resolveConfig({
470
430
  future,
471
431
  prerender,
472
432
  routes: routes2,
473
- routeDiscovery,
474
433
  serverBuildFile,
475
434
  serverBundles,
476
435
  serverModuleFormat,
@@ -483,13 +442,12 @@ async function resolveConfig({
483
442
  }
484
443
  async function createConfigLoader({
485
444
  rootDirectory: root,
486
- watch: watch2,
487
- mode
445
+ watch: watch2
488
446
  }) {
489
447
  root = root ?? process.env.REACT_ROUTER_ROOT ?? process.cwd();
490
448
  let viteNodeContext = await createContext({
491
449
  root,
492
- mode
450
+ mode: watch2 ? "development" : "production"
493
451
  });
494
452
  let reactRouterConfigFile = findEntry(root, "react-router.config", {
495
453
  absolute: true
@@ -565,13 +523,9 @@ async function createConfigLoader({
565
523
  }
566
524
  };
567
525
  }
568
- async function loadConfig({
569
- rootDirectory,
570
- mode
571
- }) {
526
+ async function loadConfig({ rootDirectory }) {
572
527
  let configLoader = await createConfigLoader({
573
528
  rootDirectory,
574
- mode,
575
529
  watch: false
576
530
  });
577
531
  let config = await configLoader.getConfig();
@@ -579,24 +533,13 @@ async function loadConfig({
579
533
  return config;
580
534
  }
581
535
  function findEntry(dir, basename2, options) {
582
- let currentDir = import_pathe3.default.resolve(dir);
583
- let { root } = import_pathe3.default.parse(currentDir);
584
- while (true) {
585
- for (let ext of options?.extensions ?? entryExts) {
586
- let file = import_pathe3.default.resolve(currentDir, basename2 + ext);
587
- if (import_node_fs.default.existsSync(file)) {
588
- return options?.absolute ?? false ? file : import_pathe3.default.relative(dir, file);
589
- }
590
- }
591
- if (!options?.walkParents) {
592
- return void 0;
536
+ for (let ext of entryExts) {
537
+ let file = import_pathe3.default.resolve(dir, basename2 + ext);
538
+ if (import_node_fs.default.existsSync(file)) {
539
+ return options?.absolute ?? false ? file : import_pathe3.default.relative(dir, file);
593
540
  }
594
- let parentDir = import_pathe3.default.dirname(currentDir);
595
- if (currentDir === root || parentDir === currentDir) {
596
- return void 0;
597
- }
598
- currentDir = parentDir;
599
541
  }
542
+ return void 0;
600
543
  }
601
544
  var import_node_fs, import_node_child_process, import_package_json, import_pathe3, import_chokidar, import_picocolors, import_pick2, import_omit, import_cloneDeep, import_isEqual, excludedConfigPresetKeys, mergeReactRouterConfig, deepFreeze, entryExts;
602
545
  var init_config = __esm({
@@ -865,12 +808,12 @@ var init_generate = __esm({
865
808
  });
866
809
 
867
810
  // typegen/index.ts
868
- async function run(rootDirectory, { mode }) {
869
- const ctx = await createContext2({ rootDirectory, mode, watch: false });
811
+ async function run(rootDirectory) {
812
+ const ctx = await createContext2({ rootDirectory, watch: false });
870
813
  await writeAll(ctx);
871
814
  }
872
- async function watch(rootDirectory, { mode, logger }) {
873
- const ctx = await createContext2({ rootDirectory, mode, watch: true });
815
+ async function watch(rootDirectory, { logger } = {}) {
816
+ const ctx = await createContext2({ rootDirectory, watch: true });
874
817
  await writeAll(ctx);
875
818
  logger?.info(import_picocolors3.default.green("generated types"), { timestamp: true, clear: true });
876
819
  ctx.configLoader.onChange(async ({ result, routeConfigChanged }) => {
@@ -893,10 +836,9 @@ async function watch(rootDirectory, { mode, logger }) {
893
836
  }
894
837
  async function createContext2({
895
838
  rootDirectory,
896
- watch: watch2,
897
- mode
839
+ watch: watch2
898
840
  }) {
899
- const configLoader = await createConfigLoader({ rootDirectory, mode, watch: watch2 });
841
+ const configLoader = await createConfigLoader({ rootDirectory, watch: watch2 });
900
842
  const configResult = await configLoader.getConfig();
901
843
  if (!configResult.ok) {
902
844
  throw new Error(configResult.error);
@@ -991,7 +933,6 @@ var init_typegen = __esm({
991
933
  export const isSpaMode: ServerBuild["isSpaMode"];
992
934
  export const prerender: ServerBuild["prerender"];
993
935
  export const publicPath: ServerBuild["publicPath"];
994
- export const routeDiscovery: ServerBuild["routeDiscovery"];
995
936
  export const routes: ServerBuild["routes"];
996
937
  export const ssr: ServerBuild["ssr"];
997
938
  export const unstable_getCriticalCss: ServerBuild["unstable_getCriticalCss"];
@@ -1316,9 +1257,8 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
1316
1257
  ""
1317
1258
  ) : null;
1318
1259
  let routeChunkSuffix = routeChunkName ? `-${(0, import_kebabCase.default)(routeChunkName)}` : "";
1319
- let assetsDir = (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi ? viteUserConfig?.environments?.client?.build?.assetsDir : null) ?? viteUserConfig?.build?.assetsDir ?? "assets";
1320
1260
  return path7.posix.join(
1321
- assetsDir,
1261
+ (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi ? viteUserConfig?.environments?.client?.build?.assetsDir : viteUserConfig?.build?.assetsDir) ?? "assets",
1322
1262
  `[name]${routeChunkSuffix}-[hash].js`
1323
1263
  );
1324
1264
  }
@@ -1472,10 +1412,7 @@ __export(build_exports, {
1472
1412
  async function build(root, viteBuildOptions) {
1473
1413
  await preloadVite();
1474
1414
  let vite2 = getVite();
1475
- let configResult = await loadConfig({
1476
- rootDirectory: root,
1477
- mode: viteBuildOptions.mode ?? "production"
1478
- });
1415
+ let configResult = await loadConfig({ rootDirectory: root });
1479
1416
  if (!configResult.ok) {
1480
1417
  throw new Error(configResult.error);
1481
1418
  }
@@ -1801,12 +1738,9 @@ function transpile(tsx, options = {}) {
1801
1738
  init_profiler();
1802
1739
  init_typegen();
1803
1740
  init_vite();
1804
- async function routes(rootDirectory, flags = {}) {
1805
- rootDirectory = resolveRootDirectory(rootDirectory, flags);
1806
- let configResult = await loadConfig({
1807
- rootDirectory,
1808
- mode: flags.mode ?? "production"
1809
- });
1741
+ async function routes(reactRouterRoot, flags = {}) {
1742
+ let rootDirectory = reactRouterRoot ?? process.cwd();
1743
+ let configResult = await loadConfig({ rootDirectory });
1810
1744
  if (!configResult.ok) {
1811
1745
  console.error(import_picocolors7.default.red(configResult.error));
1812
1746
  process.exit(1);
@@ -1815,7 +1749,9 @@ async function routes(rootDirectory, flags = {}) {
1815
1749
  console.log(formatRoutes(configResult.value.routes, format));
1816
1750
  }
1817
1751
  async function build2(root, options = {}) {
1818
- root = resolveRootDirectory(root, options);
1752
+ if (!root) {
1753
+ root = process.env.REACT_ROUTER_ROOT || process.cwd();
1754
+ }
1819
1755
  let { build: build3 } = await Promise.resolve().then(() => (init_build(), build_exports));
1820
1756
  if (options.profile) {
1821
1757
  await start();
@@ -1832,7 +1768,6 @@ async function dev2(root, options = {}) {
1832
1768
  await start();
1833
1769
  }
1834
1770
  (0, import_exit_hook.default)(() => stop(console.info));
1835
- root = resolveRootDirectory(root, options);
1836
1771
  await dev3(root, options);
1837
1772
  await new Promise(() => {
1838
1773
  });
@@ -1844,17 +1779,14 @@ var conjunctionListFormat = new Intl.ListFormat("en", {
1844
1779
  style: "long",
1845
1780
  type: "conjunction"
1846
1781
  });
1847
- async function generateEntry(entry, rootDirectory, flags = {}) {
1782
+ async function generateEntry(entry, reactRouterRoot, flags = {}) {
1848
1783
  if (!entry) {
1849
- await generateEntry("entry.client", rootDirectory, flags);
1850
- await generateEntry("entry.server", rootDirectory, flags);
1784
+ await generateEntry("entry.client", reactRouterRoot, flags);
1785
+ await generateEntry("entry.server", reactRouterRoot, flags);
1851
1786
  return;
1852
1787
  }
1853
- rootDirectory = resolveRootDirectory(rootDirectory, flags);
1854
- let configResult = await loadConfig({
1855
- rootDirectory,
1856
- mode: flags.mode ?? "production"
1857
- });
1788
+ let rootDirectory = reactRouterRoot ?? process.cwd();
1789
+ let configResult = await loadConfig({ rootDirectory });
1858
1790
  if (!configResult.ok) {
1859
1791
  console.error(import_picocolors7.default.red(configResult.error));
1860
1792
  return;
@@ -1909,12 +1841,6 @@ async function generateEntry(entry, rootDirectory, flags = {}) {
1909
1841
  )
1910
1842
  );
1911
1843
  }
1912
- function resolveRootDirectory(root, flags) {
1913
- if (root) {
1914
- return path8.resolve(root);
1915
- }
1916
- return process.env.REACT_ROUTER_ROOT || (flags?.config ? path8.dirname(path8.resolve(flags.config)) : process.cwd());
1917
- }
1918
1844
  async function checkForEntry(rootDirectory, appDirectory, entries2) {
1919
1845
  for (let entry of entries2) {
1920
1846
  let entryPath = path8.resolve(appDirectory, entry);
@@ -1937,22 +1863,17 @@ async function createClientEntry(rootDirectory, appDirectory, inputFile) {
1937
1863
  return contents;
1938
1864
  }
1939
1865
  async function typegen(root, flags) {
1940
- root = resolveRootDirectory(root, flags);
1866
+ root ??= process.cwd();
1941
1867
  if (flags.watch) {
1942
1868
  await preloadVite();
1943
1869
  const vite2 = getVite();
1944
1870
  const logger = vite2.createLogger("info", { prefix: "[react-router]" });
1945
- await watch(root, {
1946
- mode: flags.mode ?? "development",
1947
- logger
1948
- });
1871
+ await watch(root, { logger });
1949
1872
  await new Promise(() => {
1950
1873
  });
1951
1874
  return;
1952
1875
  }
1953
- await run(root, {
1954
- mode: flags.mode ?? "production"
1955
- });
1876
+ await run(root);
1956
1877
  }
1957
1878
 
1958
1879
  // cli/run.ts
package/dist/config.d.ts CHANGED
@@ -102,22 +102,6 @@ type ReactRouterConfig = {
102
102
  * other platforms and tools.
103
103
  */
104
104
  presets?: Array<Preset>;
105
- /**
106
- * Control the "Lazy Route Discovery" behavior
107
- *
108
- * - `routeDiscovery.mode`: By default, this resolves to `lazy` which will
109
- * lazily discover routes as the user navigates around your application.
110
- * You can set this to `initial` to opt-out of this behavior and load all
111
- * routes with the initial HTML document load.
112
- * - `routeDiscovery.manifestPath`: The path to serve the manifest file from.
113
- * Only applies to `mode: "lazy"` and defaults to `/__manifest`.
114
- */
115
- routeDiscovery?: {
116
- mode: "lazy";
117
- manifestPath?: string;
118
- } | {
119
- mode: "initial";
120
- };
121
105
  /**
122
106
  * The file name of the server build output. This file
123
107
  * should end in a `.js` extension and should be deployed to your server.
@@ -164,17 +148,6 @@ type ResolvedReactRouterConfig = Readonly<{
164
148
  * function returning an array to dynamically generate URLs.
165
149
  */
166
150
  prerender: ReactRouterConfig["prerender"];
167
- /**
168
- * Control the "Lazy Route Discovery" behavior
169
- *
170
- * - `routeDiscovery.mode`: By default, this resolves to `lazy` which will
171
- * lazily discover routes as the user navigates around your application.
172
- * You can set this to `initial` to opt-out of this behavior and load all
173
- * routes with the initial HTML document load.
174
- * - `routeDiscovery.manifestPath`: The path to serve the manifest file from.
175
- * Only applies to `mode: "lazy"` and defaults to `/__manifest`.
176
- */
177
- routeDiscovery: ReactRouterConfig["routeDiscovery"];
178
151
  /**
179
152
  * An object of all available routes, keyed by route id.
180
153
  */
package/dist/config.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-818f8e08d
2
+ * @react-router/dev v0.0.0-experimental-e56aa53bc
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 v0.0.0-experimental-818f8e08d
2
+ * @react-router/dev v0.0.0-experimental-e56aa53bc
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-818f8e08d
2
+ * @react-router/dev v0.0.0-experimental-e56aa53bc
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -113,9 +113,7 @@ function fromNodeRequest(nodeReq, nodeRes) {
113
113
  }
114
114
  async function toNodeRequest(res, nodeRes) {
115
115
  nodeRes.statusCode = res.status;
116
- if (!nodeRes.req || nodeRes.req.httpVersionMajor < 2) {
117
- nodeRes.statusMessage = res.statusText;
118
- }
116
+ nodeRes.statusMessage = res.statusText;
119
117
  let cookiesStrings = [];
120
118
  for (let [name, value] of res.headers) {
121
119
  if (name === "set-cookie") {
@@ -215,15 +213,6 @@ async function createContext({
215
213
  optimizeDeps: {
216
214
  noDiscovery: true
217
215
  },
218
- css: {
219
- // This empty PostCSS config object prevents the PostCSS config file from
220
- // being loaded. We don't need it in a React Router config context, and
221
- // there's also an issue in Vite 5 when using a .ts PostCSS config file in
222
- // an ESM project: https://github.com/vitejs/vite/issues/15869. Consumers
223
- // can work around this in their own Vite config file, but they can't
224
- // configure this internal usage of vite-node.
225
- postcss: {}
226
- },
227
216
  configFile: false,
228
217
  envFile: false,
229
218
  plugins: []
@@ -443,17 +432,12 @@ async function resolveConfig({
443
432
  serverModuleFormat: "esm",
444
433
  ssr: true
445
434
  };
446
- let userAndPresetConfigs = mergeReactRouterConfig(
447
- ...presets,
448
- reactRouterUserConfig
449
- );
450
435
  let {
451
436
  appDirectory: userAppDirectory,
452
437
  basename,
453
438
  buildDirectory: userBuildDirectory,
454
439
  buildEnd,
455
440
  prerender,
456
- routeDiscovery: userRouteDiscovery,
457
441
  serverBuildFile,
458
442
  serverBundles,
459
443
  serverModuleFormat,
@@ -461,7 +445,7 @@ async function resolveConfig({
461
445
  } = {
462
446
  ...defaults,
463
447
  // Default values should be completely overridden by user/preset config, not merged
464
- ...userAndPresetConfigs
448
+ ...mergeReactRouterConfig(...presets, reactRouterUserConfig)
465
449
  };
466
450
  if (!ssr && serverBundles) {
467
451
  serverBundles = void 0;
@@ -472,32 +456,6 @@ async function resolveConfig({
472
456
  "The `prerender` config must be a boolean, an array of string paths, or a function returning a boolean or array of string paths"
473
457
  );
474
458
  }
475
- let routeDiscovery;
476
- if (userRouteDiscovery == null) {
477
- if (ssr) {
478
- routeDiscovery = {
479
- mode: "lazy",
480
- manifestPath: "/__manifest"
481
- };
482
- } else {
483
- routeDiscovery = { mode: "initial" };
484
- }
485
- } else if (userRouteDiscovery.mode === "initial") {
486
- routeDiscovery = userRouteDiscovery;
487
- } else if (userRouteDiscovery.mode === "lazy") {
488
- if (!ssr) {
489
- return err(
490
- 'The `routeDiscovery.mode` config cannot be set to "lazy" when setting `ssr:false`'
491
- );
492
- }
493
- let { manifestPath } = userRouteDiscovery;
494
- if (manifestPath != null && !manifestPath.startsWith("/")) {
495
- return err(
496
- 'The `routeDiscovery.manifestPath` config must be a root-relative pathname beginning with a slash (i.e., "/__manifest")'
497
- );
498
- }
499
- routeDiscovery = userRouteDiscovery;
500
- }
501
459
  let appDirectory = import_pathe3.default.resolve(root, userAppDirectory || "app");
502
460
  let buildDirectory = import_pathe3.default.resolve(root, userBuildDirectory);
503
461
  let rootRouteFile = findEntry(appDirectory, "root");
@@ -565,7 +523,6 @@ async function resolveConfig({
565
523
  future,
566
524
  prerender,
567
525
  routes,
568
- routeDiscovery,
569
526
  serverBuildFile,
570
527
  serverBundles,
571
528
  serverModuleFormat,
@@ -578,13 +535,12 @@ async function resolveConfig({
578
535
  }
579
536
  async function createConfigLoader({
580
537
  rootDirectory: root,
581
- watch,
582
- mode
538
+ watch
583
539
  }) {
584
540
  root = root ?? process.env.REACT_ROUTER_ROOT ?? process.cwd();
585
541
  let viteNodeContext = await createContext({
586
542
  root,
587
- mode
543
+ mode: watch ? "development" : "production"
588
544
  });
589
545
  let reactRouterConfigFile = findEntry(root, "react-router.config", {
590
546
  absolute: true
@@ -660,13 +616,9 @@ async function createConfigLoader({
660
616
  }
661
617
  };
662
618
  }
663
- async function loadConfig({
664
- rootDirectory,
665
- mode
666
- }) {
619
+ async function loadConfig({ rootDirectory }) {
667
620
  let configLoader = await createConfigLoader({
668
621
  rootDirectory,
669
- mode,
670
622
  watch: false
671
623
  });
672
624
  let config = await configLoader.getConfig();
@@ -675,24 +627,13 @@ async function loadConfig({
675
627
  }
676
628
  var entryExts = [".js", ".jsx", ".ts", ".tsx"];
677
629
  function findEntry(dir, basename, options) {
678
- let currentDir = import_pathe3.default.resolve(dir);
679
- let { root } = import_pathe3.default.parse(currentDir);
680
- while (true) {
681
- for (let ext of options?.extensions ?? entryExts) {
682
- let file = import_pathe3.default.resolve(currentDir, basename + ext);
683
- if (import_node_fs.default.existsSync(file)) {
684
- return options?.absolute ?? false ? file : import_pathe3.default.relative(dir, file);
685
- }
686
- }
687
- if (!options?.walkParents) {
688
- return void 0;
689
- }
690
- let parentDir = import_pathe3.default.dirname(currentDir);
691
- if (currentDir === root || parentDir === currentDir) {
692
- return void 0;
630
+ for (let ext of entryExts) {
631
+ let file = import_pathe3.default.resolve(dir, basename + ext);
632
+ if (import_node_fs.default.existsSync(file)) {
633
+ return options?.absolute ?? false ? file : import_pathe3.default.relative(dir, file);
693
634
  }
694
- currentDir = parentDir;
695
635
  }
636
+ return void 0;
696
637
  }
697
638
 
698
639
  // vite/cloudflare-dev-proxy.ts
@@ -711,15 +652,14 @@ var cloudflareDevProxyVitePlugin = (options = {}) => {
711
652
  let future;
712
653
  return {
713
654
  name: PLUGIN_NAME,
714
- config: async (config, configEnv) => {
655
+ config: async (config) => {
715
656
  await preloadVite();
716
657
  const vite2 = getVite();
717
658
  const serverConditions = [
718
659
  ...vite2.defaultServerConditions ?? []
719
660
  ];
720
661
  let configResult = await loadConfig({
721
- rootDirectory: config.root ?? process.cwd(),
722
- mode: configEnv.mode
662
+ rootDirectory: config.root ?? process.cwd()
723
663
  });
724
664
  if (!configResult.ok) {
725
665
  throw new Error(configResult.error);
package/dist/vite.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-experimental-818f8e08d
2
+ * @react-router/dev v0.0.0-experimental-e56aa53bc
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -154,15 +154,6 @@ async function createContext({
154
154
  optimizeDeps: {
155
155
  noDiscovery: true
156
156
  },
157
- css: {
158
- // This empty PostCSS config object prevents the PostCSS config file from
159
- // being loaded. We don't need it in a React Router config context, and
160
- // there's also an issue in Vite 5 when using a .ts PostCSS config file in
161
- // an ESM project: https://github.com/vitejs/vite/issues/15869. Consumers
162
- // can work around this in their own Vite config file, but they can't
163
- // configure this internal usage of vite-node.
164
- postcss: {}
165
- },
166
157
  configFile: false,
167
158
  envFile: false,
168
159
  plugins: []
@@ -405,17 +396,12 @@ async function resolveConfig({
405
396
  serverModuleFormat: "esm",
406
397
  ssr: true
407
398
  };
408
- let userAndPresetConfigs = mergeReactRouterConfig(
409
- ...presets,
410
- reactRouterUserConfig
411
- );
412
399
  let {
413
400
  appDirectory: userAppDirectory,
414
401
  basename: basename2,
415
402
  buildDirectory: userBuildDirectory,
416
403
  buildEnd,
417
404
  prerender,
418
- routeDiscovery: userRouteDiscovery,
419
405
  serverBuildFile,
420
406
  serverBundles,
421
407
  serverModuleFormat,
@@ -423,7 +409,7 @@ async function resolveConfig({
423
409
  } = {
424
410
  ...defaults,
425
411
  // Default values should be completely overridden by user/preset config, not merged
426
- ...userAndPresetConfigs
412
+ ...mergeReactRouterConfig(...presets, reactRouterUserConfig)
427
413
  };
428
414
  if (!ssr && serverBundles) {
429
415
  serverBundles = void 0;
@@ -434,32 +420,6 @@ async function resolveConfig({
434
420
  "The `prerender` config must be a boolean, an array of string paths, or a function returning a boolean or array of string paths"
435
421
  );
436
422
  }
437
- let routeDiscovery;
438
- if (userRouteDiscovery == null) {
439
- if (ssr) {
440
- routeDiscovery = {
441
- mode: "lazy",
442
- manifestPath: "/__manifest"
443
- };
444
- } else {
445
- routeDiscovery = { mode: "initial" };
446
- }
447
- } else if (userRouteDiscovery.mode === "initial") {
448
- routeDiscovery = userRouteDiscovery;
449
- } else if (userRouteDiscovery.mode === "lazy") {
450
- if (!ssr) {
451
- return err(
452
- 'The `routeDiscovery.mode` config cannot be set to "lazy" when setting `ssr:false`'
453
- );
454
- }
455
- let { manifestPath } = userRouteDiscovery;
456
- if (manifestPath != null && !manifestPath.startsWith("/")) {
457
- return err(
458
- 'The `routeDiscovery.manifestPath` config must be a root-relative pathname beginning with a slash (i.e., "/__manifest")'
459
- );
460
- }
461
- routeDiscovery = userRouteDiscovery;
462
- }
463
423
  let appDirectory = import_pathe3.default.resolve(root, userAppDirectory || "app");
464
424
  let buildDirectory = import_pathe3.default.resolve(root, userBuildDirectory);
465
425
  let rootRouteFile = findEntry(appDirectory, "root");
@@ -527,7 +487,6 @@ async function resolveConfig({
527
487
  future,
528
488
  prerender,
529
489
  routes,
530
- routeDiscovery,
531
490
  serverBuildFile,
532
491
  serverBundles,
533
492
  serverModuleFormat,
@@ -540,13 +499,12 @@ async function resolveConfig({
540
499
  }
541
500
  async function createConfigLoader({
542
501
  rootDirectory: root,
543
- watch: watch2,
544
- mode
502
+ watch: watch2
545
503
  }) {
546
504
  root = root ?? process.env.REACT_ROUTER_ROOT ?? process.cwd();
547
505
  let viteNodeContext = await createContext({
548
506
  root,
549
- mode
507
+ mode: watch2 ? "development" : "production"
550
508
  });
551
509
  let reactRouterConfigFile = findEntry(root, "react-router.config", {
552
510
  absolute: true
@@ -637,18 +595,7 @@ async function resolveEntryFiles({
637
595
  let userEntryServerFile = findEntry(appDirectory, "entry.server");
638
596
  let entryServerFile;
639
597
  let entryClientFile = userEntryClientFile || "entry.client.tsx";
640
- let packageJsonPath = findEntry(rootDirectory, "package", {
641
- extensions: [".json"],
642
- absolute: true,
643
- walkParents: true
644
- });
645
- if (!packageJsonPath) {
646
- throw new Error(
647
- `Could not find package.json in ${rootDirectory} or any of its parent directories`
648
- );
649
- }
650
- let packageJsonDirectory = import_pathe3.default.dirname(packageJsonPath);
651
- let pkgJson = await import_package_json.default.load(packageJsonDirectory);
598
+ let pkgJson = await import_package_json.default.load(rootDirectory);
652
599
  let deps = pkgJson.content.dependencies ?? {};
653
600
  if (userEntryServerFile) {
654
601
  entryServerFile = userEntryServerFile;
@@ -671,7 +618,7 @@ async function resolveEntryFiles({
671
618
  await pkgJson.save();
672
619
  let packageManager = detectPackageManager() ?? "npm";
673
620
  (0, import_node_child_process.execSync)(`${packageManager} install`, {
674
- cwd: packageJsonDirectory,
621
+ cwd: rootDirectory,
675
622
  stdio: "inherit"
676
623
  });
677
624
  }
@@ -683,24 +630,13 @@ async function resolveEntryFiles({
683
630
  }
684
631
  var entryExts = [".js", ".jsx", ".ts", ".tsx"];
685
632
  function findEntry(dir, basename2, options) {
686
- let currentDir = import_pathe3.default.resolve(dir);
687
- let { root } = import_pathe3.default.parse(currentDir);
688
- while (true) {
689
- for (let ext of options?.extensions ?? entryExts) {
690
- let file = import_pathe3.default.resolve(currentDir, basename2 + ext);
691
- if (import_node_fs.default.existsSync(file)) {
692
- return options?.absolute ?? false ? file : import_pathe3.default.relative(dir, file);
693
- }
694
- }
695
- if (!options?.walkParents) {
696
- return void 0;
633
+ for (let ext of entryExts) {
634
+ let file = import_pathe3.default.resolve(dir, basename2 + ext);
635
+ if (import_node_fs.default.existsSync(file)) {
636
+ return options?.absolute ?? false ? file : import_pathe3.default.relative(dir, file);
697
637
  }
698
- let parentDir = import_pathe3.default.dirname(currentDir);
699
- if (currentDir === root || parentDir === currentDir) {
700
- return void 0;
701
- }
702
- currentDir = parentDir;
703
638
  }
639
+ return void 0;
704
640
  }
705
641
 
706
642
  // vite/babel.ts
@@ -842,8 +778,8 @@ function formatParamProperties(fullpath2) {
842
778
  }
843
779
 
844
780
  // typegen/index.ts
845
- async function watch(rootDirectory, { mode, logger }) {
846
- const ctx = await createContext2({ rootDirectory, mode, watch: true });
781
+ async function watch(rootDirectory, { logger } = {}) {
782
+ const ctx = await createContext2({ rootDirectory, watch: true });
847
783
  await writeAll(ctx);
848
784
  logger?.info(import_picocolors2.default.green("generated types"), { timestamp: true, clear: true });
849
785
  ctx.configLoader.onChange(async ({ result, routeConfigChanged }) => {
@@ -866,10 +802,9 @@ async function watch(rootDirectory, { mode, logger }) {
866
802
  }
867
803
  async function createContext2({
868
804
  rootDirectory,
869
- watch: watch2,
870
- mode
805
+ watch: watch2
871
806
  }) {
872
- const configLoader = await createConfigLoader({ rootDirectory, mode, watch: watch2 });
807
+ const configLoader = await createConfigLoader({ rootDirectory, watch: watch2 });
873
808
  const configResult = await configLoader.getConfig();
874
809
  if (!configResult.ok) {
875
810
  throw new Error(configResult.error);
@@ -950,7 +885,6 @@ var virtual = import_dedent2.default`
950
885
  export const isSpaMode: ServerBuild["isSpaMode"];
951
886
  export const prerender: ServerBuild["prerender"];
952
887
  export const publicPath: ServerBuild["publicPath"];
953
- export const routeDiscovery: ServerBuild["routeDiscovery"];
954
888
  export const routes: ServerBuild["routes"];
955
889
  export const ssr: ServerBuild["ssr"];
956
890
  export const unstable_getCriticalCss: ServerBuild["unstable_getCriticalCss"];
@@ -1011,9 +945,7 @@ function fromNodeRequest(nodeReq, nodeRes) {
1011
945
  }
1012
946
  async function toNodeRequest(res, nodeRes) {
1013
947
  nodeRes.statusCode = res.status;
1014
- if (!nodeRes.req || nodeRes.req.httpVersionMajor < 2) {
1015
- nodeRes.statusMessage = res.statusText;
1016
- }
948
+ nodeRes.statusMessage = res.statusText;
1017
949
  let cookiesStrings = [];
1018
950
  for (let [name, value] of res.headers) {
1019
951
  if (name === "set-cookie") {
@@ -2422,9 +2354,6 @@ var reactRouterVitePlugin = () => {
2422
2354
  export const ssr = ${ctx.reactRouterConfig.ssr};
2423
2355
  export const isSpaMode = ${isSpaMode};
2424
2356
  export const prerender = ${JSON.stringify(prerenderPaths)};
2425
- export const routeDiscovery = ${JSON.stringify(
2426
- ctx.reactRouterConfig.routeDiscovery
2427
- )};
2428
2357
  export const publicPath = ${JSON.stringify(ctx.publicPath)};
2429
2358
  export const entry = { module: entryServer };
2430
2359
  export const routes = {
@@ -2758,17 +2687,14 @@ var reactRouterVitePlugin = () => {
2758
2687
  prefix: "[react-router]"
2759
2688
  });
2760
2689
  rootDirectory = viteUserConfig.root ?? process.env.REACT_ROUTER_ROOT ?? process.cwd();
2761
- let mode = viteConfigEnv.mode;
2762
2690
  if (viteCommand === "serve") {
2763
2691
  typegenWatcherPromise = watch(rootDirectory, {
2764
- mode,
2765
2692
  // ignore `info` logs from typegen since they are redundant when Vite plugin logs are active
2766
2693
  logger: vite2.createLogger("warn", { prefix: "[react-router]" })
2767
2694
  });
2768
2695
  }
2769
2696
  reactRouterConfigLoader = await createConfigLoader({
2770
2697
  rootDirectory,
2771
- mode,
2772
2698
  watch: viteCommand === "serve"
2773
2699
  });
2774
2700
  await updatePluginContext();
@@ -3161,7 +3087,6 @@ var reactRouterVitePlugin = () => {
3161
3087
  ].join("\n")
3162
3088
  );
3163
3089
  }
3164
- process.env.IS_RR_BUILD_REQUEST = "yes";
3165
3090
  if (isPrerenderingEnabled(ctx.reactRouterConfig)) {
3166
3091
  await handlePrerender(
3167
3092
  viteConfig,
@@ -3824,6 +3749,11 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
3824
3749
  }
3825
3750
  }
3826
3751
  let buildRoutes = createPrerenderRoutes(build.routes);
3752
+ let headers = {
3753
+ // Header that can be used in the loader to know if you're running at
3754
+ // build time or runtime
3755
+ "X-React-Router-Prerender": "yes"
3756
+ };
3827
3757
  for (let path7 of build.prerender) {
3828
3758
  let matches = (0, import_react_router2.matchRoutes)(buildRoutes, `/${path7}/`.replace(/^\/\/+/, "/"));
3829
3759
  if (!matches) {
@@ -3842,14 +3772,16 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
3842
3772
  [leafRoute.id],
3843
3773
  clientBuildDirectory,
3844
3774
  reactRouterConfig,
3845
- viteConfig
3775
+ viteConfig,
3776
+ { headers }
3846
3777
  );
3847
3778
  await prerenderResourceRoute(
3848
3779
  handler,
3849
3780
  path7,
3850
3781
  clientBuildDirectory,
3851
3782
  reactRouterConfig,
3852
- viteConfig
3783
+ viteConfig,
3784
+ { headers }
3853
3785
  );
3854
3786
  } else {
3855
3787
  viteConfig.logger.warn(
@@ -3868,7 +3800,8 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
3868
3800
  null,
3869
3801
  clientBuildDirectory,
3870
3802
  reactRouterConfig,
3871
- viteConfig
3803
+ viteConfig,
3804
+ { headers }
3872
3805
  );
3873
3806
  }
3874
3807
  await prerenderRoute(
@@ -3879,9 +3812,10 @@ async function handlePrerender(viteConfig, reactRouterConfig, serverBuildDirecto
3879
3812
  viteConfig,
3880
3813
  data ? {
3881
3814
  headers: {
3815
+ ...headers,
3882
3816
  "X-React-Router-Prerender-Data": encodeURI(data)
3883
3817
  }
3884
- } : void 0
3818
+ } : { headers }
3885
3819
  );
3886
3820
  }
3887
3821
  }
@@ -4445,9 +4379,8 @@ async function getEnvironmentOptionsResolvers(ctx, viteCommand) {
4445
4379
  ""
4446
4380
  ) : null;
4447
4381
  let routeChunkSuffix = routeChunkName ? `-${(0, import_kebabCase.default)(routeChunkName)}` : "";
4448
- let assetsDir = (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi ? viteUserConfig?.environments?.client?.build?.assetsDir : null) ?? viteUserConfig?.build?.assetsDir ?? "assets";
4449
4382
  return path6.posix.join(
4450
- assetsDir,
4383
+ (ctx.reactRouterConfig.future.unstable_viteEnvironmentApi ? viteUserConfig?.environments?.client?.build?.assetsDir : viteUserConfig?.build?.assetsDir) ?? "assets",
4451
4384
  `[name]${routeChunkSuffix}-[hash].js`
4452
4385
  );
4453
4386
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-router/dev",
3
- "version": "0.0.0-experimental-818f8e08d",
3
+ "version": "0.0.0-experimental-e56aa53bc",
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": "0.0.0-experimental-818f8e08d"
89
+ "@react-router/node": "0.0.0-experimental-e56aa53bc"
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": "^4.2.0",
113
- "react-router": "^0.0.0-experimental-818f8e08d",
114
- "@react-router/serve": "0.0.0-experimental-818f8e08d"
113
+ "react-router": "^0.0.0-experimental-e56aa53bc",
114
+ "@react-router/serve": "0.0.0-experimental-e56aa53bc"
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 || ^4.0.0",
120
- "@react-router/serve": "^0.0.0-experimental-818f8e08d",
121
- "react-router": "^0.0.0-experimental-818f8e08d"
120
+ "@react-router/serve": "^0.0.0-experimental-e56aa53bc",
121
+ "react-router": "^0.0.0-experimental-e56aa53bc"
122
122
  },
123
123
  "peerDependenciesMeta": {
124
124
  "@react-router/serve": {