Registry / gcp / better-firebase-functions-esbuild

better-firebase-functions-esbuild

JSON →
library7.1.1jsnpmunverified

esbuild plugin for optimizing Firebase Cloud Functions builds. Version 7.1.1 is the latest stable, released April 2026, requiring Node >=20 and esbuild >=0.17.0. It provides per-function entry point generation with tree shaking by executing the BFF entry point in a discovery mode, automatically reusing runtime config (functionDirectoryPath, searchGlob, etc.) so no duplicate configuration is needed. Published weekly, it supports buildFunctions() as the recommended API, along with manual discovery helpers and a logging plugin. Differentiates from vanilla esbuild by automating the discovery of Firebase function files and maintaining the output directory structure matching the runtime layout.

npm install better-firebase-functions-esbuild
INSTALL
IMPORT
SIG · BETTER-FIREBASE-FU
B
better-firebase-functions-esbuild
gcpjavascriptv7.1.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

buildFunctions
import { buildFunctions } from 'better-firebase-functions-esbuild'
const buildFunctions = require('better-firebase-functions-esbuild')
ESM-only since v7.0.0; require() will fail.
discoverFunctionEntryPoints
import { discoverFunctionEntryPoints } from 'better-firebase-functions-esbuild'
import * as BFF from 'better-firebase-functions-esbuild'; BFF.discoverFunctionEntryPoints()
Named export; default export is undefined.
discoverBuildEntryPoints
import { discoverBuildEntryPoints } from 'better-firebase-functions-esbuild'
import { discoverBuildEntryPoints } from 'better-firebase-functions'
This helper is in the esbuild plugin package, not the main BFF package.

Builds per-function bundles using the BFF entry point config (ESM, Node 20, TypeScript).

import { buildFunctions } from 'better-firebase-functions-esbuild'; import { resolve } from 'path'; // Ensure your entry point exports functions via exportFunctions/exportFunctionsAsync await buildFunctions({ entryPoint: resolve(__dirname, 'src/index.ts'), outdir: resolve(__dirname, 'dist'), target: 'node20', verbose: true, }); // Output: dist/main.js and dist/functions/**/*.js mirroring runtime layout
Debug
Known issues
breakingv6.0.0 dropped support for Node <14, upgraded all dependencies.
fix
Upgrade Node to >=14 or use v5.0.0 if stuck on older Node.
affects: >=6.0.0 <7.0.0
breakingv7.0.0 switched to ESM-only; CommonJS require() no longer works.
fix
Migrate your project to ESM (type: module in package.json) and use import syntax.
affects: >=7.0.0
gotchabffEsbuildPlugin() cannot add entry points dynamically; it only logs. Use buildFunctions() for actual bundling.
fix
Use buildFunctions() instead of the plugin for per-function output.
affects: >=0.0.0
gotchaIf your entry point exports functions using exportFunctions(), you must provide the config at runtime; the plugin executes the entry point in discovery mode, so any external side effects may run twice.
fix
Wrap side effects in guards that skip during discovery mode (check process.env.BFF_DISCOVERY).
affects: >=0.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/node_modules/better-firebase-functions-esbuild/build/index.js from /path/to/your-script.js not supported.
Package is ESM-only since v7.0.0, but your project uses CommonJS require().
fix
Switch to import syntax and set "type": "module" in your package.json, or use dynamic import().
TypeError: bffEsbuildPlugin is not a function
Incorrect import: default import attempted but bffEsbuildPlugin is a named export.
fix
Use import { bffEsbuildPlugin } from 'better-firebase-functions-esbuild'.
Error: No functions discovered. Check your entry point exports functions via exportFunctions/exportFunctionsAsync.
Entry point does not call exportFunctions() or exportFunctionsAsync(), or the glob pattern finds no files.
fix
Ensure your entry point invokes exportFunctions({ ... }) with correct functionDirectoryPath and searchGlob.
Upgrade
Version history
7.1.1latest on npm
Audit
Dependencies
esbuildrequiredPeer dependency: required for bundling functions.
Agent activity
44 hits · last 30 days
node
40
OpenAI (training)
1
Resources
better-firebase-functions-esbuild — npm install better-firebase-functions-esbuild · libregistry