3

I am developing with Firebase Cloud Functions and testing on local emulators. I am using Typescript as my language. However, whenever I update my code and hit save, the changes do not reflect in the emulator. I would always have to stop and re-run the emulator. Is there a way where I could achieve this without having to stop and re-run?

1 Answer 1

9

Typescript supports a configuration file called tsconfig.json. In that file you can configure the compiler, define code formatting rules and more importantly for you, provide it with information about the TS files in your project. You have it watch the files for changes then you can use the 'watch' flag: tsc --watch inside your package scripts.

Script:

"scripts": {
   "serve": "npm run build -- --watch | firebase emulators:start --only functions",
   ...
}`

A common tsconfig.json file:

{
"compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "declaration": false,
    "noImplicitAny": false,
    "removeComments": true,
    "noLib": false
},
"include": [
    "**/*"
],
"exclude": [
    "node_modules",
    "**/*.spec.ts"
]}

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.