firebase-tools
firebase-tools copied to clipboard
Function emulator unable to recognize multiple "codebase" entries
[REQUIRED] Environment info
firebase-tools: 11.7.0
Platform: macOS
[REQUIRED] Test case
project structure
/
firebase.json
/packages
/web (next.js project)
/functions (regular firebase functions)
firebase.json file
{
"functions": [
{
"source": "./packages/web",
"codebase": "nextJs",
"predeploy": [
"yarn --cwd \"$RESOURCE_DIR\" run lint",
"yarn --cwd \"$RESOURCE_DIR\" run build"
],
"runtime": "nodejs16"
},
{
"source": "./packages/functions",
"codebase": "functions",
"predeploy": [
"yarn --cwd \"$RESOURCE_DIR\" run lint",
"yarn --cwd \"$RESOURCE_DIR\" run build"
],
"runtime": "nodejs16"
}
],
"emulators": {
"functions": {
"port": 5001
}
}
}
[REQUIRED] Steps to reproduce
- Create project structure as above
- Use the firebase.json file above
- Start firebase hosting emulator using
firebase emulators:start
[REQUIRED] Expected behavior
In the latest documentation about organizing functions in a monorepo it appears that we should be able to use multiple function directories from the same project. I'd expect that the hosting emulator would understand the array directive under the functions
key, but it does it.
[REQUIRED] Actual behavior
The firestore emulator complains that ⚠ functions: The functions emulator is configured but there is no functions source directory. Have you run firebase init functions?

I've also encountered this issue, going down the rabbit hole the errors is here, the getFunctionsSDKVersion
function runs the command:
npm list firebase-functions --json=true
In a non-monorepo setup that will yield:
{
"name": "functions",
"dependencies": {
"firebase-functions": {
"version": "3.23.0",
"resolved": "https://registry.npmjs.org/firebase-functions/-/firebase-functions-3.23.0.tgz"
}
}
}
Whereas in a monorepo results in:
{
"version": "1.0.4",
"name": "monorepo",
"dependencies": {
"@backend": {
"version": "1.0.0",
"resolved": "file:../../packages/backend",
"dependencies": {
"firebase-functions": {
"version": "3.21.2",
"resolved": "https://registry.npmjs.org/firebase-functions/-/firebase-functions-3.21.2.tgz"
}
}
}
}
}
Finally, when reading the version, this code gets executed:
_.get(output, ["dependencies", "firebase-functions", "version"]);
That will work on the first payload but fail for the second one.
I have the same issue
Hi everyone, you all noticed an area of improvement in the functions emulator! We currently have a feature request bug for adding codebase
support - #4878
I'm going to close this so we don't have duplicate issues open. Thanks