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

source maps do no respect sourceRoot #31

Closed
Toxicable opened this issue Jun 15, 2019 · 6 comments
Closed

source maps do no respect sourceRoot #31

Toxicable opened this issue Jun 15, 2019 · 6 comments

Comments

@Toxicable
Copy link
Contributor

Toxicable commented Jun 15, 2019

Under the build tool I am using .ts files do not live next to .js files, therefore we use sourceRoot to point the source maps at the correct source dir.

This line here: https://github.com/istanbuljs/v8-to-istanbul/blob/master/lib/v8-to-istanbul.js#L40

this.path = relativeTo(rawSourceMap.sourcemap.sources[0], this.path)

fails to resolve that logic, we've had to modify it to be

this.path = join(rawSourceMap.sourcemap.sourceRoot, rawSourceMap.sourcemap.sources[0])

for it to be able to resolve sourceRoot's correctly

@bcoe
Copy link
Member

bcoe commented Jun 17, 2019

@Toxicable what is sourceRoot by default? wondering if we're safe to always use the logic you shared above, or whether we should make it conditional on the value of sourceRoot being set?

@bcoe
Copy link
Member

bcoe commented Jun 17, 2019

will happily take a patch for this 😄

@Toxicable
Copy link
Contributor Author

@bcoe usually it's empty string by default.
Will look at how we can combine that logic, but otherwise a conditional should work fine.
I just want to make sure the changes here actually conform to how source maps are meant to be read

Toxicable pushed a commit to Toxicable/v8-to-istanbul that referenced this issue Jun 21, 2019
Toxicable pushed a commit to Toxicable/v8-to-istanbul that referenced this issue Jun 21, 2019
@bcoe
Copy link
Member

bcoe commented Jun 23, 2019

we need to also make sure that relative paths populated in sourceRoot take into account process.cwd() when determining the final path, see: #39

To add an additional pain point, it seems that some sourceMap instrumenters sometimes add the filename in sourceRoot, so we need to be mindful to strip this out when determining the relative path.

I think for a path forward:

  • lib/pathutils.js should be updated to handle these edge-cases, rather than using join directly (as is currently the case).
  • the c8 test suite should be run with the updated version of v8-to-istanbul before releasing it.

@bcoe
Copy link
Member

bcoe commented Nov 30, 2019

@Toxicable mind checking if this is fixed in the latest release? I did some reworking around how we handled path resolution, in an effort to make it closer to Source Map V3.

@Toxicable
Copy link
Contributor Author

Whops, sorry for not checking back in here sooner.
Looks like it handles sourceRoot fine now, thanks!

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

No branches or pull requests

2 participants