如何使用Firebase云函数的TypeScript引用?
我的Firebase项目都是TypeScript。我有一个如何使用Firebase云函数的TypeScript引用?,typescript,firebase,google-cloud-functions,Typescript,Firebase,Google Cloud Functions,我的Firebase项目都是TypeScript。我有一个corelib,用于在我的云功能和Web应用程序之间共享一些代码。作为npm包维护core开始变得非常麻烦,因为为了在代码中做一个小的更改并在部署中测试它,我必须构建库、升级版本、发布它,等等。因此,我决定迁移到 我的目录结构类似于: ./functions ./webapp ./lib ./core 然后functions有一个tsconfig.json文件,其中包含: "references": [ {
core
lib,用于在我的云功能和Web应用程序之间共享一些代码。作为npm包维护core
开始变得非常麻烦,因为为了在代码中做一个小的更改并在部署中测试它,我必须构建库、升级版本、发布它,等等。因此,我决定迁移到
我的目录结构类似于:
./functions
./webapp
./lib
./core
然后functions
有一个tsconfig.json
文件,其中包含:
"references": [
{"path": "../lib/core"}
]
使用tsc--build
构建函数
项目是可行的,但是构建的*.js
函数文件中对核心的依赖性最终是:
const core_1 = require("../../../lib/core");
因此,在firebase--deploy
之后,firebase会抱怨:
⚠ functions[testFunction(us-central1)]: Deployment error.
Function failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation.
我想这是因为这个要求
我已经研究过在引用中使用prepend:true
,但我不知道这是否会适得其反,因为我的core
项目依赖于firebase函数
和其他firebase lib
有没有办法让tsc
将引用的项目引入dist
(输出目录)的结构中