← 全部工具

firebase-tools-with-isolate

热度 65 更新于 开发与构建

Command-Line Interface for Firebase with monorepo support

npmauto-collected

安装

npm
npm install -g firebase-tools-with-isolate

通过 npm 安装。

Firebase CLI with monorepo support

This is a fork of firebase-tools that integrates isolate-package into the functions deploy command to support monorepo setups. Whether to run isolation is decided by detect-monorepo, so standalone projects are untouched.

The integration is minimal — roughly 50 lines of code across 3 files — and does not affect any existing functionality. Isolation runs automatically whenever your functions source directory sits inside a detected monorepo (pnpm / npm / yarn / bun workspaces, or Rush). Standalone projects are left untouched and behave exactly like upstream.

Installation

Add this dependency to the root of your monorepo:

pnpm add firebase-tools-with-isolate -D -w

Or the equivalent for NPM or Yarn. I encourage using pnpm — apart from being fast and efficient, it has better monorepo support, and the lockfile isolation code is solid and works in parallel for multiple packages, unlike NPM.

Important: Remove/uninstall the original firebase-tools package if you have it installed, because otherwise that binary might get precedence over the forked one and npx firebase deploy will execute the wrong one.

Usage

Installing the fork provides you with the same firebase command. On the command line, prefix it with npx:

npx firebase deploy

In package.json scripts, npx is not required — scripts already prefer locally installed binaries.

Configuration

No configuration is required. When you run firebase deploy, the fork calls detectMonorepo from detect-monorepo on the functions source directory. If a workspace root is found (pnpm-workspace.yaml, a parent package.json with a workspaces field, or rush.json), isolation runs automatically. Otherwise the deploy proceeds exactly as in upstream firebase-tools.

{
  "functions": {
    "source": ".",
    "runtime": "nodejs22",
    "predeploy": ["turbo build"]
  }
}

For a monorepo with multiple function packages, place firebase.json at the root:

{
  "functions": [
    {
      "source": "services/api",
      "predeploy": ["pnpm build:api"],
      "runtime": "nodejs22",
      "codebase": "api"
    },
    {
      "source": "services/fns",
      "predeploy": ["pnpm build:fns"],
      "runtime": "nodejs22",

} ] }