首页 > 解决方案 > firebase deploy 跳过导出的函数

问题描述

我最近在我的项目中添加了一个新的云功能,但由于某种原因,当我部署它时被跳过:

firebase deploy --only functions:stripeOperation

这导致

⚠ 函数:指定了以下过滤器,但不匹配项目中的任何函数:stripeOperation

文件结构是这样的:

functions/
├── src/
│   ├── stripe
│   │    ├── index.ts
│   │    ├── myTrigger.ts
│   │    ├── anotherTrigger.ts
│   │    └── stripeOperation.ts
│   ├── index.ts

functions/src/stripe/index导出条带文件夹中的所有 3 个函数。 functions/src/index从条带文件夹中导出它们:

export { stripeOperation, myTrigger, anotherTrigger } from './stripe';

这就是它变得奇怪的地方 -myTriggeranotherTrigger成功部署,但stripeOperation没有。没有构建错误。Firebase 没有给我任何关于它为什么被跳过的线索。我检查了一下,转译的代码看起来不错。stripeOperation是一个可调用函数,但其​​他 2 个是 firestore 触发器。这是 的签名stripeOperation

export const stripeOperation = functions.https.onCall((data, context) => {
  ...
});

有什么方法可以确定为什么 firebase 不会部署我的功能?我在用"firebase-functions": "^2.3.1"

更新:我尝试重命名该函数,并使用先前部署的函数完全切换函数体,但均未成功。

标签: firebasegoogle-cloud-functions

解决方案


您必须将可调用函数与触发器函数分开导出。这没有意义,所以我提出了一个问题

functions/src/index

export { stripeOperation } from './stripe/stripeOperation';
export { myTrigger, anotherTrigger } from './stripe';

推荐阅读