Open dmail opened 5 years ago
I forgot to tell you how I execute the files:
For chrome I open the following html file.
<script src="./file.es5.js"></script>
For vscode I uses the following launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch with node",
"type": "node",
"request": "launch",
"program": "${file}",
"sourceMaps": true,
"trace": true,
},
]
}
@dmail is your sourceMappingURL
correct?
You put //# sourceMappingURL=__asset__/file.es5.js.map
but your source map file is in asset
folder.
I think it was a mistake when I wrote my comment, I forgot to put __asset__
and wrote asset
instead.
But I remember testing it with actual files and chrome was ok so I assume I had no such mistake in the actual files I used to reproduce.
Have you tried to reproduce? I will try on my side when feeling more energy to do so.
It looks like vscode fallbaks on the script dirname but should fallback on the sourcemap dirname.
Any thought regarding this suggestion ?
I think it was a mistake when I wrote my comment, I forgot to put
__asset__
and wroteasset
instead. But I remember testing it with actual files and chrome was ok so I assume I had no such mistake in the actual files I used to reproduce.Have you tried to reproduce? I will try on my side when feeling more energy to do so.
I thought I had the same issue in my project so I created a simple web app with webpack
but I couldn't replicate the problem - the debugger works fine when I put the source map in a different folder from the js file.
Not sure why it doesn't work for the other app I have though.
I thought I had the same issue in my project so I created a simple web app with
webpack
but I couldn't replicate the problem - the debugger works fine when I put the source map in a different folder from the js file.Not sure why it doesn't work for the other app I have though.
Turns out I had some wrong webpack
config for sourcemap path in my project, resulting in wrong sourceMappingURL
.
From my side, VSCode debugger has no problem when we put source map in a different folder from the JS file.
I see thanks, I try to repro today and let you know if I can still reproduce
Still reproductible. VsCode still fails to find the sourcemap file while chrome devtools are fine.
(I have updated my first comment with the correct filenames in case someone wants to reproduce).
How did you generate the source map files?
In my case it's "sources":["webpack:///./src/index.js"]
, it's different format from yours:
"sources": [
"../file.js"
],
I have generated them programatically using babel.
Webpack seems to use a special scheme (webpack://) that vscode seems to understand and resolve differently than relative path
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
file.es5.js
file.es5.js.map
Vscode pauses in
file.js
Chrome dev tools pauses in
file.js
File structure failing in vscode
file.js
file.es5.js
asset/file.es5.js.map
vscode pauses inside
file.es5.js
chrome devtools pauses in
file.js
Additional info
When I put "
trace": true
insidelaunch.json
one log draws my attention:SourceMap: no sourceRoot specified, using script dirname
I think it corresponds to the following line in getComputedSourceRoot https://github.com/microsoft/vscode-chrome-debug-core/blob/87d2c194179033e38d68308027c1d1dbbc43c454/src/sourceMaps/sourceMapUtils.ts#L53
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.
https://github.com/microsoft/vscode-chrome-debug-core/blob/87d2c194179033e38d68308027c1d1dbbc43c454/src/sourceMaps/sourceMapUtils.ts#L52