serverless-bundle icon indicating copy to clipboard operation
serverless-bundle copied to clipboard

How make sourcemaps run...

Open TheMechanic opened this issue 2 years ago • 3 comments

I lost my day on it, so I share it here. I was not able to have sourcemaps working. For making them work, you have to install 'source-map-support', then import at top of your entrypoint import 'source-map-support/register';

I don't get why this is not mentioned in the doc...

hoping it will help somebody else

TheMechanic avatar Mar 22 '22 17:03 TheMechanic

Hey @TheMechanic,

Just as an addition I tried this for typescript and although it was a bit more readable it didn't report the correct line numbers

Dashue avatar Mar 30 '22 11:03 Dashue

@TheMechanic @Dashue I think it could be useful if you added a bit more details on your errors, with like a screenshot of the error or something similar. That would either help other people help you, or allow people to see if they have the same errors that you experience.

I didn't have to add import 'source-map-support/register'; in any of my handlers, although, I had to set the NODE_OPTIONS environment variables like so:

environment: {
  NODE_OPTIONS: "--enable-source-maps",
},

With that, the source maps seem to at least be used. Although, since the code is minified, the stacktraces aren't much more useful... I wonder if this is expected or not.

With sourcemaps enabled: image

Without sourcemaps enabled: image

louislatreille avatar Apr 05 '22 12:04 louislatreille

@louislatreille There is a significant performance impact for using --enable-source-maps instead of import 'source-map-support/register' which is still unresolved.

I too am struggling to get serverless-bundle to solve the sourcemap problem with little intervention. I wouldn't need to include in the lambda zip if I could upload them to Sentry automatically...

Jackman3005 avatar Jul 10 '23 05:07 Jackman3005