v8-to-istanbul icon indicating copy to clipboard operation
v8-to-istanbul copied to clipboard

Support webpack:// in the `sourceRoot` option

Open tomardern opened this issue 3 years ago • 2 comments

Hi,

I'm having an issue with resolving to the correct file paths when the sourceRoot is webpack://.

Here is my investigation notes:

Example Sourcemap:

{
	"version":3,
	"sources":["./src/app/helloworld.js"],
	 ... 
	"sourceRoot":"webpack://"
}

Example:

let result = _resolveSource({
	sourcemap: {
   sourceRoot: "webpack://"
 }
}, "src/app/helloworld.js");

Should probably return src/app/helloworld.js but currently returns webpack:/src/app/helloworld.js

Maybe changing this line (https://github.com/istanbuljs/v8-to-istanbul/blob/master/lib/v8-to-istanbul.js#L87) from :

const sourceRoot = rawSourceMap.sourcemap.sourceRoot ? rawSourceMap.sourcemap.sourceRoot.replace('file://', '') : ''

to:

const sourceRoot = rawSourceMap.sourcemap.sourceRoot ? rawSourceMap.sourcemap.sourceRoot.replace(/(^file:\/\/)|(^webpack:\/\/)/, '') : ''

As a workaround, I can override the sourceRoot property to 'file://'.

Environment Information

  System:
    OS: macOS 10.15.1
    CPU: (4) x64 Intel(R) Core(TM) i5-5250U CPU @ 1.60GHz
    Memory: 281.22 MB / 8.00 GB
  Binaries:
    Node: 14.11.0 - ~/.nvm/versions/node/v14.11.0/bin/node
    npm: 6.14.8 - ~/.nvm/versions/node/v14.11.0/bin/npm
  npmPackages:
    nyc: ^15.1.0 => 15.1.0 
    typescript: ^4.1.3 => 4.1.3 
    v8-to-istanbul: ^7.1.0 => 7.1.0 

Thanks!

tomardern avatar Feb 15 '21 21:02 tomardern

@tomardern what's the expected behavior? should we just be dropping webpack:// in this case?

bcoe avatar Feb 17 '21 02:02 bcoe

@bcoe For my case, yes, I'm not an expert on sourcemaps, so I'm not totally sure.

tomardern avatar Feb 17 '21 09:02 tomardern