istanbuljs/v8-to-istanbul

Support webpack:// in the `sourceRoot` option

Open

#133 ouverte le 15 févr. 2021

Voir sur GitHub
 (4 commentaires) (3 réactions) (0 assignés)JavaScript (40 forks)github user discovery
bughelp wanted

Métriques du dépôt

Stars
 (134 stars)
Métriques de merge PR
 (Métriques PR en attente)

Description

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!

Guide contributeur