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 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d4b6a03
WIP adding the v3_routeConfig flag.
seanparsons Jan 20, 2025
d347234
WIP testing the example projects.
seanparsons Jan 22, 2025
e6ded23
WIP Trying to diagnose the skeleton project startup failure.
seanparsons Jan 22, 2025
e19ab47
Reimplemented virtual routes to build paths without node libraries.
seanparsons Jan 23, 2025
1acaac3
Removed change to multipass project.
seanparsons Jan 24, 2025
55a1450
Merge remote-tracking branch 'origin' into refactor/v3_routeconfig_flag
seanparsons Jan 24, 2025
010deb3
Multipass example now uses v3preset.
seanparsons Jan 24, 2025
c49e589
Fix virtual route layout
wizardlyhel Feb 4, 2025
3cb970e
fix the ordering of virtual routes
wizardlyhel Feb 4, 2025
205211f
Merge remote-tracking branch 'origin' into refactor/v3_routeconfig_flag
seanparsons Feb 6, 2025
49fd22e
CLI test fixes.
seanparsons Feb 7, 2025
d6d5c8a
Working unit tests.
seanparsons Feb 11, 2025
8b681b3
Additional patch to get the tests working correctly.
seanparsons Feb 11, 2025
a28175a
Merge remote-tracking branch 'origin' into refactor/v3_routeconfig_flag
seanparsons Feb 11, 2025
c5e540e
Fixing eslint errors that arose after the merge.
seanparsons Feb 11, 2025
f366301
Applied prettier fixes to virtual-root.tsx.
seanparsons Feb 11, 2025
ad96662
Added changeset for v3_routeConfig.
seanparsons Feb 11, 2025
043b1b3
Removed change to docs page because it's unnecessary.
seanparsons Feb 11, 2025
ec7de1b
Merge branch 'main' into refactor/v3_routeconfig_flag
wizardlyhel Feb 19, 2025
4bb88b7
Update so that there is only 1 patch on remix-run/dev
wizardlyhel Feb 26, 2025
66421e6
Merge branch 'main' into refactor/v3_routeconfig_flag
wizardlyhel Feb 26, 2025
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