VS Code sourceMapPathOverrides

*爱你&永不变心* 提交于 2019-12-07 10:29:19

问题


I have an Aurelia TypeScript project where my compiled JavaScript files go into the .../wwwroot subfolder and the original typescript files are located in .../src. I am trying to use the Chrome Debugger extension in VS code but breakpoints are not hit and when I turn on diagnosticLogging in launch.json the the mapped source is incorrect: It look in .../wwwroot/src/file.ts instead of .../src/file.ts.

I tried to solve this with sourceMapPathOverrides but with no success. It seems I cannot match my sourceRoot.

I tried this:

"webRoot": "${workspaceRoot}/wwwroot",
"sourceMapPathOverrides": {
    "/src/*": "${workspaceRoot}/src/*"     
},

This is the debug console output for finding the source to login.js:

›SourceMaps.loadSourceMapContents: Reading local sourcemap file from ...\wwwroot\dist\login.js.map
›SourceMap: creating for ...\wwwroot\dist\login.js
›SourceMap: sourceRoot: /src
›SourceMap: sources: ["login.ts"]
›SourceMap: webRoot: .../wwwroot
›SourceMap: resolved sourceRoot /src -> ...\wwwroot\src
›SourceMaps.scriptParsed: ...\wwwroot\dist\login.js was just loaded and has mapped sources: ["...\\wwwroot\\src\\login.ts"]

Note: The three dots ... stand for my removed path on disk to the project root.

How can I use sourceMapPathOverrides to have it lookup login.ts in .../src/?


Because of suggestion I tried to set webRoot to the workspaceRoot like this:

"webRoot": "${workspaceRoot}"

This way the mapped source file is correct and breakpoints work. But the log also says:

Paths.scriptParsed: could not resolve http://localhost:9000/dist/login.js to a file under webRoot: c:\Users\username\Source\Repos\myproject. It may be external or served directly from the server's memory (and that's OK).

The folder served by the webserver is the wwwroot subfolder in my project so from the description setting webRoot to workspaceRoot is wrong. What other problems might occur or is the suggestion of @Steffen valid?

To make sure, this is the folder structure

/                    (project/source/git root)
/src                 (contains typescript, html files, is sourceRoot in source mapping)
/src/login.ts
/wwwroot             (root folder served by dev web server, should be webRoot shouldn't it?)
/wwwroot/index.html  (file opened by http://localhost:9000/ which starts Aurelia bootstrapper)
/wwwroot/config.js   (SystemJS config, maps * to dist/* )
/wwwroot/dist        (folder containing compiled application files)
/wwwroot/dist/login.js

来源:https://stackoverflow.com/questions/38846336/vs-code-sourcemappathoverrides

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!