-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[🐞] Qwik - Build is Aggressively Treeshaking with Firebase #7052
Comments
So qwik has to assume that every import does not have side effects on the client. The reason is that no code runs on the client except in response to events. All qrl segments are only importing code they are actually using. Can it be that firebase relies on side effects on the client? Do you know which code for missing? |
I don't know what this means.
Can you be more specific about what you mean with side effects. I can relay this to the Firebase issue. Thanks, J |
I can confirm that the Firebase SDK does indeed use side effects on import. |
@jdgamble555 As @DellaBitta confirms, importing the firebase SDK makes changes to the global object (side effects). To solve the problem, the firebase import needs to happen in a different file. This file should export helpers that expose the desired firebase functionality. Then when you use these helpers in your Qwik code, they won't be tree shaken and the firebase side effects can run on first import. |
Hi @wmertens, Could you clarify? The app should have a single point where it imports the Firebase SDK and then export helpers that should be imported throughout the rest of the application? That is, this is an App level change and not something in the SDK source base? Or am I misreading your post. Thanks! |
@wmertens - Do you mean you can only import in one file here? Please clarify. Also, is there any reason this would work in dev mode but not in production? It works on my local machine, but fails when deployed to both Netlify Edge and Vercel Edge. Thanks, J |
@jdgamble555 that is odd. The Qwik transform is the same in dev and prod but Vite does tree shaking in prod. It would be best to edit your firebase in node_modules to console.log() when it loads and see if that log is still present in the prod bundle. |
So this is a Vite problem with Qwik? Why would this not effect other frameworks that use Vite? If I edit something in (I'm using dynamic imports on everything Firebase btw) J |
@wmertens - Clarity for the Firebase Team would definitely help if you could. Thank you! |
@jdgamble555 the node modules edit is just to figure out which code runs when. And yes I think importing firebase in one file that exports helpers would help. |
@wmertens - I'm using dynamic imports on everything Firebase, and it does work in
J |
@wmertens - We have the Firebase team trying to help with this, but everyone seems to think this is a Qwik issue.
This could be a simple fix if we can at least figure out the problem. Thanks, J |
The best way to debug this is to work backwards. In the browser, find out
what isn't working, and then determine what code should have run to make it
work, and find where it should have been loaded, until you find a
difference.
The optimizer doesn't handle prod and dev differently tree-shaking wise,
but vite bundles things together in prod that might have side effects that
make it work.
Wout.
…On Sat, 21 Dec 2024, 23:26 Jonathan Gamble, ***@***.***> wrote:
@wmertens <https://github.com/wmertens> - We have the Firebase team
trying to help with this, but everyone seems to think this is a Qwik issue.
3. Is there anything that production does to the treeshaking
differently than dev or prod?
This could be a simple fix if we can at least figure out the problem.
Thanks,
J
—
Reply to this email directly, view it on GitHub
<#7052 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAANNFXJUJT4MQPMQPRLJKL2GXFI3AVCNFSM6AAAAABRNZXC4WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNJYGIZTCMZXGA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
This is a server problem, not browser problem, so harder to debug. What would vite do differently with Qwik that it wouldn't do in other frameworks? This is only problematic with Qwik and on the server in production. J |
Which component is affected?
Qwik Rollup / Vite plugin
Describe the bug
I've been working with the Firebase team to get Firebase working on Edge functions.
firebase/firebase-js-sdk#8355
Firebase now works on ever single Framework, even in Edge Environments (Bun, Deno, Cloudflare)... except on Qwik.
Reproduction
https://qwik-firebase-test.vercel.app/
Steps to reproduce
Here is issue on Firebase with deployment instructions:
firebase/firebase-js-sdk#8506
Repo: GitHub
Demo with error: Vercel Edge
System Info
Vercel Edge (no way to currently test this on Vercel Functions as there is not a Plugin)
Additional Information
Here is what the Firebase team said after agressive testing:
Here is the link to the GitHub Issue:
firebase/firebase-js-sdk#8506
Thanks,
J
Small Chance could be related to: #6322
Note: This could also be a Vercel Edge Plugin problem, but I'm not sure how the build process works.
The text was updated successfully, but these errors were encountered: