-
-
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
Can't deploy with 2.0.0-beta.1 #128
Comments
Hi @pikilon , Thankyou for reporting this, and for the detail - this is super useful. I agree that the problem will be the empty dependencies in your dist Would you mind trying something for me?
I've seen a wierd Nx issue from time to time, where you have to modify a source file after project generation before Nx will correctly output deps in the package.json. If that works, then deploy should work also. Please also let me know what version of Nx you are using, thanks. |
|
Hi @simondotm, I found the problem, it is not the package.json dependency. // The Cloud Functions for Firebase SDK to create Cloud Functions and triggers.
import { logger } from 'firebase-functions'
import { onDocumentCreated } from 'firebase-functions/v2/firestore'
import { onRequest } from 'firebase-functions/v2/https'
// The Firebase Admin SDK to access Firestore.
import { initializeApp } from 'firebase-admin/app'
import { getFirestore } from 'firebase-admin/firestore'
initializeApp()
// Take the text parameter passed to this HTTP endpoint and insert it into
// Firestore under the path /messages/:documentId/original
export const addmessage = onRequest(async (req, res) => {
// Grab the text parameter.
const original = req.query.text
// Push the new message into Firestore using the Firebase Admin SDK.
const writeResult = await getFirestore()
.collection('messages')
.add({ original: original })
// Send back a message that we've successfully written the message
res.json({ result: `Message with ID: ${writeResult.id} added.` })
})
// Listens for new messages added to /messages/:documentId/original
// and saves an uppercased version of the message
// to /messages/:documentId/uppercase
export const makeuppercase = onDocumentCreated('/messages/{documentId}', (event) => {
// Grab the current value of what was written to Firestore.
const original = event.data?.data().original
// Access the parameter `{documentId}` with `event.params`
logger.log('Uppercasing', event.params.documentId, original)
const uppercase = original.toUpperCase()
// You must return a Promise when performing
// asynchronous tasks inside a function
// such as writing to Firestore.
// Setting an 'uppercase' field in Firestore document returns a Promise.
return event.data?.ref.set({ uppercase }, { merge: true })
}) I think the default |
Ah ok very interesting. Yes, so the boiler plate functions code needs updating in the plugin. Good stuff. Looks like what is needed is to do a You are very welcome to submit a PR for this if you like. |
This is the output of /**
* Import function triggers from their respective submodules:
*
* import {onCall} from "firebase-functions/v2/https";
* import {onDocumentWritten} from "firebase-functions/v2/firestore";
*
* See a full list of supported triggers at https://firebase.google.com/docs/functions
*/
import {onRequest} from "firebase-functions/v2/https";
import * as logger from "firebase-functions/logger";
// Start writing functions
// https://firebase.google.com/docs/functions/typescript
export const helloWorld = onRequest((request, response) => {
logger.info("Hello logs!", {structuredData: true});
response.send("Hello from Firebase!");
}); I am trying to find the place to make the PR but I can't find it. |
Interesting that the latest CLI function boilerplate doesn't emit any call to The template |
I have the same issue and I can confirm that this works. Is it possible that it might have something to do with the build? I really have little experience in that 😅 |
I was thinking the same, but reading through the docs, maybe v2 is the way to go now as it feels like v1 support will be withdrawn soon. https://firebase.google.com/docs/functions/2nd-gen-upgrade
Yes v2 of the plugin builds the function code in a completely different but much better way, using I will look into fixing this template shortly. |
Got this error today took quite a while to figure out the root cause is this, almost decided to not use this library (probably would be a mistake). Worth doing a new release with the new PR merged? |
@elvisun thanks - and yes I am hoping to find time to do this over next couple of weeks. |
@elvisun - v2.0.0 now released with default firebase function template |
Hi, I am in the process to update from 1.1.0-beta.0 to 2.0.0-beta.1 and I followed the documentation (good documentation, thanks) by creating 2 projects, one for firebase and one for the cloud-functions (new from scratch with the default src files).
the folder structure:
I can build firebase and I checked it creates a
package.json
(but without thenode_modules
with the dependencies) and amain.js
with the default file:when I run the deploy it exits with
And in the
firebase-debug-log
:I think the problem is something related to the dependencies on the dist folder and this is why it can't find the
admin
from the library:Some information that could be important to solve the issue:
root
firebase.json
(the only one I have, not an empty one. I don't fully get where to put it)package.json
dependencies:I updated to the latest before the installation of nx-firebase
Thank you for your great work and in advance for your help
The text was updated successfully, but these errors were encountered: