hydrogen icon indicating copy to clipboard operation
hydrogen copied to clipboard

Centralize route matching in one place

Open frandiox opened this issue 3 years ago • 1 comments

Description

This PR extracts some refactoring I did in #1933 .

So far, we were matching routes for API and, if no matched API route was found, we ran again similar logic to match Server Components. The matching process is basically iterating over every route, converting string keys to regular expressions and testing them until we find a route match.

With the changes proposed here, we only run the matching logic once at the beginning and store the result for later. It should reduce code size and CPU a little but, more importantly, it centralizes the route matching in one place so that we can implement plugins later.


Before submitting the PR, please make sure you do the following:

  • [x] Read the Contributing Guidelines
  • [x] Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123)
  • [ ] Update docs in this repository according to your change
  • [ ] Run yarn changeset add if this PR cause a version bump based on Keep a Changelog and adheres to Semantic Versioning

frandiox avatar Aug 22 '22 13:08 frandiox

We detected some changes in packages/*/package.json or packages/*/src, and there are no updates in the .changeset. If the changes are user-facing and should cause a version bump, run "yarn changeset add" to track your changes and include them in the next release CHANGELOG. If you are making simple updates to examples or documentation, you do not need to add a changeset.

github-actions[bot] avatar Aug 22 '22 13:08 github-actions[bot]

Oxygen deployed a preview of your fd-fix-debug-info branch. Details:

Storefront Status Preview link Deployment details Last update (UTC)
custom-cart-method ✅ Successful (Logs) Preview deployment Inspect deployment April 19, 2024 2:50 PM
third-party-queries-caching ✅ Successful (Logs) Preview deployment Inspect deployment April 19, 2024 2:50 PM
vite ✅ Successful (Logs) Preview deployment Inspect deployment April 19, 2024 2:50 PM
subscriptions ✅ Successful (Logs) Preview deployment Inspect deployment April 19, 2024 2:50 PM
optimistic-cart-ui ✅ Successful (Logs) Preview deployment Inspect deployment April 19, 2024 2:50 PM
skeleton ✅ Successful (Logs) Preview deployment Inspect deployment April 19, 2024 2:50 PM

Learn more about Hydrogen's GitHub integration.

shopify[bot] avatar Apr 19 '24 14:04 shopify[bot]