simondotm / nx-firebase

Firebase plugin for Nx Monorepos
https://www.npmjs.com/package/@simondotm/nx-firebase
MIT License
175 stars 31 forks source link

Firebase functions & `pnpm` support #203

Closed simondotm closed 2 months ago

simondotm commented 3 months ago

Deploying Firebase functions from github actions workflow.

Getting errors that my lockfile and package.json are not in sync. It's using the lockfile from the workspace root package.json, and using packages from the project firebase directory package.json

apps/projectName/functions/package.json

I do have the function packages.json and pnpm-lock.yaml in the build directory, where pnpm-lock.yaml is generated during the functions build

I found a workaround by changing the nx.json:cli:packageManager to "npm" on the fly in workflow, but then also have to maintain a root package-lock.json file alongside the pnpm-lock.yaml file.

I believe this works because npm does not force the lockfile to be in sync with the functions package.json.

Please let me know if there is something I need to adjust, or if this is possibly a bug of some kind.

Originally posted by @Lowell20 in https://github.com/simondotm/nx-firebase/issues/193#issuecomment-2018869760

I'm quite interested in pnpm compatibility, and I'm currently trying to migrate this plugin to it at the moment, mainly for speed reasons with CI & e2e/compatibility testing.

In terms of pnpm support for firebase functions in Nx workspaces that use pnpm, I think it should just work.

As far as I can tell, as long as Nx knows the workspace package manager is pnpm it will generate a pruned `pnpm-lock.yaml' for firebase functions built with esbuild (from Nx 16.8.1+ anyway).

If the workspace package manager is npm, it will generate a pruned package-lock.json instead.

I've yet to try deploying a function with pnpm-lock.yarn, so would be interested to know if anyone in the community has got this working.

simondotm commented 3 months ago

I dug a little bit deeper and found that around the time that you started seeing this behavior (end of may), the https://github.com/GoogleCloudPlatform/buildpacks/issues/193#issuecomment-1570604865. They state that you would need to have the @google-cloud/functions-framework dependency installed, like the error gives.

A comment from an issue in firebase tools. Seems like pnpm is supported, but that dependency needs to be added.

We'll likely need to add this to the plugin initialiser then.