feat: replace direct sonner imports with lazy @/lib/toast wrapper (#949)#953
Conversation
Co-authored-by: Ona <no-reply@ona.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
✅ UI verification passed — no visual changes to verify. This PR only changes import paths ( |
|
✅ Post-merge verification passed. E2E suite (337 tests against
Ad-hoc smoke tests — all passed:
Interaction smoke test (feat PR safety net):
|
Closes #949
What
Replaces direct
import { toast } from "sonner"withimport { toast } from "@/lib/toast"in 5 database-domain files, and adds an ESLint rule to prevent future regressions.The lazy wrapper (
src/lib/toast.ts) dynamically imports sonner on first invocation, keeping ~15 kB gzipped out of the initial page JS. These 5 files were the only remaining production code bypassing the wrapper.Changes
sonner→@/lib/toast:use-database-filters.tsuse-database-views.tsuse-database-rows.tsuse-database-properties.tsviews/table-cell.tsxvi.mock("sonner", ...)→vi.mock("@/lib/toast", ...)to match new import pathssrc/lib/toast.ts— extendedToastDatatype withactionproperty ({ label, onClick }) used by database hooks for retry buttonseslint.config.mjs— addedsonnertono-restricted-importsrule, banningtoastimports fromsonnerwith a message directing to@/lib/toast. Exemptssrc/lib/toast.ts(the wrapper itself).Testing
pnpm lint— 0 errors (45 pre-existing warnings)pnpm typecheck— passespnpm test— 133 files, 1818 tests passed