My typescript firebase function project is simple yet the code works fine. However, there seems to be an issue in the project configuration that causes firebase serve
NOT to recompile the code before starting the server. On the contrary, firebase deploy
works perfectly.
The project directory structure is as follows:
firebase
-.firebaserc
-firebase.json
-functions
--package.json
--tsconfig.json
--src
---...all the code goes here
--built
---...compiled code goes here
This is the content of firebase.json:
{
"functions": [
{
"source": "functions",
"codebase": "default",
"ignore": [
"node_modules",
".git",
"firebase-debug.log",
"firebase-debug.*.log"
],
"predeploy": "npm --prefix functions run build"
}
]
}
And this is the content of package.json:
{
"name": "functions",
"scripts": {
"build": "tsc",
...
},
...
}
If I navigate inside the functions folder and execute npm run serve
, everything works as expected. But when running firebase serve
, it only serves the webserver with the current compiled code without reflecting any modifications. If the code isn't compiled yet, it fails to start. What steps can I take to resolve this issue?