Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorporate the v3_routeConfig future flag for Remix. #2722

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .changeset/spicy-drinks-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
'skeleton': patch
'@shopify/hydrogen': patch
'@shopify/cli-hydrogen': patch
---

Added support for the Remix future flag `v3_routeConfig`.

Remix documentation for the `v3_routeConfig`: [https://remix.run/docs/en/main/start/future-flags#v3_routeconfig](https://remix.run/docs/en/main/start/future-flags#v3_routeconfig)
Details the base changes that need to be made to enable the flag, including the up to 3 additional dependencies that need to be added.

Two files need to be changed once the above instructions have been applied.

1. In the `app/routes.ts` file, a support function needs to be included to get the additional routes that were originally added in the vite plugin. With a file like the following:

```typescript
import {flatRoutes} from '@remix-run/fs-routes';
import type {RouteConfig} from '@remix-run/route-config';
import {route} from '@remix-run/route-config';
import {remixRoutesOptionAdapter} from '@remix-run/routes-option-adapter';

export default [
...(await flatRoutes({rootDirectory: 'fs-routes'})),

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

route('/hello', 'routes/hello.tsx'),
] satisfies RouteConfig;
```

Include the `hydrogenRoutes` function like so:

```typescript
import {flatRoutes} from '@remix-run/fs-routes';
import type {RouteConfig} from '@remix-run/route-config';
import {route} from '@remix-run/route-config';
import {remixRoutesOptionAdapter} from '@remix-run/routes-option-adapter';
import {hydrogenRoutes} from '@shopify/hydrogen';

export default hydrogenRoutes([
...(await flatRoutes({rootDirectory: 'fs-routes'})),

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

route('/hello', 'routes/hello.tsx'),
]) satisfies RouteConfig;
```

The function should wrap around all of the routes so that the priority of the routes is applied correctly.

2. In the Vite config (`vite.config.ts` usually) the `remix` plugin needs to have it's configuration slightly altered.

From this:
Copy link
Contributor

@juanpprieto juanpprieto Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would wrap this instruction on a diff -/+ block instead


```typescript
...
remix({
presets: [hydrogen.preset()],
...
```
To this:
```typescript
...
remix({
presets: [hydrogen.v3preset()],
...
```
This is due to the `routes` configuration option not being allowed with the `v3_routeConfig` future flag enabled.
1 change: 1 addition & 0 deletions examples/classic-remix/remix.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ module.exports = {
v3_throwAbortReason: true,
v3_lazyRouteDiscovery: true,
v3_singleFetch: true,
v3_routeConfig: true,
},
};
5 changes: 5 additions & 0 deletions examples/express/app/routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {flatRoutes} from '@remix-run/fs-routes';
import type {RouteConfig} from '@remix-run/route-config';
import {hydrogenRoutes} from '@shopify/hydrogen';

export default hydrogenRoutes([...(await flatRoutes())]) satisfies RouteConfig;
3 changes: 3 additions & 0 deletions examples/express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"@remix-run/node": "^2.15.3",
"@remix-run/react": "^2.15.3",
"@remix-run/server-runtime": "^2.15.3",
"@remix-run/eslint-config": "^2.15.3",
"@remix-run/fs-routes": "^2.15.3",
"@remix-run/route-config": "^2.15.3",
"@shopify/hydrogen": "2025.1.2",
"compression": "^1.7.4",
"cross-env": "^7.0.3",
Expand Down
3 changes: 2 additions & 1 deletion examples/express/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ export default defineConfig({
plugins: [
hydrogen(),
remix({
presets: [hydrogen.preset()],
presets: [hydrogen.v3preset()],
future: {
v3_fetcherPersist: true,
v3_relativeSplatPath: true,
v3_throwAbortReason: true,
v3_lazyRouteDiscovery: true,
v3_routeConfig: true,
v3_singleFetch: true,
},
}),
Expand Down
3 changes: 3 additions & 0 deletions examples/multipass/app/routes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import {flatRoutes} from '@remix-run/fs-routes';

export default flatRoutes();
3 changes: 2 additions & 1 deletion examples/multipass/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ export default defineConfig({
hydrogen(),
oxygen(),
remix({
presets: [hydrogen.preset()],
presets: [hydrogen.v3preset()],
future: {
v3_fetcherPersist: true,
v3_relativeSplatPath: true,
v3_throwAbortReason: true,
v3_lazyRouteDiscovery: true,
v3_routeConfig: true,
v3_singleFetch: true,
},
}),
Expand Down
Loading
Loading