{"id":20998,"library":"better-firebase-functions-rollup","title":"better-firebase-functions-rollup","description":"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.","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","rollup","rollup-plugin","optimization","tree-shaking","typescript"],"install":[{"cmd":"npm install better-firebase-functions-rollup","lang":"bash","label":"npm"},{"cmd":"yarn add better-firebase-functions-rollup","lang":"bash","label":"yarn"},{"cmd":"pnpm add better-firebase-functions-rollup","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required as a plugin for Rollup bundler","package":"rollup","optional":false}],"imports":[{"note":"Named ESM export. CommonJS require will not work in Node >=20 with ESM module type.","wrong":"const bffRollupPlugin = require('better-firebase-functions-rollup')","symbol":"bffRollupPlugin","correct":"import { bffRollupPlugin } from 'better-firebase-functions-rollup'"},{"note":"Named export, not default. Default import is undefined.","wrong":"import bffRollupOutput from 'better-firebase-functions-rollup'","symbol":"bffRollupOutput","correct":"import { bffRollupOutput } from 'better-firebase-functions-rollup'"},{"note":"Type-only import to avoid runtime import error, especially in TypeScript's isolatedModules.","wrong":"import { BffRollupPluginOptions } from 'better-firebase-functions-rollup'","symbol":"bffRollupPlugin (type)","correct":"import type { BffRollupPluginOptions } from 'better-firebase-functions-rollup'"}],"quickstart":{"code":"// file: rollup.config.ts\nimport { resolve } from 'path';\nimport { bffRollupPlugin, bffRollupOutput } from 'better-firebase-functions-rollup';\n\n// Runtime entry point (src/index.ts) should call exportFunctions() with config\nexport default {\n  input: resolve(__dirname, 'src/index.ts'),\n  output: bffRollupOutput({\n    dir: resolve(__dirname, 'dist'),\n    mainFileName: 'main.js',\n    format: 'cjs',\n  }),\n  plugins: [\n    bffRollupPlugin({\n      entryPoint: resolve(__dirname, 'src/index.ts'),\n      verbose: true,\n    }),\n  ],\n};","lang":"typescript","description":"Configures Rollup with bffRollupPlugin to discover Firebase functions and bffRollupOutput to emit per-function chunks preserving source layout."},"warnings":[{"fix":"Upgrade to at least Node 20, and ensure npm >=11.10.0.","message":"v6.0.0 dropped support for Node <14; engine requirement changed to >=20 in v7.0.0","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Explicitly set searchGlob to '**/*.func.js' if you need to maintain previous behavior.","message":"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","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Ensure your project has rollup@3 or higher installed.","message":"Plugin requires a peer dependency of rollup >=3.0.0; using with rollup 2.x will silently fail or cause errors","severity":"gotcha","affected_versions":">=7.0.0"},{"fix":"If you override the function name logic, update to use K_SERVICE.","message":"FUNCTION_NAME environment variable replaced by K_SERVICE in v3.3.1; the plugin now uses K_SERVICE internally","severity":"deprecated","affected_versions":">=3.3.1"},{"fix":"Provide explicit functionDirectoryPath, searchGlob, and funcNameFromRelPath as fallback options in bffRollupPlugin.","message":"If entry point cannot be executed during build (e.g., due to side effects), build-discovery fails and fallback manual overrides must be provided","severity":"gotcha","affected_versions":">=7.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run: npm install -D better-firebase-functions-rollup","cause":"Package not installed or wrong import path","error":"Error: Cannot find module 'better-firebase-functions-rollup'"},{"fix":"Change import to: import { bffRollupPlugin } from 'better-firebase-functions-rollup'","cause":"Default import used instead of named import","error":"TypeError: bffRollupPlugin is not a function"},{"fix":"Make sure config is synchronous and default export is the config object","cause":"Rollup config returned promise or invalid shape (common when using dynamic imports in config)","error":"Error: rollup.config.ts must be a function or an object"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}