better-firebase-functions-rollup
raw JSON → 7.1.1 verified Mon Apr 27 auth: no javascript
Rollup plugin for better-firebase-functions that enables per-function bundling with tree shaking for Firebase Cloud Functions. Current stable version is v7.1.1 (released April 2026) with active development and frequent releases. It discovers function files by executing the BFF entry point in build-discovery mode, reusing existing config (functionDirectoryPath, searchGlob, funcNameFromRelPath). Outputs one bundled chunk per function preserving the original directory layout. Supports TypeScript, ESM/CJS, and requires Rollup >=3. Key differentiator: it eliminates the need to duplicate glob configuration and automates function splitting without manual input.
Common errors
error Error: Cannot find module 'better-firebase-functions-rollup' ↓
cause Package not installed or wrong import path
fix
Run: npm install -D better-firebase-functions-rollup
error TypeError: bffRollupPlugin is not a function ↓
cause Default import used instead of named import
fix
Change import to: import { bffRollupPlugin } from 'better-firebase-functions-rollup'
error Error: rollup.config.ts must be a function or an object ↓
cause Rollup config returned promise or invalid shape (common when using dynamic imports in config)
fix
Make sure config is synchronous and default export is the config object
Warnings
breaking v6.0.0 dropped support for Node <14; engine requirement changed to >=20 in v7.0.0 ↓
fix Upgrade to at least Node 20, and ensure npm >=11.10.0.
breaking v5.0.0 changed default searchGlob to include both .js and .ts files, which may break setups expecting only .js files in the same directory ↓
fix Explicitly set searchGlob to '**/*.func.js' if you need to maintain previous behavior.
gotcha Plugin requires a peer dependency of rollup >=3.0.0; using with rollup 2.x will silently fail or cause errors ↓
fix Ensure your project has rollup@3 or higher installed.
deprecated FUNCTION_NAME environment variable replaced by K_SERVICE in v3.3.1; the plugin now uses K_SERVICE internally ↓
fix If you override the function name logic, update to use K_SERVICE.
gotcha If entry point cannot be executed during build (e.g., due to side effects), build-discovery fails and fallback manual overrides must be provided ↓
fix Provide explicit functionDirectoryPath, searchGlob, and funcNameFromRelPath as fallback options in bffRollupPlugin.
Install
npm install better-firebase-functions-rollup yarn add better-firebase-functions-rollup pnpm add better-firebase-functions-rollup Imports
- bffRollupPlugin wrong
const bffRollupPlugin = require('better-firebase-functions-rollup')correctimport { bffRollupPlugin } from 'better-firebase-functions-rollup' - bffRollupOutput wrong
import bffRollupOutput from 'better-firebase-functions-rollup'correctimport { bffRollupOutput } from 'better-firebase-functions-rollup' - bffRollupPlugin (type) wrong
import { BffRollupPluginOptions } from 'better-firebase-functions-rollup'correctimport type { BffRollupPluginOptions } from 'better-firebase-functions-rollup'
Quickstart
// file: rollup.config.ts
import { resolve } from 'path';
import { bffRollupPlugin, bffRollupOutput } from 'better-firebase-functions-rollup';
// Runtime entry point (src/index.ts) should call exportFunctions() with config
export default {
input: resolve(__dirname, 'src/index.ts'),
output: bffRollupOutput({
dir: resolve(__dirname, 'dist'),
mainFileName: 'main.js',
format: 'cjs',
}),
plugins: [
bffRollupPlugin({
entryPoint: resolve(__dirname, 'src/index.ts'),
verbose: true,
}),
],
};