Skip to content

JS ESM Compatibility? #42

@chrisspiegl

Description

@chrisspiegl

Hello, I have been trying to use this library for a few hours and can't get it to work. Here's what I am doing:

I generally use the ESM (type=module) setting in my node.js projects. However, it seems the exports setting of this library is giving me heart aches 🙈.

This is my index.js:

import bff from 'better-firebase-functions'
import { fileURLToPath } from 'node:url'
const __filename = fileURLToPath(import.meta.url)

const result = bff.exportFunctions({
  enableLogger: true,
  __filename,
  exports: module.exports,
  // exportPathMode: true,
})
console.log('BFF RESULT:', result)

Note that I already found a way to replace the __filename since that appears to be missing in ESM, but no matter what I set for the exports parameter, I never get it to work. module.exports is not defined and the same is true if I just use exports.

  • Does anyone know of a solution for this?
  • Is it possible in some way to use Better Firebase Functions with ESM / import?

Thank you, I am looking forward to reading from you.

Cheers, Chris

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions