-
Notifications
You must be signed in to change notification settings - Fork 899
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
Requesting Cloud Functions for Firebase to support pnpm workspaces #5911
Comments
Hmmm, removing |
Firebase does not officially support pnpm. In order to deploy your functions, we need to load your code using a script we install with the firebase-functions SDK. Pnpm workspaces make it hard to do this sort of bootstrapping of your code. |
I have been using pnpm with firebase functions since a couple of years without any problem (I am not using workspace - just pnpm as the dependency manager). The fact that functions deploy properly when I remove |
@taeold - can this be retriaged to |
So for sure, this information should be, at least, in the documentation. It is a huge limitation. This one, and also the one related to workspaces. |
https://firebase.google.com/docs/functions/handle-dependencies Doesn't this document mean that Firebase supports pnpm? I've encountered the exact same problem and removing |
@christophe-g I deployed 1st gen functions using pnpm workspace |
@colerogers - any chance to have this reviewed and fixed ? Please note that this is not a feature request - but a bug as it was previously working as expected (possible to deploy with pnpm as stated in the documentation). Thanks. |
Hi @christophe-g apologies for the delayed response. So I did a little digging on this issue and the error is not actually coming from the Firebase CLI, but instead the Cloud Build job. Since a Firebase function is actually a Google Cloud Function under the hood, we send your source code over to Cloud Build and that job uses Buildpacks to build source to a container image. I dug a little bit deeper and found that around the time that you started seeing this behavior (end of may), the buildpacks team published support for pnpm. They state that you would need to have the Since it sounds like you still have this issue with the dependency installed, I think opening a bug on their repo would be a good next step. I'm sorry that this has taken so long and that you have to jump through more hoops just to get this resolved. Thanks |
Thanks a lot @colerogers - appreciated. I will try to install @google-cloud/functions-framework again and update all related dep. Will post the results here. |
In case you'd like to deploy only an isolated part of your pnpm monorepo to firebase, have a look at this solution It also lets you deploy to firebase from multiple packages. |
@0x80 Great work on |
In case you like to avoid adding the |
Thanks, @0x80. Do you know about the (possibly undocumented) For example:
I get the local dependencies in by bundling them with
No copying, linking, zipping, vendoring or any of that nonsense. The dummy
The
I can re-run |
@johndunderhill I tried it at some point in the beginning and somehow concluded that it wasn't doing what I needed. I think it doesn't take the original lockfile into account. It was quite a long and winding road for me to get to the isolated lockfile for pnpm, so I don't quite remember everything. Eventually, the process of adapting the lockfile is quite straightforward, and also fast, so I don't think there's much to gain from using an alternative approach. |
I had the same problem and finally found a solutionIn my case it's only types and therefore a devellopement dependency but the library is well built in the modules nodes so it should work for the rest. I finally found the solution in the google doc... Change this: pre-deploy.jsconst fs = require("fs");
fs.readFile("./package.json", "utf8", (err, data) => {
if (err) {
console.error("Erreur lors de la lecture du fichier package.json :", err);
return;
}
const packageJson = JSON.parse(data);
packageJson.devDependencies["@types/gcrm"] = "file:1.0.0";
fs.writeFile(
"./package.json",
JSON.stringify(packageJson, null, 2),
"utf8",
(err) => {
if (err) {
console.error(
"Erreur lors de l'écriture dans le fichier package.json :",
err,
);
return;
}
console.log("Le fichier package.json a été mis à jour avec succès.");
},
);
}); Does the same but reverse process in post-deploy.js (or add conditionning for switch also) firebase.json"functions": [
{
"source": "apps/backend/functions",
"codebase": "default",
"ignore": [
"node_modules",
".git",
"firebase-debug.log",
"firebase-debug.*.log"
],
"predeploy": [
"pnpm --prefix \"$RESOURCE_DIR\" run predeployscript",
"pnpm --prefix \"$RESOURCE_DIR\" run lint",
"pnpm --prefix \"$RESOURCE_DIR\" run build"
],
"postdeploy": [
"pnpm --prefix \"$RESOURCE_DIR\" run postdeployscript"
]
}
], Don't forget to create the script on your package.json "scripts": {
"lint": "eslint --ext .js,.ts .",
"lint:fix": "eslint --ext .js,.ts --fix .",
"format": "prettier --write \"src/**/*.ts\"",
"build": "pnpm run format && tsc",
"build:watch": "tsc --watch",
"dev": "pnpm run build && firebase emulators:start --only functions",
"shell": "pnpm run build && firebase functions:shell",
"start": "pnpm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log",
"test": "vitest",
"test:ui": "vitest --ui",
"predeployscript": "node ./pre-deploy.js",
"postdeployscript": "node ./post-deploy.js"
},
Bye |
I am facing a pretty serious situation in which I cannot deploy/fix any functions to my project (pnpm based).
Trying to deploy fail with this error:
The proposed fix (adding
@google-cloud/functions-framework
) does not help.[REQUIRED] Environment info
firebase-tools: 12.2.1
Platform: Linux Mint 21.1
[REQUIRED] Test case
firebase deploy --only functions:bigben
)The log file for the deploy operation is attached.
[REQUIRED] Steps to reproduce
See above
[REQUIRED] Expected behavior
Functions should deploy when a project is set-up with pnpm
[REQUIRED] Actual behavior
See error above:
I am not sure since when this occurs, but I deployed new functions without any issues 3rd May.
firebase-debug.log
The text was updated successfully, but these errors were encountered: