Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access inline sourcemap produced using Transform API in TransformResult #650

Closed
airhorns opened this issue Jan 6, 2021 · 1 comment
Closed

Comments

@airhorns
Copy link

airhorns commented Jan 6, 2021

It'd be handy to be able to access a sourcemap that's generated and stored inline in a .transform'd file from the TransformResult as well. Right now, if sourcemap: "inline" is set, there's no sourcemap in the returned TransformResult. If it's not a major performance hit, it'd be awesome to just have access to the map when using sourcemaps: "inline" by default, but if not, a "both" option a la babel might make sense too.

My use case is this: when using esbuild in a development setting, sometimes there are multiple downstream consumers, each expecting to find sourcemaps in their own strange way. In my case, I'm using esbuild-jest to transform TypeScript files for Jest, and then using VSCode to edit said sourcefiles. VSCode accesses sourcemaps on disk or via the inline data: URLs, so if I want to debug my code with breakpoints from the editor, I want to pass sourcemaps: "inline" to give VSCode the sourcemap. But, Jest also consumes sourcemaps in order to provide nice rich error messages that show the source around an assertion error, and it uses the sourcemap to do that. Its API expects to be passed the sourcemap and the code from anything transforming code (like esbuild-jest), so I want to pass sourcemaps: true to esbuild to get a sourcemap to hand to Jest. I can teach one of the things in the chain of tools to find the sourcemap in one place and move it to the other, but it'd be handy if esbuild produced it in both places since it will be the most performant thing at doing that.

@evanw
Copy link
Owner

evanw commented Jan 7, 2021

This has been added as a --sourcemap=both option in version 0.8.31.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants