Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloudflare deployment error on page deployment using qwik-lottie: "Uncaught ReferenceError: document is not defined" #1

Open
Daniel-SDSharp opened this issue Jan 13, 2023 · 0 comments

Comments

@Daniel-SDSharp
Copy link

I'm getting this error at the end of cloudflare pages's deploy on an app that usesqwik-lottie to render animations (build and deployment works fine if the use of qwik-lottie is removed):

15:53:23.426
15:53:23.429 ✨ Success! Uploaded 0 files (126 already uploaded) (0.54 sec)
15:53:23.430
15:53:23.735 ✨ Upload complete!
15:53:25.551 Success: Assets published!
15:53:26.510 Error: Failed to publish your Function. Got error: Uncaught ReferenceError: document is not defined
at worker.mjs:6315:11 in createTag
at worker.mjs:7376:26
at worker.mjs:7383:12
at worker.mjs:7562:10
at worker.mjs:6296:26 in lottie2
at worker.mjs:6297:8
at worker.mjs:21393:7 in ../node_modules/qwik-lottie/lib/index.qwik.mjs
at worker.mjs:16:59 in __init
at worker.mjs:112844:5 in ../server/entry.cloudflare-pages.js
at worker.mjs:16:59 in __init

I suspect this happens because qwik uses ssr and qwik-lottie tries to access the document and then obtains undefined... are there any workarounds?

Initially, I tried to use a fairly simple implementation, just declaring the state and then rendering the component:

image
image

This would render the component in development, build would succeed and then deployment would fail

Then, I tried dynamically importing the QwikLottie component from the library and conditionally rendering it, which worked again in development but failed in deployment:

image
image
image

Am I missing something? I would appreaciate any help :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant