Skip to content
This repository has been archived by the owner on Oct 2, 2021. It is now read-only.

sourcemap failing inside vscode but working inside chrome devtoolsΒ #544

Open
@dmail

Description

Depending where the sourcemap file is, vscode fails to locate the source while chrome dev tools has no problem to find it.

If you want to reproduce you can try with the first file structure where both vscode and chrome devtools are working.
Then compare with the second file structure that works only in chrome devtools.

File structure working in both

file.js

const value = true

debugger

console.log(value)

file.es5.js

var value = true;

debugger;

console.log(value);
//# sourceMappingURL=file.es5.js.map

file.es5.js.map

{
  "version": 3,
  "sources": [
    "./file.js"
  ],
  "names": [
    "value",
    "console",
    "log"
  ],
  "mappings": "AAAA,IAAMA,QAAQ,IAAd;;AAEA;;AAEAC,QAAQC,GAAR,CAAYF,KAAZ",
  "file": "file.js"
}

Vscode pauses in file.js

image

Chrome dev tools pauses in file.js

image

File structure failing in vscode

file.js

const value = true

debugger

console.log(value)

file.es5.js

var value = true;

debugger;

console.log(value);
//# sourceMappingURL=__asset__/file.es5.js.map

asset/file.es5.js.map

{
  "version": 3,
  "sources": [
    "../file.js"
  ],
  "names": [
    "value",
    "console",
    "log"
  ],
  "mappings": "AAAA,IAAMA,QAAQ,IAAd;;AAEA;;AAEAC,QAAQC,GAAR,CAAYF,KAAZ",
  "file": "file.js"
}

vscode pauses inside file.es5.js

image

chrome devtools pauses in file.js

image

Additional info

When I put "trace": true inside launch.json one log draws my attention:

SourceMap: no sourceRoot specified, using script dirname

I think it corresponds to the following line in getComputedSourceRoot

logger.log(`SourceMap: no sourceRoot specified, using script dirname: ${absSourceRoot}`);

It looks like vscode fallbaks on the script dirname but should fallback on the sourcemap dirname. Otherwise when sourcemap file and script file are not in the same directory sourceroot is wrong.

absSourceRoot = path.dirname(generatedPath);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions