Skip to content

Commit 297fbd9

Browse files
committed
chore: merge dev
2 parents 02b5721 + bc4da87 commit 297fbd9

File tree

8 files changed

+98
-57
lines changed

8 files changed

+98
-57
lines changed

Diff for: .changeset/sour-years-cover.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
"@remix-run/dev": patch
3+
---
4+
5+
Stabilize the `future.v3_routeConfig` future flag, replacing `future.unstable_routeConfig`. This enables support for `routes.ts` to assist with the migration to React Router v7.
6+
7+
Note that if you had already enabled the `future.unstable_routeConfig` flag, your route config in `app/routes.ts` is no longer defined via the `routes` export and must now be defined via the default export.
8+
9+
```diff
10+
import { type RouteConfig } from "@remix-run/route-config";
11+
12+
-export const routes: RouteConfig = [];
13+
+export default [] satisfies RouteConfig;
14+
```

Diff for: docs/start/future-flags.md

+43-23
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,29 @@ function handleBrowserRequest(/* ... */) {
511511
}
512512
```
513513

514-
## unstable_routeConfig
514+
## v3_lazyRouteDiscovery
515+
516+
**Background**
517+
518+
With this flag, Remix no longer sends the full route manifest up to the client on initial load. Instead, Remix only sends the server-rendered routes up in the manifest and then fetches the remaining routes as the user navigated around the application. Additional details are available in the [docs][lazy-route-discovery] and the [blog post][lazy-route-discovery-blog-post]
519+
520+
👉 **Enable the Flag**
521+
522+
```ts filename=vite.config.ts
523+
remix({
524+
future: {
525+
v3_lazyRouteDiscovery: true,
526+
},
527+
});
528+
```
529+
530+
**Update your Code**
531+
532+
You shouldn't need to make any changes to your application code for this feature to work.
533+
534+
You may find some usage for the new [`<Link discover>`][discover-prop] API if you wish to disable eager route discovery on certain links.
535+
536+
## v3_routeConfig
515537

516538
<docs-warning>
517539

@@ -521,7 +543,7 @@ This flag requires the [Vite plugin][vite-plugin].
521543

522544
Config-based routing is the new default in React Router v7, configured via the `routes.ts` file in the app directory. Support for `routes.ts` and its related APIs in Remix are designed as a migration path to help minimize the number of changes required when moving your Remix project over to React Router v7. While some new packages have been introduced within the `@remix-run` scope, these new packages only exist to keep the code in `routes.ts` as similar as possible to the equivalent code for React Router v7.
523545

524-
When the `unstable_routeConfig` future flag is enabled, Remix's built-in file system routing will be disabled and your project will opted into React Router v7's config-based routing. If you prefer to keep using Remix's file-based routing we cover how to enable it in `routes.ts` below.
546+
When the `v3_routeConfig` future flag is enabled, Remix's built-in file system routing will be disabled and your project will opted into React Router v7's config-based routing. To opt back in to file system routing, this can be explicitly configured within `routes.ts` as we'll cover below.
525547

526548
**Update your code**
527549

@@ -532,7 +554,7 @@ To migrate Remix's file system routing and route config to the equivalent setup
532554
```ts filename=vite.config.ts
533555
remix({
534556
future: {
535-
unstable_routeConfig: true,
557+
v3_routeConfig: true,
536558
},
537559
});
538560
```
@@ -556,7 +578,7 @@ touch app/routes.ts
556578
```ts filename=app/routes.ts
557579
import type { RouteConfig } from "@remix-run/route-config";
558580

559-
export const routes: RouteConfig = [];
581+
export default [] satisfies RouteConfig;
560582
```
561583

562584
This is a good way to check that your new `routes.ts` file is being picked up successfully. Your app should now be rendering a blank page since there aren't any routes defined yet.
@@ -575,7 +597,7 @@ This package matches the API of React Router v7's `@react-router/fs-routes`, mak
575597
import { flatRoutes } from "@remix-run/fs-routes";
576598
import type { RouteConfig } from "@remix-run/route-config";
577599

578-
export const routes: RouteConfig = flatRoutes();
600+
export default flatRoutes() satisfies RouteConfig;
579601
```
580602

581603
👉 **If you used the `routes` config option, add `@remix-run/routes-option-adapter` and use it in `routes.ts`**
@@ -601,9 +623,9 @@ import { type RouteConfig } from "@remix-run/route-config";
601623
import { remixRoutesOptionAdapter } from "@remix-run/routes-option-adapter";
602624
import { flatRoutes } from "remix-flat-routes";
603625

604-
export const routes: RouteConfig = remixRoutesOptionAdapter(
605-
(defineRoutes) => flatRoutes("routes", defineRoutes)
606-
);
626+
export default remixRoutesOptionAdapter((defineRoutes) =>
627+
flatRoutes("routes", defineRoutes)
628+
) satisfies RouteConfig;
607629
```
608630

609631
Or, if you were using the `routes` option to define config-based routes:
@@ -613,18 +635,16 @@ import { flatRoutes } from "@remix-run/fs-routes";
613635
import { type RouteConfig } from "@remix-run/route-config";
614636
import { remixRoutesOptionAdapter } from "@remix-run/routes-option-adapter";
615637

616-
export const routes: RouteConfig = remixRoutesOptionAdapter(
617-
(defineRoutes) => {
618-
return defineRoutes((route) => {
619-
route("/", "home/route.tsx", { index: true });
620-
route("about", "about/route.tsx");
621-
route("", "concerts/layout.tsx", () => {
622-
route("trending", "concerts/trending.tsx");
623-
route(":city", "concerts/city.tsx");
624-
});
638+
export default remixRoutesOptionAdapter((defineRoutes) => {
639+
return defineRoutes((route) => {
640+
route("/", "home/route.tsx", { index: true });
641+
route("about", "about/route.tsx");
642+
route("", "concerts/layout.tsx", () => {
643+
route("trending", "concerts/trending.tsx");
644+
route(":city", "concerts/city.tsx");
625645
});
626-
}
627-
);
646+
});
647+
}) satisfies RouteConfig;
628648
```
629649

630650
If you're defining config-based routes in this way, you might want to consider migrating to the new route config API since it's more streamlined while still being very similar to the old API. For example, the routes above would look like this:
@@ -637,14 +657,14 @@ import {
637657
index,
638658
} from "@remix-run/route-config";
639659

640-
export const routes: RouteConfig = [
660+
export default [
641661
index("home/route.tsx"),
642662
route("about", "about/route.tsx"),
643663
layout("concerts/layout.tsx", [
644664
route("trending", "concerts/trending.tsx"),
645665
route(":city", "concerts/city.tsx"),
646666
]),
647-
];
667+
] satisfies RouteConfig;
648668
```
649669

650670
Note that if you need to mix and match different route config approaches, they can be merged together into a single array of routes. The `RouteConfig` type ensures that everything is still valid.
@@ -655,13 +675,13 @@ import type { RouteConfig } from "@remix-run/route-config";
655675
import { route } from "@remix-run/route-config";
656676
import { remixRoutesOptionAdapter } from "@remix-run/routes-option-adapter";
657677

658-
export const routes: RouteConfig = [
678+
export default [
659679
...(await flatRoutes({ rootDirectory: "fs-routes" })),
660680

661681
...(await remixRoutesOptionAdapter(/* ... */)),
662682

663683
route("/hello", "routes/hello.tsx"),
664-
];
684+
] satisfies RouteConfig;
665685
```
666686

667687
## Deprecations

