在 typescript 中开发 firebase 函数时,我试图让源映射正常工作。
在我的 tsconfig.json
文件中启用了源映射。
这生成了源映射。然后,我将这一行包含在我的 index.ts
文件中:
import 'source-map-support/register';
然后它似乎就起作用了。此配置是否正确,并且 source-map-support
是否已添加到项目 package.json
文件中?
最佳答案
是的,您需要做一些事情,其中一些已记录在here中:
npm install source-map-support
通过添加以下内容在
tsconfig.json
中启用sourceMap
(不是 package.json!):
"compilerOptions": {
"sourceMap": true,
...
},
- 将库导入到您的文件中
- 如果您使用 ES6 模块:
import 'source-map-support/register'
- 如果您使用 commonJS 模块:
require('source-map-support').install();
- 如果您使用 ES6 模块:
结果将改变这一点:
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)
关于firebase - Firebase 函数的 Sourcemap 支持吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51321965/