Shopify / hydrogen-demo-store

This template contains a full-featured setup of components, queries and tooling to get started with Hydrogen. It is deployed to https://hydrogen.shop
100 stars 34 forks source link

Avoid circular imports to improve HMR in Vite #27

Closed frandiox closed 4 months ago

frandiox commented 5 months ago

Similar to https://github.com/Shopify/hydrogen/pull/2014

We were getting an error like the following:

5:53:33 PM [vite] hmr update /app/root.tsx, /app/styles/app.css?direct, /app/root.tsx?client-route=1
5:53:34 PM [vite] hmr invalidate /app/root.tsx Could not Fast Refresh. Learn more at https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#consistent-components-exports
5:53:34 PM [vite] hmr update ./server.ts, /app/root.tsx, /app/styles/app.css?direct, /app/components/Text.tsx, /app/components/Button.tsx, /app/components/ProductCard.tsx, /app/components/Layout.tsx, /app/components/Cart.tsx, /app/components/FeaturedSection.tsx, /app/components/CountrySelector.tsx, /app/components/FeaturedProducts.tsx, /app/components/Link.tsx, /app/root.tsx?client-route=1

With these changes, there's no more error related to Fast Refresh.

Before After
image image