@react-router/dev 0.0.0-nightly-a41323a0b-20241011 → 7.0.0-pre.1

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,247 @@
1
1
  # `@remix-run/dev`
2
2
 
3
+ ## 7.0.0-pre.1
4
+
5
+ ### Minor Changes
6
+
7
+ - Add `prefix` route config helper to `@react-router/dev/routes` ([#12094](https://github.com/remix-run/react-router/pull/12094))
8
+
9
+ ### Patch Changes
10
+
11
+ - - Fix `react-router-serve` handling of prerendered HTML files by removing the `redirect: false` option so it now falls back on the default `redirect: true` behavior of redirecting from `/folder` -> `/folder/` which will then pick up `/folder/index.html` from disk. See https://expressjs.com/en/resources/middleware/serve-static.html ([#12071](https://github.com/remix-run/react-router/pull/12071))
12
+ - Proxy prerendered loader data into prerender pass for HTML files to avoid double-invocations of the loader at build time
13
+ - Updated dependencies:
14
+ - `react-router@7.0.0-pre.1`
15
+ - `@react-router/serve@7.0.0-pre.1`
16
+ - `@react-router/node@7.0.0-pre.1`
17
+
18
+ ## 7.0.0-pre.0
19
+
20
+ ### Major Changes
21
+
22
+ - For Remix consumers migrating to React Router, the `vitePlugin` and `cloudflareDevProxyVitePlugin` exports have been renamed and moved. ([#11904](https://github.com/remix-run/react-router/pull/11904))
23
+
24
+ ```diff
25
+ -import {
26
+ - vitePlugin as remix,
27
+ - cloudflareDevProxyVitePlugin,
28
+ -} from "@remix/dev";
29
+
30
+ +import { reactRouter } from "@react-router/dev/vite";
31
+ +import { cloudflareDevProxy } from "@react-router/dev/vite/cloudflare";
32
+ ```
33
+
34
+ - Remove single_fetch future flag. ([#11522](https://github.com/remix-run/react-router/pull/11522))
35
+ - update minimum node version to 18 ([#11690](https://github.com/remix-run/react-router/pull/11690))
36
+ - Add `exports` field to all packages ([#11675](https://github.com/remix-run/react-router/pull/11675))
37
+ - node package no longer re-exports from react-router ([#11702](https://github.com/remix-run/react-router/pull/11702))
38
+ - For Remix consumers migrating to React Router who used the Vite plugin's `buildEnd` hook, the resolved `reactRouterConfig` object no longer contains a `publicPath` property since this belongs to Vite, not React Router. ([#11575](https://github.com/remix-run/react-router/pull/11575))
39
+ - For Remix consumers migrating to React Router, the Vite plugin's `manifest` option has been removed. ([#11573](https://github.com/remix-run/react-router/pull/11573))
40
+
41
+ The `manifest` option been superseded by the more powerful `buildEnd` hook since it's passed the `buildManifest` argument. You can still write the build manifest to disk if needed, but you'll most likely find it more convenient to write any logic depending on the build manifest within the `buildEnd` hook itself.
42
+
43
+ If you were using the `manifest` option, you can replace it with a `buildEnd` hook that writes the manifest to disk like this:
44
+
45
+ ```js
46
+ import { reactRouter } from "@react-router/dev/vite";
47
+ import { writeFile } from "node:fs/promises";
48
+
49
+ export default {
50
+ plugins: [
51
+ reactRouter({
52
+ async buildEnd({ buildManifest }) {
53
+ await writeFile(
54
+ "build/manifest.json",
55
+ JSON.stringify(buildManifest, null, 2),
56
+ "utf-8"
57
+ );
58
+ },
59
+ }),
60
+ ],
61
+ };
62
+ ```
63
+
64
+ - Update default `isbot` version to v5 and drop support for `isbot@3` ([#11770](https://github.com/remix-run/react-router/pull/11770))
65
+
66
+ - If you have `isbot@4` or `isbot@5` in your `package.json`:
67
+ - You do not need to make any changes
68
+ - If you have `isbot@3` in your `package.json` and you have your own `entry.server.tsx` file in your repo
69
+ - You do not need to make any changes
70
+ - You can upgrade to `isbot@5` independent of the React Router v7 upgrade
71
+ - If you have `isbot@3` in your `package.json` and you do not have your own `entry.server.tsx` file in your repo
72
+ - You are using the internal default entry provided by React Router v7 and you will need to upgrade to `isbot@5` in your `package.json`
73
+
74
+ - For Remix consumers migrating to React Router, Vite manifests (i.e. `.vite/manifest.json`) are now written within each build subdirectory, e.g. `build/client/.vite/manifest.json` and `build/server/.vite/manifest.json` instead of `build/.vite/client-manifest.json` and `build/.vite/server-manifest.json`. This means that the build output is now much closer to what you'd expect from a typical Vite project. ([#11573](https://github.com/remix-run/react-router/pull/11573))
75
+
76
+ Originally the Remix Vite plugin moved all Vite manifests to a root-level `build/.vite` directory to avoid accidentally serving them in production, particularly from the client build. This was later improved with additional logic that deleted these Vite manifest files at the end of the build process unless Vite's `build.manifest` had been enabled within the app's Vite config. This greatly reduced the risk of accidentally serving the Vite manifests in production since they're only present when explicitly asked for. As a result, we can now assume that consumers will know that they need to manage these additional files themselves, and React Router can safely generate a more standard Vite build output.
77
+
78
+ ### Minor Changes
79
+
80
+ - Params, loader data, and action data as props for route component exports ([#11961](https://github.com/remix-run/react-router/pull/11961))
81
+
82
+ ```tsx
83
+ export default function Component({ params, loaderData, actionData }) {}
84
+
85
+ export function HydrateFallback({ params }) {}
86
+ export function ErrorBoundary({ params, loaderData, actionData }) {}
87
+ ```
88
+
89
+ - Remove internal entry.server.spa.tsx implementation ([#11681](https://github.com/remix-run/react-router/pull/11681))
90
+ - ### Typesafety improvements ([#12019](https://github.com/remix-run/react-router/pull/12019))
91
+
92
+ React Router now generates types for each of your route modules.
93
+ You can access those types by importing them from `./+types.<route filename without extension>`.
94
+ For example:
95
+
96
+ ```ts
97
+ // app/routes/product.tsx
98
+ import type * as Route from "./+types.product";
99
+
100
+ export function loader({ params }: Route.LoaderArgs) {}
101
+
102
+ export default function Component({ loaderData }: Route.ComponentProps) {}
103
+ ```
104
+
105
+ This initial implementation targets type inference for:
106
+
107
+ - `Params` : Path parameters from your routing config in `routes.ts` including file-based routing
108
+ - `LoaderData` : Loader data from `loader` and/or `clientLoader` within your route module
109
+ - `ActionData` : Action data from `action` and/or `clientAction` within your route module
110
+
111
+ These types are then used to create types for route export args and props:
112
+
113
+ - `LoaderArgs`
114
+ - `ClientLoaderArgs`
115
+ - `ActionArgs`
116
+ - `ClientActionArgs`
117
+ - `HydrateFallbackProps`
118
+ - `ComponentProps` (for the `default` export)
119
+ - `ErrorBoundaryProps`
120
+
121
+ In the future, we plan to add types for the rest of the route module exports: `meta`, `links`, `headers`, `shouldRevalidate`, etc.
122
+ We also plan to generate types for typesafe `Link`s:
123
+
124
+ ```tsx
125
+ <Link to="/products/:id" params={{ id: 1 }} />
126
+ // ^^^^^^^^^^^^^ ^^^^^^^^^
127
+ // typesafe `to` and `params` based on the available routes in your app
128
+ ```
129
+
130
+ #### Setup
131
+
132
+ React Router will generate types into a `.react-router/` directory at the root of your app.
133
+ This directory is fully managed by React Router and is derived based on your route config (`routes.ts`).
134
+
135
+ 👉 **Add `.react-router/` to `.gitignore`**
136
+
137
+ ```txt
138
+ .react-router
139
+ ```
140
+
141
+ You should also ensure that generated types for routes are always present before running typechecking,
142
+ especially for running typechecking in CI.
143
+
144
+ 👉 **Add `react-router typegen` to your `typecheck` command in `package.json`**
145
+
146
+ ```json
147
+ {
148
+ "scripts": {
149
+ "typecheck": "react-router typegen && tsc"
150
+ }
151
+ }
152
+ ```
153
+
154
+ To get TypeScript to use those generated types, you'll need to add them to `include` in `tsconfig.json`.
155
+ And to be able to import them as if they files next to your route modules, you'll also need to configure `rootDirs`.
156
+
157
+ 👉 **Configure `tsconfig.json` for generated types**
158
+
159
+ ```json
160
+ {
161
+ "include": [".react-router/types/**/*"],
162
+ "compilerOptions": {
163
+ "rootDirs": [".", "./.react-router/types"]
164
+ }
165
+ }
166
+ ```
167
+
168
+ #### `typegen` command
169
+
170
+ You can manually generate types with the new `typegen` command:
171
+
172
+ ```sh
173
+ react-router typegen
174
+ ```
175
+
176
+ However, manual type generation is tedious and types can get out of sync quickly if you ever forget to run `typegen`.
177
+ Instead, we recommend that you setup our new TypeScript plugin which will automatically generate fresh types whenever routes change.
178
+ That way, you'll always have up-to-date types.
179
+
180
+ #### TypeScript plugin
181
+
182
+ To get automatic type generation, you can use our new TypeScript plugin.
183
+
184
+ 👉 **Add the TypeScript plugin to `tsconfig.json`**
185
+
186
+ ```json
187
+ {
188
+ "compilerOptions": {
189
+ "plugins": [{ "name": "@react-router/dev" }]
190
+ }
191
+ }
192
+ ```
193
+
194
+ We plan to add some other goodies to our TypeScript plugin soon, including:
195
+
196
+ - Automatic `jsdoc` for route exports that include links to official docs
197
+ - Autocomplete for route exports
198
+ - Warnings for non-HMR compliant exports
199
+
200
+ ##### VSCode
201
+
202
+ TypeScript looks for plugins registered in `tsconfig.json` in the local `node_modules/`,
203
+ but VSCode ships with its own copy of TypeScript that is installed outside of your project.
204
+ For TypeScript plugins to work, you'll need to tell VSCode to use the local workspace version of TypeScript.
205
+ For security reasons, [VSCode won't use the workspace version of TypeScript](https://code.visualstudio.com/docs/typescript/typescript-compiling#_using-the-workspace-version-of-typescript) until you manually opt-in.
206
+
207
+ Your project should have a `.vscode/settings.json` with the following settings:
208
+
209
+ ```json
210
+ {
211
+ "typescript.tsdk": "node_modules/typescript/lib",
212
+ "typescript.enablePromptUseWorkspaceTsdk": true
213
+ }
214
+ ```
215
+
216
+ That way [VSCode will ask you](https://code.visualstudio.com/updates/v1_45#_prompt-users-to-switch-to-the-workspace-version-of-typescript) if you want to use the workspace version of TypeScript the first time you open a TS file in that project.
217
+
218
+ > [!IMPORTANT]
219
+ > You'll need to install dependencies first so that the workspace version of TypeScript is available.
220
+
221
+ 👉 **Select "Allow" when VSCode asks if you want to use the workspace version of TypeScript**
222
+
223
+ Otherwise, you can also manually opt-in to the workspace version:
224
+
225
+ 1. Open up any TypeScript file in your project
226
+ 2. Open up the VSCode Command Palette (<kbd>Cmd</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd>)
227
+ 3. Search for `Select TypeScript Version`
228
+ 4. Choose `Use Workspace Version`
229
+ 5. Quit and reopen VSCode
230
+
231
+ ##### Troubleshooting
232
+
233
+ In VSCode, open up any TypeScript file in your project and then use <kbd>CMD</kbd>+<kbd>SHIFT</kbd>+<kbd>P</kbd> to select `Open TS Server log`.
234
+ There should be a log for `[react-router] setup` that indicates that the plugin was resolved correctly.
235
+ Then look for any errors in the log.
236
+
237
+ ### Patch Changes
238
+
239
+ - include root "react-dom" module for optimization ([#12060](https://github.com/remix-run/react-router/pull/12060))
240
+ - Updated dependencies:
241
+ - `react-router@7.0.0-pre.0`
242
+ - `@react-router/serve@7.0.0-pre.0`
243
+ - `@react-router/node@7.0.0-pre.0`
244
+
3
245
  ## 2.9.0
4
246
 
5
247
  ### Minor Changes
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
package/dist/cli/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
package/dist/cli/run.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
package/dist/colors.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
package/dist/invariant.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
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-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
package/dist/vite/dev.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1202,8 +1202,8 @@ function determineStaticPrerenderRoutes(routes, viteConfig, isBooleanUsage = fal
1202
1202
  }
1203
1203
  }
1204
1204
  recurse(routes);
1205
- if (isBooleanUsage && paramRoutes) {
1206
- viteConfig.logger.warn("The following paths were not prerendered because Dynamic Param and Splat " + "routes cannot be prerendered when using `prerender:true`. You may want to " + "consider using the `prerender()` API if you wish to prerender slug and " + "splat routes.");
1205
+ if (isBooleanUsage && paramRoutes.length > 0) {
1206
+ viteConfig.logger.warn(["⚠️ Paths with dynamic/splat params cannot be prerendered when using `prerender: true`.", "You may want to use the `prerender()` API to prerender the following paths:", ...paramRoutes.map(p => " - " + p)].join("\n"));
1207
1207
  }
1208
1208
  // Clean double slashes and remove trailing slashes
1209
1209
  return paths.map(p => p.replace(/\/\/+/g, "/").replace(/(.+)\/$/, "$1"));
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
package/dist/vite/vmod.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v0.0.0-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
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 v0.0.0-nightly-a41323a0b-20241011
2
+ * @react-router/dev v7.0.0-pre.1
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-router/dev",
3
- "version": "0.0.0-nightly-a41323a0b-20241011",
3
+ "version": "7.0.0-pre.1",
4
4
  "description": "Dev tools and CLI for React Router",
5
5
  "homepage": "https://reactrouter.com",
6
6
  "bugs": {
@@ -61,7 +61,7 @@
61
61
  "set-cookie-parser": "^2.6.0",
62
62
  "valibot": "^0.41.0",
63
63
  "vite-node": "^1.6.0",
64
- "@react-router/node": "0.0.0-nightly-a41323a0b-20241011"
64
+ "@react-router/node": "7.0.0-pre.1"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@types/babel__core": "^7.20.5",
@@ -87,15 +87,15 @@
87
87
  "tiny-invariant": "^1.2.0",
88
88
  "vite": "^5.1.0",
89
89
  "wrangler": "^3.28.2",
90
- "react-router": "^0.0.0-nightly-a41323a0b-20241011",
91
- "@react-router/serve": "0.0.0-nightly-a41323a0b-20241011"
90
+ "@react-router/serve": "7.0.0-pre.1",
91
+ "react-router": "^7.0.0-pre.1"
92
92
  },
93
93
  "peerDependencies": {
94
94
  "typescript": "^5.1.0",
95
95
  "vite": "^5.1.0",
96
96
  "wrangler": "^3.28.2",
97
- "react-router": "^0.0.0-nightly-a41323a0b-20241011",
98
- "@react-router/serve": "^0.0.0-nightly-a41323a0b-20241011"
97
+ "@react-router/serve": "^7.0.0-pre.1",
98
+ "react-router": "^7.0.0-pre.1"
99
99
  },
100
100
  "peerDependenciesMeta": {
101
101
  "@react-router/serve": {