aws / aws-sam-cli

CLI tool to build, test, debug, and deploy Serverless applications using AWS SAM
https://aws.amazon.com/serverless/sam/
Apache License 2.0
6.51k stars 1.17k forks source link

VSCode Debug SourceMap Location #3830

Open JumaBok opened 2 years ago

JumaBok commented 2 years ago

Describe your idea/feature/enhancement

I'm not sure if this already exists, but I can't see it readily documented. I'd like to be able to debug locally in VSCode using a launch configuration, and using the new typescript beta-features. While esbuild is emitting sourcemaps, it's dropping those into the .aws-sam/build/** folders and therefore the debug cannot locate them relative to the source code.

Is there a way for me to specify an alternative location for the sourcemaps to be emitted, or can I tell VSCode where to look? I've tried to add resolveSourceMapLocations but it doesn't recognise the option under the configuration type of aws-sam.

Thanks!

moelasmar commented 2 years ago

Thanks @JumaBok for raising this feature request.

orrenbizz commented 1 year ago

Is there a workaround for this?

ffMathy commented 1 year ago

We have this issue too.

dgokcin commented 10 months ago

Having the same issue.

Ugikie commented 6 months ago

Would love to know a solution for this as well

eternal-eager-beaver commented 5 months ago

Having the same issue

dgokcin commented 5 months ago

@eternal-eager-beaver @Ugikie @ffMathy @orrenbizz @JumaBok I have spent countless hours debugging why debugging was not working when I first faced this issue and wanted to update this issue with my workaround. It is a little bit ugly/fragile but it works.

I worked around this limitations using some scripting magic in vscodeslaunch.json & tasks.json and slightly modifying the tsconfig.json and enabling the sourcemap option in the SAM template.

.vscode/launch.json

.gitignore

tasks.json in .vscode/

tsconfig.json

template.yaml