cbdeveloper
cbdeveloper

Reputation: 31425

Which files are sent to the Firebase cloud functions environment when you deploy the functions?

Let's say I have the following structure inside my functions folder for my Firebase app.

functions
  > node_modules      // INSTALLED NODE MODULES
  > distApp           // REACT APP FILES TRANSPILED WITH BABEL
      App.js
      index.html
  > distFunctions     // FUNCTION FILES TRANSPILED WITH BABEL
      function1.js    // SOME OF THEM USE FILES FROM 'distApp' FOLDER
      function2.js
  > src               // FUNCTION FILES WRITTEN IN ES6+
      function1.js
      function2.js
indexES6.js           // CLOUD FUNCTIONS index.js WRITTEN IN ES6+
index.js              // CLOUD FUNCTIONS index.js TRANSPILED WITH BABEL
package.json

QUESTION

I would like to understand what happend when I deploy my index.js file.

NOTE: This functions folder lives inside my Firebase project root folder, where I have a firebase.json file and everything else needed for deployment.

PS: I know it's not best practice to ask more than one question here on SO, but they're all related to the main question: "Exactly which files and folders are deployed to the cloud functions environment when you run firebase deploy --only functions "?

Upvotes: 3

Views: 541

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317542

Everything from your functions folder gets deployed, except node_modules. It doesn't matter what your index.js contains.

Cloud Functions will reconstitute your node_modules folder on the backend by running npm install. So, the contents of your package.json matters a lot.

In the end, Cloud Functions builds a docker image and puts all those files and modules from your functions folder into it, and it will all be available when your function executes.

Upvotes: 4

Related Questions