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

Conversation

seanparsons
Copy link

@seanparsons seanparsons commented Jan 23, 2025

WHY are these changes introduced?

These changes are to support an upgrade to the next version of Remix, by using the future flag and supporting libraries to get the code ready for that upgrade in place before the upgrade itself happens.

WHAT is this pull request doing?

  • Added the v3_routeConfig flag set to true.
  • Created a hydrogen.v3preset function which excludes the routes attribute that the hydrogen.preset function includes because that is incompatible with the flag being turned on.
  • Added a hydrogenRoutes function which transforms the route specified in routes.ts to include the virtual routes.
  • Rewrote getVirtualRoutes to work without using any node libraries so that it can run in MiniOxygen.
  • Updated the example projects to have them use the flag and the changes necessary to use the flag.
  • Set the LANG environment variable in the cli package so that the date formatting uses the US formatting.
  • build.test.ts now closes resources so that the test doesn't fail due to the hanging file watchers.
  • build.ts sets the server.watch configuration option as that may be necessary to disable the file watching.
  • hydrogen/dev.ts shuts down the watcher on the viteServer when finishing up.
  • setup.test.ts makes sure to include the routes.ts file.
  • classic-compiler/dev.ts makes sure to filter out the virtual routes when disableVirtualRoutes is true.
  • common.ts now makes sure to include routes.ts and layout.tsx.
  • local.test.ts slightly tweaked to make it easier to find out what files are missing and also now correctly takes account of the content that was shifted from root.tsx to layout.tsx.
  • remix-config.ts constructs a value routesViteNodeContext which is necessary when resolving the config if v3_routeConfig is enabled.
  • route-validator.ts is now null safe when assigning currentRoute.path.
  • replacers.ts looks for layout instead of root.
  • get-virtual-routes.test.ts now checks for the jsx files instead of the tsx files of the virtual routes.
  • Patched @remix-run/dev to not watch in remixVitePlugin when in a test because the file watchers cannot be reached to switch them off which causes tests relying on that to fail.
  • Patched vite to handle the watch properties of the config to set it if the value is null as that has meaning in that particular case.

HOW to test your changes?

  • Follow the steps as described in https://remix.run/docs/en/main/start/future-flags#v3_routeconfig to bring your project in line with the expectations therein.
  • Wrap the routes in routes.ts with the hydrogenRoutes function, to add the supporting routes.
  • Change the hydrogen preset from hydrogen.preset() to hydrogen.v3preset().

Post-merge steps

Checklist

  • I've read the Contributing Guidelines
  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've added a changeset if this PR contains user-facing or noteworthy changes
  • I've added tests to cover my changes
  • I've added or updated the documentation

Copy link
Contributor

shopify bot commented Jan 23, 2025

Oxygen deployed a preview of your refactor/v3_routeconfig_flag branch. Details:

Storefront Status Preview link Deployment details Last update (UTC)
third-party-queries-caching ✅ Successful (Logs) Preview deployment Inspect deployment February 19, 2025 9:37 PM
Skeleton (skeleton.hydrogen.shop) ✅ Successful (Logs) Preview deployment Inspect deployment February 19, 2025 9:37 PM
metaobjects ✅ Successful (Logs) Preview deployment Inspect deployment February 19, 2025 9:37 PM
classic-remix ✅ Successful (Logs) Preview deployment Inspect deployment February 19, 2025 9:37 PM
custom-cart-method ✅ Successful (Logs) Preview deployment Inspect deployment February 19, 2025 9:37 PM

Learn more about Hydrogen's GitHub integration.

@seanparsons seanparsons marked this pull request as ready for review February 11, 2025 17:58

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

Copy link
Contributor

@juanpprieto juanpprieto left a comment

Choose a reason for hiding this comment

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

Looking great Sean!

Tophat found no issues

import {PageLayout} from '~/components/PageLayout';
import { RootLoader } from './root';

export default function Layout() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think now that we have a separate file for this layout, I would prefer if we consolidated /components/PageLayout.tsx here to avoid an unnecessary level of abstraction

@@ -16,6 +16,9 @@
"dependencies": {
"@remix-run/react": "^2.15.3",
"@remix-run/server-runtime": "^2.15.3",
"@remix-run/fs-routes": "^2.15.3",
Copy link
Contributor

Choose a reason for hiding this comment

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

A reminder that we will need to add these new dependencies to our changelog.json entry when the time comes to release this

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

Successfully merging this pull request may close these issues.

3 participants