I am working on speeding up my firebase functions deployment and noticed that firebase functions use cloud build to download and install the dependencies from package.json serverside again and was missing a package-lock.json, so had to calculate all dependencies again.
According to the documentation, yarn can be used too if a yarn lock file is specified. We use yarn 3 in our project, which means we only have a single yarn lock file for the whole workspace.
At first that failed, because firebase functions deployment by default uses yarn 1. I found out that one can specify the yarn version via the package.json engines. So I had working yarn 3.
I tried this and found out installing using yarn takes longer than using npm without a lockfile, because yarn has to download all dependencies again. So I tried adding the cache to do a yarn pnp like install, but had problems because of the 100 mb cloud functions size limit. As a workaround I deleted the biggest dependencies from the cache, but it seems if a cache is uploaded the buildpack switches to --immutable-cache
Currently I am considering using npm for installing my dependencies clientside, so I at least get the benefit of a package-lock.json serverside. I would prefer to have the speed of yarn for my deploys - since they are currently the longest running task in my CI. Does anybody have a working setup here? The setup with yarn 3 would work for me if the cache was somehow being used, but it seems to be ignored.