A Cordova projects' typescript source is kept outside of the www folder. The generated map file points to source it cannot access. How do I set up a post-build event to copy the typescript source in the www folder and update the generated mapping file to enable the debugger to load the correct typescript source file when a breakpoint is hit?
Figured out the first requirement, copying the typescript source files into the www folder. Edit the .jsproj project file and add the following:
<ItemGroup>
<TypeScriptSourceFiles Include="$(ProjectDir)scripts\**\*.ts"></TypeScriptSourceFiles>
</ItemGroup>
<Target Name="AfterBuild">
<Copy SourceFiles="@(TypeScriptSourceFiles)" DestinationFiles="@(TypeScriptSourceFiles->'$(ProjectDir)www\scripts\ts\%(RecursiveDir)%(Filename)%(Extension)')"></Copy>
</Target>
Now do I just need to modify the .js.map file and update the sourceRoot attribute?
Any ideas?
Sorry for your trouble. We know that we have some issues with source maps and Typescript, depending on the scenario you are debugging. The best way to fix this for now is to add the following setting to your tsconfig.json file:
"inlineSources": true
This will embed your typescript sources in the source map files so that you can debug them in all scenarios.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With