From 4abdec2ffd9d3a58c52471fcce4f941f57f37dd6 Mon Sep 17 00:00:00 2001 From: Masaki Date: Thu, 26 Feb 2026 20:43:42 +0900 Subject: [PATCH] fix: optional canvas-confetti via CDN with cached promise (Fix 2) - Load confetti from CDN at runtime when package not in node_modules - Module-scoped cached promise so only one script tag is appended (record type calls run() twice 300ms apart) - No optimizeDeps for canvas-confetti; package stays optional - PR rationale and description in docs/PR_FIX2_CANVAS_CONFETTI_BODY.md Made-with: Cursor --- docs/PR_FIX2_CANVAS_CONFETTI_BODY.md | 39 ++++++++++++++++ src/services/celebration.ts | 70 ++++++++++++++++++---------- 2 files changed, 85 insertions(+), 24 deletions(-) create mode 100644 docs/PR_FIX2_CANVAS_CONFETTI_BODY.md diff --git a/docs/PR_FIX2_CANVAS_CONFETTI_BODY.md b/docs/PR_FIX2_CANVAS_CONFETTI_BODY.md new file mode 100644 index 00000000..560eac2a --- /dev/null +++ b/docs/PR_FIX2_CANVAS_CONFETTI_BODY.md @@ -0,0 +1,39 @@ +# PR: Optional canvas-confetti via CDN (Fix 2) + +Copy from "Summary" below for the PR description. + +--- + +## Summary + +Makes the celebration service work when the `canvas-confetti` package is not installed in `node_modules`, so the app builds and runs without "Failed to resolve import 'canvas-confetti'" (e.g. after a fresh clone before `npm install`, or in environments where dependencies are not fully installed). + +**When the import fails:** The error occurs when Vite tries to resolve `canvas-confetti` at build or dev startup and the package is missing from `node_modules` — for example right after cloning the repo without running `npm install`, or in a workspace where dependencies have not been installed yet. We did not observe it in CI, Tauri build, or a specific Node version; it was the "package not installed" case. + +**Implementation:** +- Load confetti at runtime from a CDN script instead of bundling the npm package. No `import 'canvas-confetti'` in source, so Vite never tries to resolve it. +- Use a **module-scoped cached promise** for the load so that only one `