firebase - Firebase 函数的 Sourcemap 支持吗?

标签 firebase google-cloud-functions

在 typescript 中开发 firebase 函数时,我试图让源映射正常工作。

在我的 tsconfig.json 文件中启用了源映射。

这生成了源映射。然后,我将这一行包含在我的 index.ts 文件中:

import 'source-map-support/register';

然后它似乎就起作用了。此配置是否正确,并且 source-map-support 是否已添加到项目 package.json 文件中?

最佳答案

是的,您需要做一些事情,其中​​一些已记录在here中:

  1. npm install source-map-support

  2. 通过添加以下内容在 tsconfig.json 中启用 sourceMap(不是 package.json!):

  "compilerOptions": {
    "sourceMap": true,
    ...
  },
  • 将库导入到您的文件中
    • 如果您使用 ES6 模块:import 'source-map-support/register'
    • 如果您使用 commonJS 模块: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)
    

    关于firebase - Firebase 函数的 Sourcemap 支持吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51321965/

    相关文章:

    node.js - 如何在云函数中的config.json文件中提及.csv和.json文件格式来触发DAG

    node.js - Firebase:firebase.messaging() 不是函数

    git - 如何使用 cloudbuild yaml 排除部署中的文件和目录?

    android - Firebase - 未找到 GetTokenResult、getExpirationTimestamp()

    Firebase RTDB 在关键字列表中搜索关键字

    javascript - 使用 JavaScript 中的 Firebase 云函数更新标签栏项目徽章的 ios 静默推送通知的有效负载

    node.js - 如何从 Google Cloud Function(Cheerio、Node.js)发出多个 http 请求

    typescript - Firebase 模拟器缺少 tsconfig.json?

    java - Firebase 阅读问题。对象始终为空

    android - DocumentSnapshot (Firestore) 到包含自定义对象列表的 Kotlin 对象