Diff for: integration/helpers/vite.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const viteConfig = {
4343
export default {
4444
${await viteConfig.server(args)}
4545
plugins: [remix(${
46-
args.routeConfig ? "{ future: { unstable_routeConfig: true } }" : ""
46+
args.routeConfig ? "{ future: { v3_routeConfig: true } }" : ""
4747
})]
4848
}
4949
`;

Diff for: integration/vite-fs-routes-test.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ test.describe("fs-routes", () => {
2424
2525
export default defineConfig({
2626
plugins: [remix({
27-
future: { unstable_routeConfig: true },
27+
future: { v3_routeConfig: true },
2828
})],
2929
});
3030
`,
@@ -33,7 +33,7 @@ test.describe("fs-routes", () => {
3333
import { flatRoutes } from "@remix-run/fs-routes";
3434
import { remixRoutesOptionAdapter } from "@remix-run/routes-option-adapter";
3535
36-
export const routes: RouteConfig = [
36+
export default [
3737
...await flatRoutes({
3838
rootDirectory: "fs-routes",
3939
ignoredRouteFiles: ["**/ignored-route.*"],
@@ -46,7 +46,7 @@ test.describe("fs-routes", () => {
4646
route("/routes/option/adapter/route", "routes-option-adapter-route.tsx")
4747
});
4848
})
49-
];
49+
] satisfies RouteConfig;
5050
`,
5151
"app/root.tsx": js`
5252
import { Links, Meta, Outlet, Scripts } from "@remix-run/react";
@@ -257,17 +257,17 @@ test.describe("emits warnings for route conflicts", async () => {
257257
258258
export default defineConfig({
259259
plugins: [remix({
260-
future: { unstable_routeConfig: true },
260+
future: { v3_routeConfig: true },
261261
})],
262262
});
263263
`,
264264
"app/routes.ts": js`
265265
import { type RouteConfig } from "@remix-run/route-config";
266266
import { flatRoutes } from "@remix-run/fs-routes";
267267
268-
export const routes: RouteConfig = flatRoutes({
268+
export default flatRoutes({
269269
rootDirectory: "fs-routes",
270-
});
270+
}) satisfies RouteConfig;
271271
`,
272272
"fs-routes/_dashboard._index.tsx": js`
273273
export default function () {
@@ -331,17 +331,17 @@ test.describe("", () => {
331331
332332
export default defineConfig({
333333
plugins: [remix({
334-
future: { unstable_routeConfig: true },
334+
future: { v3_routeConfig: true },
335335
})],
336336
});
337337
`,
338338
"app/routes.ts": js`
339339
import { type RouteConfig } from "@remix-run/route-config";
340340
import { flatRoutes } from "@remix-run/fs-routes";
341341
342-
export const routes: RouteConfig = flatRoutes({
342+
export default flatRoutes({
343343
rootDirectory: "fs-routes",
344-
});
344+
}) satisfies RouteConfig;
345345
`,
346346
"app/fs-routes/_index/route.tsx": js``,
347347
"app/fs-routes/_index/utils.ts": js``,
@@ -380,17 +380,17 @@ test.describe("pathless routes and route collisions", () => {
380380
381381
export default defineConfig({
382382
plugins: [remix({
383-
future: { unstable_routeConfig: true },
383+
future: { v3_routeConfig: true },
384384
})],
385385
});
386386
`,
387387
"app/routes.ts": js`
388388
import { type RouteConfig } from "@remix-run/route-config";
389389
import { flatRoutes } from "@remix-run/fs-routes";
390390
391-
export const routes: RouteConfig = flatRoutes({
391+
export default flatRoutes({
392392
rootDirectory: "fs-routes",
393-
});
393+
}) satisfies RouteConfig;
394394
`,
395395
"app/root.tsx": js`
396396
import { Link, Outlet, Scripts, useMatches } from "@remix-run/react";

Diff for: integration/vite-route-config-test.ts

+15-15
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ test.describe("route config", () => {
4343
4444
export default {
4545
plugins: [remix({
46-
future: { unstable_routeConfig: true },
46+
future: { v3_routeConfig: true },
4747
})]
4848
}
4949
`,
@@ -64,12 +64,12 @@ test.describe("route config", () => {
6464
6565
export default {
6666
plugins: [remix({
67-
future: { unstable_routeConfig: true },
67+
future: { v3_routeConfig: true },
6868
routes: () => {},
6969
})]
7070
}
7171
`,
72-
"app/routes.ts": `export const routes = [];`,
72+
"app/routes.ts": `export default [];`,
7373
});
7474
let buildResult = viteBuild({ cwd });
7575
expect(buildResult.status).toBe(1);
@@ -88,12 +88,12 @@ test.describe("route config", () => {
8888
export default {
8989
${await viteConfig.server({ port })}
9090
plugins: [remix({
91-
future: { unstable_routeConfig: true },
91+
future: { v3_routeConfig: true },
9292
routes: () => {},
9393
})]
9494
}
9595
`,
96-
"app/routes.ts": `export const routes = [];`,
96+
"app/routes.ts": `export default [];`,
9797
});
9898
let devError: Error | undefined;
9999
try {
@@ -113,7 +113,7 @@ test.describe("route config", () => {
113113
114114
export default {
115115
plugins: [remix({
116-
future: { unstable_routeConfig: true },
116+
future: { v3_routeConfig: true },
117117
})]
118118
}
119119
`,
@@ -161,9 +161,9 @@ test.describe("route config", () => {
161161
"app/routes.ts": js`
162162
import { type RouteConfig, index } from "@remix-run/route-config";
163163
164-
export const routes: RouteConfig = [
164+
export default [
165165
index("test-route-1.tsx"),
166-
];
166+
] satisfies RouteConfig;
167167
`,
168168
"app/test-route-1.tsx": `
169169
export default function TestRoute1() {
@@ -220,14 +220,14 @@ test.describe("route config", () => {
220220
port,
221221
}),
222222
"app/routes.ts": js`
223-
export { routes } from "./actual-routes";
223+
export { default } from "./actual-routes";
224224
`,
225225
"app/actual-routes.ts": js`
226226
import { type RouteConfig, index } from "@remix-run/route-config";
227227
228-
export const routes: RouteConfig = [
228+
export default [
229229
index("test-route-1.tsx"),
230-
];
230+
] satisfies RouteConfig;
231231
`,
232232
"app/test-route-1.tsx": `
233233
export default function TestRoute1() {
@@ -286,9 +286,9 @@ test.describe("route config", () => {
286286
"app/routes.ts": js`
287287
import { type RouteConfig, index } from "@remix-run/route-config";
288288
289-
export const routes: RouteConfig = [
289+
export default [
290290
index("test-route-1.tsx"),
291-
];
291+
] satisfies RouteConfig;
292292
`,
293293
"app/test-route-1.tsx": `
294294
export default function TestRoute1() {
@@ -354,9 +354,9 @@ test.describe("route config", () => {
354354
import path from "node:path";
355355
import { type RouteConfig, index } from "@remix-run/route-config";
356356
357-
export const routes: RouteConfig = [
357+
export default [
358358
index(path.resolve(import.meta.dirname, "test-route.tsx")),
359-
];
359+
] satisfies RouteConfig;
360360
`,
361361
"app/test-route.tsx": `
362362
export default function TestRoute() {

Diff for: packages/remix-dev/__tests__/readConfig-test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ describe("readConfig", () => {
3737
"entryServerFilePath": Any<String>,
3838
"future": {
3939
"unstable_optimizeDeps": false,
40-
"unstable_routeConfig": false,
4140
"v3_fetcherPersist": false,
4241
"v3_lazyRouteDiscovery": false,
4342
"v3_relativeSplatPath": false,
43+
"v3_routeConfig": false,
4444
"v3_singleFetch": false,
4545
"v3_throwAbortReason": false,
4646
},

0 commit comments

Comments
 (0)