-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Firebase function V1 failed to deploy #158
Comments
Does anyone have deploy V1 firebase function with this new version of plugin ? |
Hi @chrisDupuis - I still use v1 firebase projects in one of my other projects, and last time I deployed a few months ago it was ok. |
We have create a test project ( before doing the migration).
|
@chrisDupuis What's the actual error message when you run something like this instead: In my case, the underlying issue was an import statement: I suspect the issue are your logger & functions imports. Try rewriting those and see if that helps. If that was indeed the issue though, I feel like this is something that should be solved by the build pipeline instead. Rewriting many imports isn't really feasable and it's only a matter of time before some dev accidentally accepts the wrong import and breaks deployment with very hard to find error logs. logs to compare against
|
I did some more digging: Switching the format in import * as admin from "firebase-admin";
...
// here we check if Firebase is already initialized to avoid calling initializeApp() twice
const isInitialized = admin.apps.some((app) => app?.name === "[DEFAULT]"); What this code does isn't important, the important part is that the imported I've tried to make esbuild work like this so far, but nothing seems to work:
|
So I've managed to finally deploy a sample cloud function, here's what lead to that:
Not sure if cjs improves any of this. I think there's one "path" I could test there which might work, since the error message that I gave up on was the same error that was fixed by updating the |
Interesting findings, thanks. Yes firebase exports in the later SDKs are now modular - see here I did add some notes on use of es6 modules to the docs, but this topic makes me think there are corner cases - especially if using package dependencies that do not have an esm export, only cjs. Note also that the I found that migrating to esm was a bit of 'a process' in my own projects, but I believe it is inevitable that cjs modules are on track to become legacy now, so I felt it was worth putting in the grind. |
@chrisDupuis - did you make any progress with this on your side? |
I believe I am having the same (or a very similar issue). I can spin it into its own issue if needed. Here is a minimal reproduction of the issue: With the following
I receive the following error when running
Note that if I switch the import from Relevant versions: My build config in my
|
Thanks @brendanowens this is helpful. Could you try |
I believe that firebase team are generally recommending against using the old style imports like:
..etc. to the new modular approach where you'd import specifically the dependencies you need:
This is the recommended import recipe regardless of whether output will be built as esm or cjs. |
Thanks @simondotm for the suggestion, but the issue still persists with the following imports:
|
Adding the following
|
@brendanowens esbuild uses esm by default and esm doesnt support node's global To debug, remove imports until compilation works and see if you can change the broken imports to something else, import them in a different way or avoid them entirely. |
When I use a V1 mode function I have an error
The function
If I only use V2 function the déploiement is OK
with version
"@simondotm/nx-firebase": "^2.1.2",
The text was updated successfully, but these errors were encountered: