@shopify/create-hydrogen 5.0.23 → 5.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/hydrogen/starter/.cursor/rules/hydrogen-react-router.mdc +5 -3
- package/dist/assets/hydrogen/starter/CHANGELOG.md +46 -40
- package/dist/assets/hydrogen/starter/package.json +2 -2
- package/dist/{chunk-NIHY2BIB.js → chunk-QUKX7CP5.js} +19 -19
- package/dist/create-app.js +2 -2
- package/dist/{error-handler-O653XSNU.js → error-handler-YXM2BB34.js} +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
description:
|
|
3
|
-
globs:
|
|
4
|
-
alwaysApply:
|
|
2
|
+
description:
|
|
3
|
+
globs:
|
|
4
|
+
alwaysApply: true
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
# React Router Import Rule for Hydrogen
|
|
@@ -29,6 +29,8 @@ When you see imports from Remix packages, replace them with their equivalent Rea
|
|
|
29
29
|
| `@remix-run/server-runtime` | `react-router` |
|
|
30
30
|
| `@remix-run/testing` | `react-router` |
|
|
31
31
|
|
|
32
|
+
NEVER USE 'react-router-dom' imports!
|
|
33
|
+
|
|
32
34
|
## Common Import Examples
|
|
33
35
|
|
|
34
36
|
```js
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# skeleton
|
|
2
2
|
|
|
3
|
+
## 2025.5.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Bumping the cli to 3.80.4 ([#2956](https://github.com/Shopify/hydrogen/pull/2956)) by [@balazsbajorics](https://github.com/balazsbajorics)
|
|
8
|
+
|
|
3
9
|
## 2025.5.0
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -160,13 +166,13 @@
|
|
|
160
166
|
1. Add a routes.ts file. This is your new Remix route configuration file.
|
|
161
167
|
|
|
162
168
|
```ts
|
|
163
|
-
import {flatRoutes} from
|
|
164
|
-
import {layout, type RouteConfig} from
|
|
165
|
-
import {hydrogenRoutes} from
|
|
169
|
+
import { flatRoutes } from "@remix-run/fs-routes";
|
|
170
|
+
import { layout, type RouteConfig } from "@remix-run/route-config";
|
|
171
|
+
import { hydrogenRoutes } from "@shopify/hydrogen";
|
|
166
172
|
|
|
167
173
|
export default hydrogenRoutes([
|
|
168
174
|
// Your entire app reading from routes folder using Layout from layout.tsx
|
|
169
|
-
layout(
|
|
175
|
+
layout("./layout.tsx", await flatRoutes()),
|
|
170
176
|
]) satisfies RouteConfig;
|
|
171
177
|
```
|
|
172
178
|
|
|
@@ -757,25 +763,25 @@
|
|
|
757
763
|
8. Update the `ProductForm` component.
|
|
758
764
|
|
|
759
765
|
```tsx
|
|
760
|
-
import {Link, useNavigate} from
|
|
761
|
-
import {type MappedProductOptions} from
|
|
766
|
+
import { Link, useNavigate } from "@remix-run/react";
|
|
767
|
+
import { type MappedProductOptions } from "@shopify/hydrogen";
|
|
762
768
|
import type {
|
|
763
769
|
Maybe,
|
|
764
770
|
ProductOptionValueSwatch,
|
|
765
|
-
} from
|
|
766
|
-
import {AddToCartButton} from
|
|
767
|
-
import {useAside} from
|
|
768
|
-
import type {ProductFragment} from
|
|
771
|
+
} from "@shopify/hydrogen/storefront-api-types";
|
|
772
|
+
import { AddToCartButton } from "./AddToCartButton";
|
|
773
|
+
import { useAside } from "./Aside";
|
|
774
|
+
import type { ProductFragment } from "storefrontapi.generated";
|
|
769
775
|
|
|
770
776
|
export function ProductForm({
|
|
771
777
|
productOptions,
|
|
772
778
|
selectedVariant,
|
|
773
779
|
}: {
|
|
774
780
|
productOptions: MappedProductOptions[];
|
|
775
|
-
selectedVariant: ProductFragment[
|
|
781
|
+
selectedVariant: ProductFragment["selectedOrFirstAvailableVariant"];
|
|
776
782
|
}) {
|
|
777
783
|
const navigate = useNavigate();
|
|
778
|
-
const {open} = useAside();
|
|
784
|
+
const { open } = useAside();
|
|
779
785
|
return (
|
|
780
786
|
<div className="product-form">
|
|
781
787
|
{productOptions.map((option) => (
|
|
@@ -809,8 +815,8 @@
|
|
|
809
815
|
to={`/products/${handle}?${variantUriQuery}`}
|
|
810
816
|
style={{
|
|
811
817
|
border: selected
|
|
812
|
-
?
|
|
813
|
-
:
|
|
818
|
+
? "1px solid black"
|
|
819
|
+
: "1px solid transparent",
|
|
814
820
|
opacity: available ? 1 : 0.3,
|
|
815
821
|
}}
|
|
816
822
|
>
|
|
@@ -827,13 +833,13 @@
|
|
|
827
833
|
<button
|
|
828
834
|
type="button"
|
|
829
835
|
className={`product-options-item${
|
|
830
|
-
exists && !selected ?
|
|
836
|
+
exists && !selected ? " link" : ""
|
|
831
837
|
}`}
|
|
832
838
|
key={option.name + name}
|
|
833
839
|
style={{
|
|
834
840
|
border: selected
|
|
835
|
-
?
|
|
836
|
-
:
|
|
841
|
+
? "1px solid black"
|
|
842
|
+
: "1px solid transparent",
|
|
837
843
|
opacity: available ? 1 : 0.3,
|
|
838
844
|
}}
|
|
839
845
|
disabled={!exists}
|
|
@@ -857,7 +863,7 @@
|
|
|
857
863
|
<AddToCartButton
|
|
858
864
|
disabled={!selectedVariant || !selectedVariant.availableForSale}
|
|
859
865
|
onClick={() => {
|
|
860
|
-
open(
|
|
866
|
+
open("cart");
|
|
861
867
|
}}
|
|
862
868
|
lines={
|
|
863
869
|
selectedVariant
|
|
@@ -871,7 +877,7 @@
|
|
|
871
877
|
: []
|
|
872
878
|
}
|
|
873
879
|
>
|
|
874
|
-
{selectedVariant?.availableForSale ?
|
|
880
|
+
{selectedVariant?.availableForSale ? "Add to cart" : "Sold out"}
|
|
875
881
|
</AddToCartButton>
|
|
876
882
|
</div>
|
|
877
883
|
);
|
|
@@ -894,7 +900,7 @@
|
|
|
894
900
|
aria-label={name}
|
|
895
901
|
className="product-option-label-swatch"
|
|
896
902
|
style={{
|
|
897
|
-
backgroundColor: color ||
|
|
903
|
+
backgroundColor: color || "transparent",
|
|
898
904
|
}}
|
|
899
905
|
>
|
|
900
906
|
{!!image && <img src={image} alt={name} />}
|
|
@@ -1395,21 +1401,21 @@
|
|
|
1395
1401
|
New `withCache.fetch` is for caching simple fetch requests. This method caches the responses if they are OK responses, and you can pass `shouldCacheResponse`, `cacheKey`, etc. to modify behavior. `data` is the consumed body of the response (we need to consume to cache it).
|
|
1396
1402
|
|
|
1397
1403
|
```ts
|
|
1398
|
-
const withCache = createWithCache({cache, waitUntil, request});
|
|
1404
|
+
const withCache = createWithCache({ cache, waitUntil, request });
|
|
1399
1405
|
|
|
1400
|
-
const {data, response} = await withCache.fetch<{data: T; error: string}>(
|
|
1401
|
-
|
|
1406
|
+
const { data, response } = await withCache.fetch<{ data: T; error: string }>(
|
|
1407
|
+
"my-cms.com/api",
|
|
1402
1408
|
{
|
|
1403
|
-
method:
|
|
1404
|
-
headers: {
|
|
1409
|
+
method: "POST",
|
|
1410
|
+
headers: { "Content-type": "application/json" },
|
|
1405
1411
|
body,
|
|
1406
1412
|
},
|
|
1407
1413
|
{
|
|
1408
1414
|
cacheStrategy: CacheLong(),
|
|
1409
1415
|
// Cache if there are no data errors or a specific data that make this result not suited for caching
|
|
1410
1416
|
shouldCacheResponse: (result) => !result?.error,
|
|
1411
|
-
cacheKey: [
|
|
1412
|
-
displayName:
|
|
1417
|
+
cacheKey: ["my-cms", body],
|
|
1418
|
+
displayName: "My CMS query",
|
|
1413
1419
|
},
|
|
1414
1420
|
);
|
|
1415
1421
|
```
|
|
@@ -1985,9 +1991,9 @@
|
|
|
1985
1991
|
|
|
1986
1992
|
```tsx
|
|
1987
1993
|
// app/lib/root-data.ts
|
|
1988
|
-
import {useMatches} from
|
|
1989
|
-
import type {SerializeFrom} from
|
|
1990
|
-
import type {loader} from
|
|
1994
|
+
import { useMatches } from "@remix-run/react";
|
|
1995
|
+
import type { SerializeFrom } from "@shopify/remix-oxygen";
|
|
1996
|
+
import type { loader } from "~/root";
|
|
1991
1997
|
|
|
1992
1998
|
/**
|
|
1993
1999
|
* Access the result of the root loader from a React component.
|
|
@@ -2149,10 +2155,10 @@
|
|
|
2149
2155
|
- This is an important fix to a bug with 404 routes and path-based i18n projects where some unknown routes would not properly render a 404. This fixes all new projects, but to fix existing projects, add a `($locale).tsx` route with the following contents: ([#1732](https://github.com/Shopify/hydrogen/pull/1732)) by [@blittle](https://github.com/blittle)
|
|
2150
2156
|
|
|
2151
2157
|
```ts
|
|
2152
|
-
import {type LoaderFunctionArgs} from
|
|
2158
|
+
import { type LoaderFunctionArgs } from "@remix-run/server-runtime";
|
|
2153
2159
|
|
|
2154
|
-
export async function loader({params, context}: LoaderFunctionArgs) {
|
|
2155
|
-
const {language, country} = context.storefront.i18n;
|
|
2160
|
+
export async function loader({ params, context }: LoaderFunctionArgs) {
|
|
2161
|
+
const { language, country } = context.storefront.i18n;
|
|
2156
2162
|
|
|
2157
2163
|
if (
|
|
2158
2164
|
params.locale &&
|
|
@@ -2160,7 +2166,7 @@
|
|
|
2160
2166
|
) {
|
|
2161
2167
|
// If the locale URL param is defined, yet we still are still at the default locale
|
|
2162
2168
|
// then the the locale param must be invalid, send to the 404 page
|
|
2163
|
-
throw new Response(null, {status: 404});
|
|
2169
|
+
throw new Response(null, { status: 404 });
|
|
2164
2170
|
}
|
|
2165
2171
|
|
|
2166
2172
|
return null;
|
|
@@ -2216,11 +2222,11 @@
|
|
|
2216
2222
|
```yaml
|
|
2217
2223
|
projects:
|
|
2218
2224
|
default:
|
|
2219
|
-
schema:
|
|
2225
|
+
schema: "node_modules/@shopify/hydrogen/storefront.schema.json"
|
|
2220
2226
|
documents:
|
|
2221
|
-
-
|
|
2222
|
-
-
|
|
2223
|
-
-
|
|
2227
|
+
- "!*.d.ts"
|
|
2228
|
+
- "*.{ts,tsx,js,jsx}"
|
|
2229
|
+
- "app/**/*.{ts,tsx,js,jsx}"
|
|
2224
2230
|
```
|
|
2225
2231
|
|
|
2226
2232
|
- Improve resiliency of `HydrogenSession` ([#1583](https://github.com/Shopify/hydrogen/pull/1583)) by [@blittle](https://github.com/blittle)
|
|
@@ -2435,8 +2441,8 @@
|
|
|
2435
2441
|
```ts
|
|
2436
2442
|
// root.tsx
|
|
2437
2443
|
|
|
2438
|
-
import {useMatches} from
|
|
2439
|
-
import {type SerializeFrom} from
|
|
2444
|
+
import { useMatches } from "@remix-run/react";
|
|
2445
|
+
import { type SerializeFrom } from "@shopify/remix-oxygen";
|
|
2440
2446
|
|
|
2441
2447
|
export const useRootLoaderData = () => {
|
|
2442
2448
|
const [root] = useMatches();
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "skeleton",
|
|
3
3
|
"private": true,
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "2025.5.
|
|
5
|
+
"version": "2025.5.1",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "shopify hydrogen build --codegen",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@graphql-codegen/cli": "5.0.2",
|
|
32
32
|
"@react-router/dev": "7.6.0",
|
|
33
33
|
"@react-router/fs-routes": "7.6.0",
|
|
34
|
-
"@shopify/cli": "~3.
|
|
34
|
+
"@shopify/cli": "~3.80.4",
|
|
35
35
|
"@shopify/hydrogen-codegen": "^0.3.3",
|
|
36
36
|
"@shopify/mini-oxygen": "^3.2.1",
|
|
37
37
|
"@shopify/oxygen-workers-types": "^4.1.6",
|