FilledStacks / firebase-backend

A package that helps with the management and expansion of a maintainable firebase backend

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pre-compile functions

adamschnaare opened this issue · comments

At present, each time any function is called, the function parser runs through each file on disk and re-creates all the functions. This is unnecessary, and noisy in the logs.

I think there should be a script that runs pre-deploy to create the exported and compiled index file. This should represent all of the exports that firebase functions is expecting.

While this may not be an issue with a handful of apis - I could see this being a problem if there were many more.

@adamschnaare I didn't know this is the case. I though the index file is only run once.

When I'm using it the logs only print out once unless I change the source code then it rebuilds all of them. When doing normal requests only the function that's supposed to fire is printed out.

Unless I've ignored that in my mind when looking at the logs. Which is possible.

@FilledStacks , From what I can tell, the deployed function is just a parser, it isn't actually separate functions. The only thing that the index file exports is something to handle a request - it doesn't actually export multiple functions recognized by firebase.

Meaning, when you run firebase deploy, only one function gets deployed, no matter how many functions you have developed in the system. This means that each time that one function runs, all of its logic has to run as well - namely the parsing of the function files.

I am about 70% through a draft attempting to precompile them. So the proposed flow would be:

  1. npm run prebuild -> compiles built files for each function
  2. firebase deploy / firebase emulators:start -> run or deploy functions

BUT...if I'm doing something wrong - I will be delighted to know, as this would be busy work I would gladly not do :)

Okay...so, I think I was wrong. I retested and I only see the parsing functions logs after:

  1. I rebuild
  2. I invoke that particular function (either restful or reactive)

So...apologies for the noise, but I'm closing this.