TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

Visual Studio Edit & Continue: missing sourcemap reference in .js file if editing while debugging

Open AGiorgetti opened this issue 11 years ago • 8 comments

In my web application project I have the following flags enabled: Web - 'Enable Edit & Continue. TypeScript - Compile on Save. TypeScript Generate Source maps.

I can run and debug a TypeScript file correctly, but if - while still debugging - I edit a TypeScript file and save it, I loose the ability to see the breakpoints.

The .js file will be updated with the modifications I made to the TypeScript (the new js is correctly generated), however the reference to the source map is not present, so when I reload the page in the browser I cannot debug it properly.

I need to stop the debugging session and run it again, this time the generated .js files will contain the reference to the TypeScript files again.

Steps to reproduce the issue:

  • add a TypeScript file, set a breakpoint
  • compile and run, the brekpoint will be hit
  • DO NOT stop the debugging session, edit the TypeScript file and save it
  • the .js file will be updated, but no //# sourceMappingURL has been added to it
  • refresh the page, debugging not working anymore.

Workaround: manually recompile the .ts file using tsc.

AGiorgetti avatar Sep 28 '15 11:09 AGiorgetti

Sounds like your using IE. We had this problem and to get around it you either have to clear your IE temp files (ctrl+shift+delete) and make sure "Temporary Internet File and website File" is selected and then refresh the page. Or you can change your IE settings to always look for newer versions of a page which will force IE to check for newer JS files if they are available and then a refresh of the page.

capture

djarekg avatar Sep 28 '15 19:09 djarekg

@AGiorgetti, just to confirm, when saving the file (regardless if you are debugging or not) do you see the //# sourceMappingURL generated or not?

if not, can you share the project file?

mhegazy avatar Sep 28 '15 19:09 mhegazy

@mhegazy good catch, if I edit the file (even when not debugging) and save it, I cannot see the //# sourceMappingUrl. If I run the application with the debugger (F5) the .ts files are recompiled and the //# sourceMappingUrl is there.

I have an edited version of my project file in which I stripped out all the references and file list, but GitHub is not allowing me to attach it here (neither if I convert it to plain .txt); It's something like 100+ lines of xml, do you want me to post it here as a comment?

AGiorgetti avatar Sep 29 '15 08:09 AGiorgetti

I think I've found the problem, double checking my web.csproj file I've found that I was missing some settings related to TypeScript compilation:

<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
    <TypeScriptTarget>ES5</TypeScriptTarget>
    <TypeScriptJSXEmit>None</TypeScriptJSXEmit>
    <TypeScriptCompileOnSaveEnabled>True</TypeScriptCompileOnSaveEnabled>
    <TypeScriptNoImplicitAny>False</TypeScriptNoImplicitAny>
    <TypeScriptModuleKind>None</TypeScriptModuleKind>
    <TypeScriptRemoveComments>False</TypeScriptRemoveComments>
    <TypeScriptOutFile />
    <TypeScriptOutDir />
    <TypeScriptGeneratesDeclarations>False</TypeScriptGeneratesDeclarations>
    <TypeScriptNoEmitOnError>True</TypeScriptNoEmitOnError>
    <TypeScriptSourceMap>True</TypeScriptSourceMap>
    <TypeScriptMapRoot />
    <TypeScriptSourceRoot />
  </PropertyGroup>

changing some settings on the TypeScript Build tab in the project properties added these lines to the project file, honestly I have no clue on why they were not there given the fact that I changed these settings multiple times in the past.

Adding these solved my problem.

AGiorgetti avatar Sep 29 '15 08:09 AGiorgetti

glad we got to the bottom of this issue. could be caused by #4077.

mhegazy avatar Sep 29 '15 16:09 mhegazy

Thank you @AGiorgetti - your fix helped me and our team get .ts debugging to work consistently!

JonKragh avatar Feb 10 '16 17:02 JonKragh

This solved my problem as well. My symptoms: If I edited and saved a .ts file, the corresponding .js file was missing the //# sourcemappingURL comment, but if I performed a Build, the comment would be present.

I applied the same workaround as @AGiorgetti : toggled a setting on the typescript build tab. That caused additional content to be written to my .csproj file.

If it helps: I started the typescript work in a project that I had created as an Empty ASP.Net project.
When I started, I was using whatever version of typescript comes with VS 2015 Pro / Update 1. I currently have Typescript 1.8.4 installed (installed via Tools | Extensions and Updates)

jsmarsch avatar May 04 '16 20:05 jsmarsch

Thank you! Toggling a setting on our Typescript Build tab resolved the issue for me too.

Andrew36 avatar Sep 13 '16 23:09 Andrew36