qwikverse / qwik-lottie

MIT License
8 stars 3 forks source link

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

Open Daniel-SDSharp opened 1 year ago

Daniel-SDSharp commented 1 year ago

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 :)