fix: optional canvas-confetti via CDN with cached promise (Fix 2)#409
Open
Niboshi-Wasabi wants to merge 1 commit intokoala73:mainfrom
Open
fix: optional canvas-confetti via CDN with cached promise (Fix 2)#409Niboshi-Wasabi wants to merge 1 commit intokoala73:mainfrom
Niboshi-Wasabi wants to merge 1 commit intokoala73:mainfrom
Conversation
- 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
|
@Niboshi-Wasabi is attempting to deploy a commit to the Elie Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes the celebration service work when the
canvas-confettipackage is not installed innode_modules, so the app builds and runs without "Failed to resolve import 'canvas-confetti'" (e.g. after a fresh clone beforenpm install, or in environments where dependencies are not fully installed).When the import fails: The error occurs when Vite tries to resolve
canvas-confettiat build or dev startup and the package is missing fromnode_modules— for example right after cloning the repo without runningnpm 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:
import 'canvas-confetti'in source, so Vite never tries to resolve it.<script>tag is ever appended. The record celebration callsrun()twice (300ms apart); without the cache, a second script would be appended if the first load had not finished. All callers now share the same promise.optimizeDeps.include: ['canvas-confetti']in vite.config, so the package remains optional and Vite does not try to pre-bundle it at dev startup.Trade-off: If the CDN is unavailable or the user is offline, celebrations still run but no confetti is shown. When the package is installed (after
npm install), the CDN is used the same way so behavior is consistent.Type of change
Affected areas
/api/*)src/services/celebration.ts)Checklist
api/rss-proxy.jsallowlist (if adding feeds)npm run typecheck)Screenshots
None. Manual check: run the app without
canvas-confettiin node_modules (e.g. remove it from node_modules and runnpm run dev); app should start and celebrations should load confetti from CDN when triggered.