Skip to content

mapRoot/sourceRoot write sourcemaps using absolute local paths, not URIs #25587

@roblourens

Description

@roblourens

From microsoft/vscode#54026

//tsconfig.json

{
    "compilerOptions": {
        "sourceMap": true,
        "sourceRoot": "src/",
        "mapRoot": "build/"
    }
}

./src/hello.ts exists

Actual

I run tsc and get:

hello.js:

console.log("hello world!");
//# sourceMappingURL=/Users/roblou/Downloads/tsTest/build/hello.js.map

hello.map.js:

{"version":3,"file":"hello.js","sourceRoot":"/Users/roblou/Downloads/tsTest/src/","sources":["hello.ts"], ...

Expected

This stuff is not clearly spec'd but my understanding is that sourceMappingURL and sourceRoot should be URIs or relative paths, not local absolute paths. In a browser, a path starting with / should be interpreted as relative to the webserver root.

In Node, Chrome Devtools handles this on Mac, but on Windows, it can't handle a sourceMappingUrl or sourceRoot as a windows-style absolute path. That is what convinces me that this is worth fixing on TS's end.

In vscode, I plan to try to support this scenario somehow, since it previously worked.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions