

Firebase Functions | How to use an ES module in JS functions
I'm trying to use a module in my firebase function, however it seems this is impossible.
Here is how I am currently successfully using it:
```
import * as sapling from "@saplingai/sapling-js";
const client = new sapling.Client(apiKey);
client.doStuff()
```
I want to transfer this to a backend function so I can hide my api key.
I really don't think there's even any point in discussing error messages. However, for the sake of it I'll show you a snippet.
Using it as I do succesfully on front end:
> Failed to load function definition from source: Failed to generate manifest from function source: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in package.json
Modified to use export:
> Failed to load function definition from source: Failed to generate manifest from function source: ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/.../package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
I could go on, but the suggestions do not lead to anything useful. Following them just leads back to the previous errors/suggestions.
I haven't been able to make a typescript function, ideally I do not want to as I would prefer to maintain a singular functions source, and the firebase functions typescript starter is buggy as hell.
I use dozens of other modules both ways, i.e. with import as well as require. I'd like to do the same thing here.