firebase / firebase/firebase-tools

Deno-bundled artifacts fail to register with Firebase Functions

Open
#9,632 2 comments 0 reactions 0 assignees View on GitHub
api: functions type: feature request
Dominant language
TypeScript
Stars
4.5k
Forks
1.3k
Avg merge
1d 12h
Merged PRs (30d)
84

Description

### [REQUIRED] Environment info

**firebase-tools:** 15.0.0

**Platform:** Linux

### [REQUIRED] Test case

A minimal reproduction repository is available here: https://github.com/snorreks/deno-firebase-functions-bundle-bug

The repository contains a simple HTTP function and scripts to demonstrate the bundling issue.

```typescript
// src/index.ts
import { onRequest } from "firebase-functions/v2/https";
import { initializeApp } from "firebase-admin/app";

initializeApp();

export const hello = onRequest((req, res) => {
res.send("Hello from Firebase!");
});
```

### [REQUIRED] Steps to reproduce

1. Clone the reproduction repository: `git clone https://github.com/snorreks/deno-firebase-functions-bundle-bug.git`
2. `cd deno-firebase-functions-bundle-bug`
3. Run the Deno build script to generate the problematic bundle: `deno run -A --unstable-bundle build.ts`
4. Navigate to the directory containing the Deno-generated bundle: `cd dist/deno-bundle`
5. Attempt to deploy the function: `firebase deploy --only functions`

### [REQUIRED] Expected behavior

The `firebase deploy` command should correctly identify the `hello` function within the bundled `index.js` file and proceed with the deployment.

### [REQUIRED] Actual behavior

The `firebase deploy` command fails immediately with the following error, indicating it cannot parse the bundled artifact to find the Functions SDK.

```
Error: Failed to find location of Firebase Functions SDK. Please file a bug on Github (https://github.com/firebase/firebase-tools/).
```

This issue occurs specifically when the code is bundled using Deno's native bundling capabilities (`Deno.bundle`) or tools that use its resolution logic (like `@luca/esbuild-deno-loader`). Bundling the exact same source code with standard Node.js-based `esbuild` results in a successful deployment, which points to an incompatibility between how the Firebase CLI discovers functions and how Deno generates its ESM output for Node.js targets.

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.