Firebase functions - compile typescript code before running emulators:start

1.1k Views Asked by At

I have a Firebase project setup with /functions directory, where all the source code is getting compiled from /src to the /dist directory.

The question is: how to configure Firebase in such way that it will run tsc command each time before starting the Local Emulator Suite? I wonder if there is a similar property to functions.predeploy in firebase.json config, but for the Local Emulator Suite:

{
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "functions": {
    "predeploy": [
      "npm --prefix functions run build"
    ],
    // something like this:
    "preemulator": [
      "npm --prefix functions run build"
    ]
  }
}

Here is a build script from package.json:

  "scripts": {
    // ...
    "build": "./node_modules/.bin/tsc",
  }
0

There are 0 best solutions below