0

This is going to be a very elementary question but I want to have a clear understanding of the difference between exports.function = vs export const function = inside index.ts of functions folder generated from Firebase Cloud Functions.

  exports.function = functions
      .runWith(CONFIG.MEMORY)
      .https.onRequest(async (req, res) => {
      console.log("hi")
  })
  
  export const function = functions
      .runWith(CONFIG.MEMORY)
      .https.onRequest(async (req, res) => {
      console.log("hi")
  })

I understand both totally work fine, but for what reason is it considered to be better to use exports.function = than export const function inside index file at the top level of functions folder?

I read this `export const` vs. `export default` in ES6

If it’s not at the top level of folder, I can understand their behaviors but what I want to know is how firebase cloud functions deal with export const function differently than exports.function when it’s at the top level of functions folder, which is at index file???

Ryohei
  • 525
  • 1
  • 6
  • 16

0 Answers0