firebase / firebase/firebase-tools

`bootstrap.js` doesn't work with ESM

Open
#5,847 9 comments 0 reactions 1 assignee Claimed by @jamesdaniels View on GitHub
integration: web frameworks type: bug
Dominant language
TypeScript
Stars
4.5k
Forks
1.3k
Avg merge
1d 12h
Merged PRs (30d)
84

Description

The emulator starts but then crashes with the following error when I make a request to my Express-based website:
```
ReferenceError: exports is not defined in ES module scope
> This file is being treated as an ES module because it has a '.js' file extension and '/functions/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
```

That's because it's using `exports.handle`. It should be `export const handle` when the application is using ESM.

https://github.com/firebase/firebase-tools/blob/56fb8a34201ab903f92178f696bc3b28acfb79bb/src/frameworks/express/index.ts#L64-L69

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.