[BUG] Cache strategies not available to client components
Describe the bug
The fetchSync hook allows you to set a cache strategy and according to the docs this should be one of the defined cache strategies or a custom one. However, when you try to import the cache strategy in a client component, you get the following error: SyntaxError: The requested module '/node_modules/@shopify/hydrogen/dist/esnext/client.js?v=25d58708' does not provide an export named 'CacheNone'
To Reproduce
Example is in FetchExample.client.jsx.
Expected behaviour Since the docs link to the cache strategies you'd expect to be able to use those, both client and server-side.
Additional context
- Hydrogen version: Stackblitz: 1.1.0, Local: 1.0.2
- Node version: Stackblitz: v16.14.2, Local: v17.7.2
As this document(https://shopify.dev/api/hydrogen/hooks/global/fetchsync#fetchsync-in-client-components) says, to use fetchSync in client.jsx if you want to set no-store, i think you can just write it like this:
const data = fetchSync('/api/bestSellers', {
cache: 'no-store',
}).json();
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 npm run 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.
Oxygen deployed a preview of your hl-pass-language-to-caapi branch. Details:
| Storefront | Status | Preview link | Deployment details | Last update (UTC) |
|---|---|---|---|---|
| vite | ✅ Successful (Logs) | Preview deployment | Inspect deployment | March 13, 2024 6:34 PM |
| custom-cart-method | ✅ Successful (Logs) | Preview deployment | Inspect deployment | March 13, 2024 6:34 PM |
| third-party-queries-caching | ✅ Successful (Logs) | Preview deployment | Inspect deployment | March 13, 2024 6:34 PM |
| optimistic-cart-ui | ✅ Successful (Logs) | Preview deployment | Inspect deployment | March 13, 2024 6:34 PM |
| subscriptions | ✅ Successful (Logs) | Preview deployment | Inspect deployment | March 13, 2024 6:34 PM |
| skeleton | ✅ Successful (Logs) | Preview deployment | Inspect deployment | March 13, 2024 6:34 PM |
Learn more about Hydrogen's GitHub integration.