SourceMap read failed

1k Views Asked by At

I have a WinJS-UWP-Application, where I use TypeScript 2.5. I just upgraded from VS2015 to VS2017. When I want to debug my WinJS-UWP-Application the Breakpoints inside my .ts-Files are not noted, because the SourceMap isnt read properly. I didn't change any configuration of the project.
In the output I get this message:

SourceMap ms-appx://8d7814f6-7286-4475-8ed8-be1c489c2253/js/main.js.map read failed: The URI prefix is not recognized.. My CompilerOptions are:

"compilerOptions": {
    "target": "es5",
    "removeComments": true,
    "preserveConstEnums": true,
    "sourceMap": true
  }

The min and target version of the application are: 10.0.14393.0
Do I need to setup anything else in VS2017?

EDIT:
Steps to reproduce:

  1. Create a new UWP WinJS-App in VS 17 with Min and Target Version: 10.0.14393.0
  2. Remove the js\main.js
  3. Add a main.ts file in the js folder
  4. Create a tslib folder and insert the winjs.d.ts inside [For example from DefinetlyTyped]
  5. Add the following code inside the main.ts:

/// <reference path="../tslib/winjs.d.ts"/>

WinJS.UI.processAll().then(() => {
    let div: HTMLDivElement = document.createElement("div");
    let label: HTMLLabelElement = document.createElement("label");
    label.textContent = "Hello from the TypeScript-Side";
    div.appendChild(label);
    document.body.appendChild(div);
});

  1. Add a new tsconfig.json from the VS17 template.
  2. Start the app with the AnyCPU Configuration

Expected result: Inside the App you see the text:

Content goes here!
Hello from the TypeScript-Side

In the ouput you see these two messages:

'WWAHost.exe' (Script): Loaded 'Script Code (MSAppHost/3.0)'.
SourceMap ms-appx://32fb2864-03cf-4387-8a05-6c65a66c5a48/js/main.js.map read failed: The URI prefix is not recognized..

EDIT 2: The content of the main.js.map:

{
  "version": 3,
  "file": "main.js",
  "sourceRoot": "",
  "sources": [ "main.ts" ],
  "names": [],
  "mappings": "AAAA,2CAA2C;AAE3C,KAAK,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,IAAI,CAAC;IACvB,IAAI,GAAG,GAAmB,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACxD,IAAI,KAAK,GAAqB,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC9D,KAAK,CAAC,WAAW,GAAG,gCAAgC,CAAC;IACrD,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACvB,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC,CAAC,CAAC"
}

EDIT3:
TypescriptBuild-Settings:

TypeScript version: 2.5
Compile on save: Yes
Allow implicit 'any' types: Yes
Keep comments in JavaScript output: Yes
Generate declaration files: No
Generate source maps: Yes
Specify root directory of source maps: $(MSBuildProjectDirectory)
Specify root directory of TypeScript files: $(MSBuildProjectDirectory)
Emit on error: No

If I delete the tsconfig.json, the source maps are created correctly. But i need the tsconfig.json for a few other options, so deleting it is not an option!

1

There are 1 best solutions below

0
On

I found a workaround which fixes the problem for the moment. I don't know why this works, but if you add the line:

"mapRoot": "js/"

it works correctly.

This only works for the default directory setup!