@react-router/dev 8.3.1 → 8.4.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,21 @@
1
1
  # `@react-router/dev`
2
2
 
3
+ ## v8.4.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Fix action submissions behind an HTTPS reverse proxy in `react-router dev` and `vite preview` by using `X-Forwarded-Proto` when constructing `request.url` ([#15466](https://github.com/remix-run/react-router/pull/15466))
8
+ - No React Router configuration is required
9
+ - The URL host continues to come from `Host`, not `X-Forwarded-Host`
10
+ - Configure reverse proxies to overwrite client-supplied `X-Forwarded-Proto` headers
11
+ - Do not expose dev or preview servers publicly
12
+ - Pass development conditions as CLI flags when relaunching the dev process ([#15435](https://github.com/remix-run/react-router/pull/15435))
13
+ - Fix stack trace locations for split route modules when source maps are enabled in the `reactRouter` Vite plugin ([#15440](https://github.com/remix-run/react-router/pull/15440))
14
+ - Updated dependencies:
15
+ - [`react-router@8.4.0`](https://github.com/remix-run/react-router/releases/tag/react-router@8.4.0)
16
+ - [`@react-router/node@8.4.0`](https://github.com/remix-run/react-router/releases/tag/@react-router/node@8.4.0)
17
+ - [`@react-router/serve@8.4.0`](https://github.com/remix-run/react-router/releases/tag/@react-router/serve@8.4.0)
18
+
3
19
  ## v8.3.1
4
20
 
5
21
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v8.3.1
2
+ * @react-router/dev v8.4.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import { _ as getVite, v as preloadVite } from "./typegen-DxFMuBQP.js";
11
+ import { _ as getVite, v as preloadVite } from "./typegen-WywajSVn.js";
12
12
  //#region vite/build.ts
13
13
  async function build(root, viteBuildOptions) {
14
14
  await preloadVite();
package/dist/cli/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * @react-router/dev v8.3.1
3
+ * @react-router/dev v8.4.0
4
4
  *
5
5
  * Copyright (c) Remix Software Inc.
6
6
  *
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * @license MIT
11
11
  */
12
- import { _ as getVite, l as hasNodeDependency, n as watch, t as run$1, u as loadConfig, v as preloadVite } from "../typegen-DxFMuBQP.js";
12
+ import { _ as getVite, l as hasNodeDependency, n as watch, t as run$1, u as loadConfig, v as preloadVite } from "../typegen-WywajSVn.js";
13
13
  import { createRequire } from "node:module";
14
14
  import { parseArgs } from "node:util";
15
15
  import semver from "semver";
@@ -107,20 +107,34 @@ async function hasReactRouterRscPlugin({ root, viteBuildOptions: { config, logLe
107
107
  //#endregion
108
108
  //#region restart-with-conditions.ts
109
109
  /**
110
- * Restarts the current Node process, appending new flags to the
111
- * existing NODE_OPTIONS. SIGINT/SIGTERM are always forwarded to the child.
110
+ * Build the child process invocation used to relaunch the CLI with extra flags.
111
+ *
112
+ * Extra flags are placed on argv immediately after the runtime binary. Putting
113
+ * them in NODE_OPTIONS is not portable: Bun silently ignores `--conditions`
114
+ * there, so the child would restart again and hit the already-restarted guard.
112
115
  */
113
- function restartWithMergedOptions(nodeOptions) {
114
- if (process$1.env.REACT_ROUTER_DEV_RESTARTED === "true") throw new Error("restartWithMergedOptions() was called, but the process has already been restarted. This is likely a bug in @react-router/dev.");
115
- const mergedOptions = [process$1.env.NODE_OPTIONS, nodeOptions].filter(Boolean).join(" ").trim();
116
- console.log(`[restart] Relaunching with NODE_OPTIONS: ${mergedOptions}`);
117
- const [cmd, ...args] = process$1.argv;
118
- const child = spawn(cmd, args, {
116
+ function resolveRestartSpawn(argv, extraOptions, env) {
117
+ const extraArgs = extraOptions.split(/\s+/).filter(Boolean);
118
+ const [command, ...args] = argv;
119
+ return {
120
+ command,
121
+ args: [...extraArgs, ...args],
119
122
  env: {
120
- ...process$1.env,
121
- NODE_OPTIONS: mergedOptions,
123
+ ...env,
122
124
  REACT_ROUTER_DEV_RESTARTED: "true"
123
- },
125
+ }
126
+ };
127
+ }
128
+ /**
129
+ * Restarts the current process with extra CLI flags after argv[0].
130
+ * SIGINT/SIGTERM are always forwarded to the child.
131
+ */
132
+ function restartWithMergedOptions(nodeOptions) {
133
+ if (process$1.env.REACT_ROUTER_DEV_RESTARTED === "true") throw new Error("restartWithMergedOptions() was called, but the process has already been restarted. This is likely a bug in @react-router/dev.");
134
+ const { command, args, env } = resolveRestartSpawn(process$1.argv, nodeOptions, process$1.env);
135
+ console.log(`[restart] Relaunching with ${nodeOptions}`);
136
+ const child = spawn(command, args, {
137
+ env,
124
138
  stdio: "inherit"
125
139
  });
126
140
  let signalHandlers = ["SIGINT", "SIGTERM"].map((sig) => {
@@ -158,7 +172,7 @@ async function routes(rootDirectory, flags = {}) {
158
172
  }
159
173
  async function build(root, options = {}) {
160
174
  root = resolveRootDirectory(root, options);
161
- let { build } = await import("../build-Ou3B3epu.js");
175
+ let { build } = await import("../build-CsJF5XUO.js");
162
176
  if (options.profile) await start();
163
177
  try {
164
178
  await build(root, options);
@@ -168,7 +182,7 @@ async function build(root, options = {}) {
168
182
  }
169
183
  async function dev(root, options = {}) {
170
184
  if (developmentConditionEnabled) {
171
- let { dev } = await import("../dev-DFccbHpq.js");
185
+ let { dev } = await import("../dev-_GaivbeG.js");
172
186
  if (options.profile) await start();
173
187
  exitHook(() => stop(console.info));
174
188
  root = resolveRootDirectory(root, options);
package/dist/config.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v8.3.1
2
+ * @react-router/dev v8.4.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v8.3.1
2
+ * @react-router/dev v8.4.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import { _ as getVite, v as preloadVite } from "./typegen-DxFMuBQP.js";
11
+ import { _ as getVite, v as preloadVite } from "./typegen-WywajSVn.js";
12
12
  import { n as start, r as stop, t as getSession } from "./cli/index.js";
13
13
  import colors from "picocolors";
14
14
  //#region vite/dev.ts
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v8.3.1
2
+ * @react-router/dev v8.4.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 v8.3.1
2
+ * @react-router/dev v8.4.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -8,5 +8,5 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import { a as prefix, i as layout, n as getAppDirectory, o as relative, r as index, s as route } from "./routes-C-NBxWG3.js";
11
+ import { a as prefix, i as layout, n as getAppDirectory, o as relative, r as index, s as route } from "./routes-BFdkiVnp.js";
12
12
  export { getAppDirectory, index, layout, prefix, relative, route };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v8.3.1
2
+ * @react-router/dev v8.4.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import { c as setAppDirectory, l as validateRouteConfig, t as configRoutesToRouteManifest, u as invariant } from "./routes-C-NBxWG3.js";
11
+ import { c as setAppDirectory, l as validateRouteConfig, t as configRoutesToRouteManifest, u as invariant } from "./routes-BFdkiVnp.js";
12
12
  import { createRequire } from "node:module";
13
13
  import colors from "picocolors";
14
14
  import fs from "node:fs";
package/dist/vite.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v8.3.1
2
+ * @react-router/dev v8.4.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -8,8 +8,8 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- import { _ as getVite, a as t, c as createConfigLoader, d as resolveEntryFiles, f as resolveRSCEntryFiles, g as getUserBuildRollupOptions, h as defineOptimizeDepsCompilerOptions, i as parse$1, l as hasNodeDependency, m as defineCompilerOptions, n as watch, o as traverse, p as ssrExternals, r as generate, s as configRouteToBranchRoute, v as preloadVite } from "./typegen-DxFMuBQP.js";
12
- import { u as invariant } from "./routes-C-NBxWG3.js";
11
+ import { _ as getVite, a as t, c as createConfigLoader, d as resolveEntryFiles, f as resolveRSCEntryFiles, g as getUserBuildRollupOptions, h as defineOptimizeDepsCompilerOptions, i as parse$1, l as hasNodeDependency, m as defineCompilerOptions, n as watch, o as traverse, p as ssrExternals, r as generate, s as configRouteToBranchRoute, v as preloadVite } from "./typegen-WywajSVn.js";
12
+ import { u as invariant } from "./routes-BFdkiVnp.js";
13
13
  import { createRequire } from "node:module";
14
14
  import colors from "picocolors";
15
15
  import { existsSync, readFileSync, readdirSync } from "node:fs";
@@ -37,7 +37,13 @@ import { readFile as readFile$1 } from "fs/promises";
37
37
  async function fromNodeRequest(nodeReq, nodeRes) {
38
38
  invariant(nodeReq.originalUrl, "Expected `nodeReq.originalUrl` to be defined");
39
39
  nodeReq.url = nodeReq.originalUrl;
40
- return createRequest(nodeReq, nodeRes);
40
+ return createRequest(nodeReq, nodeRes, { protocol: getForwardedProtocol(nodeReq) });
41
+ }
42
+ function getForwardedProtocol(nodeReq) {
43
+ let forwardedProto = nodeReq.headers["x-forwarded-proto"];
44
+ let proto = (Array.isArray(forwardedProto) ? forwardedProto[0] : forwardedProto)?.split(",")[0].trim().toLowerCase();
45
+ if (proto?.endsWith(":")) proto = proto.slice(0, -1);
46
+ return proto === "http" || proto === "https" ? `${proto}:` : void 0;
41
47
  }
42
48
  //#endregion
43
49
  //#region vite/resolve-file-url.ts
@@ -614,9 +620,9 @@ const routeChunkExportNames = [
614
620
  ];
615
621
  const mainChunkName = "main";
616
622
  const routeChunkNames = ["main", ...routeChunkExportNames];
617
- function getRouteChunkCode(code, chunkName, cache, cacheKey) {
618
- if (chunkName === mainChunkName) return omitChunkedExports(code, routeChunkExportNames, {}, cache, cacheKey);
619
- return getChunkedExport(code, chunkName, {}, cache, cacheKey);
623
+ function getRouteChunkCode(code, chunkName, cache, cacheKey, generateOptions = {}) {
624
+ if (chunkName === mainChunkName) return omitChunkedExports(code, routeChunkExportNames, generateOptions, cache, cacheKey);
625
+ return getChunkedExport(code, chunkName, generateOptions, cache, cacheKey);
620
626
  }
621
627
  const routeChunkQueryStringPrefix = "?route-chunk=";
622
628
  const routeChunkQueryStrings = {
@@ -1817,11 +1823,14 @@ const reactRouterVitePlugin = () => {
1817
1823
  let routeFileName = path$2.basename(routeModuleId);
1818
1824
  let sourceExports = await getRouteModuleExports(viteChildCompiler, ctx, routeModuleId);
1819
1825
  let { chunkedExports = [] } = options?.ssr ? {} : await detectRouteChunksIfEnabled(cache, ctx, id, code);
1820
- return `export { ${sourceExports.filter((exportName) => {
1821
- let isRouteEntryExport = options?.ssr && SERVER_ONLY_ROUTE_EXPORTS.includes(exportName) || CLIENT_ROUTE_EXPORTS$1.includes(exportName);
1822
- let isChunkedExport = chunkedExports.includes(exportName);
1823
- return isRouteEntryExport && !isChunkedExport;
1824
- }).join(", ")} } from "./${routeFileName}";`;
1826
+ return {
1827
+ code: `export { ${sourceExports.filter((exportName) => {
1828
+ let isRouteEntryExport = options?.ssr && SERVER_ONLY_ROUTE_EXPORTS.includes(exportName) || CLIENT_ROUTE_EXPORTS$1.includes(exportName);
1829
+ let isChunkedExport = chunkedExports.includes(exportName);
1830
+ return isRouteEntryExport && !isChunkedExport;
1831
+ }).join(", ")} } from "./${routeFileName}";`,
1832
+ map: { mappings: "" }
1833
+ };
1825
1834
  }
1826
1835
  },
1827
1836
  {
@@ -2476,7 +2485,10 @@ async function detectRouteChunksIfEnabled(cache, ctx, id, input) {
2476
2485
  }
2477
2486
  async function getRouteChunkIfEnabled(cache, ctx, id, chunkName, input) {
2478
2487
  if (!ctx.reactRouterConfig.splitRouteModules) return null;
2479
- return getRouteChunkCode(await resolveRouteFileCode(ctx, input), chunkName, cache, normalizeRelativeFilePath(id, ctx.reactRouterConfig) + (typeof input === "string" ? "" : "?read"));
2488
+ return getRouteChunkCode(await resolveRouteFileCode(ctx, input), chunkName, cache, normalizeRelativeFilePath(id, ctx.reactRouterConfig) + (typeof input === "string" ? "" : "?read"), {
2489
+ sourceMaps: true,
2490
+ sourceFileName: path$2.basename(id.split("?")[0])
2491
+ });
2480
2492
  }
2481
2493
  function validateRouteChunks$1({ ctx, id, valid }) {
2482
2494
  if (isRootRouteModuleId(ctx, id)) return;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@react-router/dev",
3
3
  "type": "module",
4
- "version": "8.3.1",
4
+ "version": "8.4.0",
5
5
  "description": "Dev tools and CLI for React Router",
6
6
  "keywords": [
7
7
  "react",
@@ -107,7 +107,7 @@
107
107
  "semver": "^7.8.1",
108
108
  "tinyglobby": "^0.2.16",
109
109
  "valibot": "^1.4.1",
110
- "@react-router/node": "8.3.1"
110
+ "@react-router/node": "8.4.0"
111
111
  },
112
112
  "devDependencies": {
113
113
  "@babel/plugin-syntax-jsx": "^7.29.7",
@@ -132,8 +132,8 @@
132
132
  "vite": "^7.0.0",
133
133
  "wireit": "0.14.12",
134
134
  "wrangler": "^4.95.0",
135
- "@react-router/serve": "8.3.1",
136
- "react-router": "^8.3.1"
135
+ "react-router": "^8.4.0",
136
+ "@react-router/serve": "8.4.0"
137
137
  },
138
138
  "peerDependencies": {
139
139
  "@vitejs/plugin-rsc": "~0.5.26",
@@ -141,8 +141,8 @@
141
141
  "typescript": "^5.1.0 || ^6.0.0 || ^7.0.0",
142
142
  "vite": "^7.0.0 || ^8.0.0",
143
143
  "wrangler": "^4.0.0",
144
- "@react-router/serve": "^8.3.1",
145
- "react-router": "^8.3.1"
144
+ "@react-router/serve": "^8.4.0",
145
+ "react-router": "^8.4.0"
146
146
  },
147
147
  "peerDependenciesMeta": {
148
148
  "@vitejs/plugin-rsc": {