Skip to content

Prefixing "file:///" to Windows absolute paths causes "Unknown source file" #63

@JoshMarler

Description

@JoshMarler

Hi @harold-b !

I wonder if you could help me out. I'm hitting some problems setting breakpoints on Windows in my project. Everything is working great on Mac/Linux but the following code is causing issues when mapping source files with absolute paths/drive letters:

From sourceMaps.ts in SouceMap constructor

  for (let i = 0; i < sm.sources.length; i++) {
            sm.sources[i] = this.toUrl(sm.sources[i]);
        }

I'm hitting "Unknown source file" issues as a result of finding no matches in DukDebugger.ts scanDir.

This is happening because of the "file:///" prefix added to source paths containing drive letters in the toUrl function. The below comparison fails as a result:

DukDebugger.ts:2121

if (this.normPath(Path.resolve(this._outDir, candidateFile)) === path)

In my case at DukDebuffer.ts:2121 the debugger shows:

candidateFile="file:///d:/Development/Proj/Software/External/Libraries/blueprint/examples/GainPlugin/Source/jsui/src/Slider.js"

path="d:\Development\Proj\Software\External\Libraries\blueprint\examples\GainPlugin\Source\jsui\src\Slider.js"

Is this prefix to be expected here? Currently this comparison will always fail.

My webpack config uses the following source-map configuration:

 devtoolModuleFilenameTemplate: info =>
    `webpack:///${info.absoluteResourcePath.replace(/\\/g, '/')}`

In my outDir I have a single main.js and a single main.js.map file. Source paths in my map appear as below:

"webpack:///D:/Development/Proj/Software/External/Libraries/blueprint/examples/GainPlugin/Source/jsui/src/Slider.js"

My workspaceFolder/root is at D:/Development/Proj/Software/External/Libraries/blueprint/examples/GainPlugin/Source/jsui

Launch.json is as follows:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Attach (duk)",
            "type": "duk",
            "request": "attach",
            "address": "localhost",
            "port": 9091,
            "localRoot": "${workspaceFolder}",
            "sourceMaps": true,
            "outDir": "${workspaceFolder}/build/js",
            "stopOnEntry": true,
            "debugLog": true
        }
    ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions