在打字稿中开发 firebase 函数时,我正在尝试让源映射正常工作。
在我的
tsconfig.json
文件中启用了源映射。
这生成了源映射。然后我将这一行包含在我的
index.ts
文件中:
import 'source-map-support/register';
然后它似乎起作用了。配置是否正确,以及
source-map-support
到项目 package.json
文件?
是的,您需要做一些事情,其中一些已记录在here:
npm install source-map-support
通过添加以下内容在
sourceMap
(不是package.json!)中启用
tsconfig.json
:
"compilerOptions": {
"sourceMap": true,
...
},
import 'source-map-support/register'
require('source-map-support').install();
结果将改变这一点:
TypeError: Cannot read property 'current_location' of null
at /user_code/lib/http_actions.js:173:74
at next (native)
at fulfilled (/user_code/lib/http_actions.js:4:58)
at process._tickDomainCallback (internal/process/next_tick.js:135:7)
进入这个:
TypeError: Cannot read property 'current_location' of null
at /user_code/src/http_actions.ts:183:33
at next (native)
at fulfilled (/user_code/lib/http_actions.js:4:58)
at process._tickDomainCallback (internal/process/next_tick.js:135:7)
在部署该功能时设置
NODE_OPTIONS=--enable-source-maps
,您将不需要任何额外的导入。
不确定 firebase 功能,但它们基本上是谷歌云功能,你可以这样做
--set-env-vars NODE_OPTIONS=--enable-source-maps
在 gcloud 函数中部署。