{"id":24995,"library":"better-firebase-functions-esbuild","title":"better-firebase-functions-esbuild","description":"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.","status":"active","version":"7.1.1","language":"javascript","source_language":"en","source_url":"https://github.com/george43g/better-firebase-functions","tags":["javascript","firebase","cloud-functions","esbuild","esbuild-plugin","optimization","tree-shaking","typescript"],"install":[{"cmd":"npm install better-firebase-functions-esbuild","lang":"bash","label":"npm"},{"cmd":"yarn add better-firebase-functions-esbuild","lang":"bash","label":"yarn"},{"cmd":"pnpm add better-firebase-functions-esbuild","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: required for bundling functions.","package":"esbuild","optional":false}],"imports":[{"note":"ESM-only since v7.0.0; require() will fail.","wrong":"const buildFunctions = require('better-firebase-functions-esbuild')","symbol":"buildFunctions","correct":"import { buildFunctions } from 'better-firebase-functions-esbuild'"},{"note":"Named export; default export is undefined.","wrong":"import * as BFF from 'better-firebase-functions-esbuild'; BFF.discoverFunctionEntryPoints()","symbol":"discoverFunctionEntryPoints","correct":"import { discoverFunctionEntryPoints } from 'better-firebase-functions-esbuild'"},{"note":"This helper is in the esbuild plugin package, not the main BFF package.","wrong":"import { discoverBuildEntryPoints } from 'better-firebase-functions'","symbol":"discoverBuildEntryPoints","correct":"import { discoverBuildEntryPoints } from 'better-firebase-functions-esbuild'"}],"quickstart":{"code":"import { buildFunctions } from 'better-firebase-functions-esbuild';\nimport { resolve } from 'path';\n\n// Ensure your entry point exports functions via exportFunctions/exportFunctionsAsync\nawait buildFunctions({\n  entryPoint: resolve(__dirname, 'src/index.ts'),\n  outdir: resolve(__dirname, 'dist'),\n  target: 'node20',\n  verbose: true,\n});\n// Output: dist/main.js and dist/functions/**/*.js mirroring runtime layout","lang":"typescript","description":"Builds per-function bundles using the BFF entry point config (ESM, Node 20, TypeScript)."},"warnings":[{"fix":"Upgrade Node to >=14 or use v5.0.0 if stuck on older Node.","message":"v6.0.0 dropped support for Node <14, upgraded all dependencies.","severity":"breaking","affected_versions":">=6.0.0 <7.0.0"},{"fix":"Migrate your project to ESM (type: module in package.json) and use import syntax.","message":"v7.0.0 switched to ESM-only; CommonJS require() no longer works.","severity":"breaking","affected_versions":">=7.0.0"},{"fix":"Use buildFunctions() instead of the plugin for per-function output.","message":"bffEsbuildPlugin() cannot add entry points dynamically; it only logs. Use buildFunctions() for actual bundling.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Wrap side effects in guards that skip during discovery mode (check process.env.BFF_DISCOVERY).","message":"If 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.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Switch to import syntax and set \"type\": \"module\" in your package.json, or use dynamic import().","cause":"Package is ESM-only since v7.0.0, but your project uses CommonJS require().","error":"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."},{"fix":"Use import { bffEsbuildPlugin } from 'better-firebase-functions-esbuild'.","cause":"Incorrect import: default import attempted but bffEsbuildPlugin is a named export.","error":"TypeError: bffEsbuildPlugin is not a function"},{"fix":"Ensure your entry point invokes exportFunctions({ ... }) with correct functionDirectoryPath and searchGlob.","cause":"Entry point does not call exportFunctions() or exportFunctionsAsync(), or the glob pattern finds no files.","error":"Error: No functions discovered. Check your entry point exports functions via exportFunctions/exportFunctionsAsync."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}