A full-featured CRM built with React, shadcn/ui, and Supabase.
fix lazyload with pwa
ThieryMichel47f114863982
diff --git a/src/components/atomic-crm/deals/index.ts b/src/components/atomic-crm/deals/index.tsindex 82086f28..251bc16d 100644--- a/src/components/atomic-crm/deals/index.ts+++ b/src/components/atomic-crm/deals/index.ts@@ -1,5 +1,32 @@import * as React from "react";-const DealList = React.lazy(() => import("./DealList"));++/**+ * Lazy-load with a full page reload on chunk load failure.+ * After a new deploy, the old service worker pre-cache may be replaced+ * while the page still holds old chunk references. A reload picks up+ * the new HTML + new SW cache, resolving the mismatch.+ * A sessionStorage guard prevents infinite reload loops.+ */+function lazyWithReload<T extends React.ComponentType<any>>(+ importFn: () => Promise<{ default: T }>,+ chunkName: string,+) {+ return React.lazy(() =>+ importFn().catch(() => {+ const key = `chunk-reload:${chunkName}`;+ if (!sessionStorage.getItem(key)) {+ sessionStorage.setItem(key, "1");+ window.location.reload();+ }+ // If we already reloaded once this session, surface the error+ return Promise.reject(+ new Error(`Failed to load chunk "${chunkName}" after reload`),+ );+ }),+ );+}++const DealList = lazyWithReload(() => import("./DealList"), "DealList");export default {list: DealList,