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

Support webpack:// in the sourceRoot option #133

Open
tomardern opened this issue Feb 15, 2021 · 2 comments
Open

Support webpack:// in the sourceRoot option #133

tomardern opened this issue Feb 15, 2021 · 2 comments
Labels

Comments

@tomardern
Copy link

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!

@bcoe bcoe added the bug label Feb 17, 2021
@bcoe
Copy link
Member

bcoe commented Feb 17, 2021

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

@tomardern
Copy link
Author

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

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

No branches or pull requests

2 participants