microsoft / microsoft/TypeScript

Add an option to force source maps to use absolute paths?

Open
#26,531 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

In Discussion Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

Previous related issue: https://github.com/Microsoft/TypeScript/issues/23180

It seems VS2017 is incompatible with relative paths, when debugging a UWP app now tries to load source maps from the app URI and the host does not support it.

'WWAHost.exe' (Script): Loaded 'Script Code (MSAppHost/3.0)'. 
SourceMap ms-appx://6b826582-e42b-45b9-b4e6-dd210285d94b/js/require-config.js.map read failed: The URI prefix is not recognized..

Hard-coding the full path in tsconfig.json is not a good idea here, I hope we have an option to behave as 2.9.2 so that we can get the auto-resolved full path.

Edit: My tsconfig.json that works in TS2.9 but not in TS3.0:

{
  "compilerOptions": {
    "strict": true,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": true,
    "target": "es2017",
    "outDir": "js/",
    "mapRoot": "js/",
    "sourceRoot": "sources/",
    "emitBOM": true,
    "module": "amd",
    "moduleResolution": "node"
  },
  "exclude": [
    "node_modules",
    "wwwroot"
  ]
}

My failed trial to fix this: (removed mapRoot and changed sourceRoot)

{
  "compilerOptions": {
    "strict": true,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": true,
    "target": "es2017",
    "outDir": "js/",
    "sourceRoot": "../sources/",
    "emitBOM": true,
    "module": "amd",
    "moduleResolution": "node"
  },
  "exclude": [
    "node_modules",
    "wwwroot"
  ]
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the related issue and the reported tsconfig examples, then trace how TypeScript emits source maps and resolves mapRoot and sourceRoot. Done means an option can reproduce the TypeScript 2.9.2 absolute-path behavior for the reported UWP debugging case, with coverage for the relevant source-map output.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
compilers, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.