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

Add fs-routes and Remix adapter package #11971

Merged
merged 1 commit into from
Sep 11, 2024
Merged

Conversation

markdalgleish
Copy link
Member

@markdalgleish markdalgleish commented Sep 10, 2024

This PR makes FS routing a more first class part of React Router 7 and not just a Remix backwards compatibility layer. To achieve this, @react-router/remix-v2-routes has been split into two packages:

  • @react-router/fs-routes
  • @react-router/remix-config-routes-adapter

fs-routes

In this PR, this package exports a flatRoutes function — deliberately leaving room for a nestedRoutes function in the future.

For most consumers, whether coming from Remix or starting fresh with React Router, the setup will look like this:

import { type RouteConfig } from "@react-router/dev/routes";
import { flatRoutes } from "@react-router/fs-routes";

export const routes: RouteConfig = flatRoutes();

The rootDirectory and ignoredRouteFiles are also supported here, but notably the routes option from Remix has now been moved out.

remix-config-routes-adapter

This package only exists to provide a backwards compatibility layer for Remix's routes option, ensuring that anyone using this option has a much smoother migration process. This is particularly useful if they're using an alternative file system routing implementation that they don't control, like remix-flat-routes:

import { type RouteConfig } from "@react-router/dev/routes";
import { remixConfigRoutes } from "@react-router/remix-config-routes-adapter";
import { flatRoutes } from "remix-flat-routes";

export const routes: RouteConfig = remixConfigRoutes(async defineRoutes => {
  return flatRoutes('routes', defineRoutes);
});

Note that since this package has been split from fs-routes, you no longer need to set ignoredRouteFiles: ['**/*'] as seen in the remix-flat-routes readme 🥳

Copy link

changeset-bot bot commented Sep 10, 2024

⚠️ No Changeset found

Latest commit: 1969982

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@@ -727,22 +727,6 @@ describe("fileRoutes", () => {
);
});

test.skip("same path, different param name", () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

I opted to clean up this skipped test while I was here.

@markdalgleish markdalgleish merged commit 6ccf92a into dev Sep 11, 2024
8 checks passed
@markdalgleish markdalgleish deleted the markdalgleish/fs-routes branch September 11, 2024 01:14
Copy link
Contributor

🤖 Hello there,

We just published version 6.28.2-pre.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant