-
Notifications
You must be signed in to change notification settings - Fork 99
sourcemap failing inside vscode but working inside chrome devtools #544
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.mapfile.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
Chrome dev tools pauses in file.js
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.mapasset/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
chrome devtools pauses in file.js
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); |



