Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sourcemap support for firebase functions?

I am trying to get sourcemaps to work, when developing firebase functions in typescript.

In my tsconfig.json file a have source maps enabled.

This generated the sourcemaps. I then include this line in my index.ts file:

import 'source-map-support/register';

And then it seems to work. Is this correct configured, and source-map-support to the projects package.json file?

like image 563
DauleDK Avatar asked Mar 06 '23 19:03

DauleDK


1 Answers

Yes, you need to do a few things, some of which is documented here:

  1. npm install source-map-support

  2. Enable sourceMap in tsconfig.json (not package.json!) by adding:

  "compilerOptions": {
    "sourceMap": true,
    ...
  },
  1. Import the library into your file
    • If you're using ES6 modules: import 'source-map-support/register'
    • If you're using commonJS modules: require('source-map-support').install();

the result would transform this:

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)

into this:

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)
like image 56
Benos Avatar answered Apr 05 '23 14:04

Benos