<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[Rolf Nebhuth - DEVELOPERS.DE]]></title><description><![CDATA[Software Development Blog with focus on .NET, Windows, Microsoft Azure powered by daenet]]></description><link>https://developers.de/</link><image><url>https://developers.de/favicon.png</url><title>Rolf Nebhuth - DEVELOPERS.DE</title><link>https://developers.de/</link></image><generator>Ghost 1.21</generator><lastBuildDate>Thu, 09 Apr 2026 14:51:44 GMT</lastBuildDate><atom:link href="https://developers.de/author/rnebhuth/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[Debugging Angular Projects and Libraries]]></title><description><![CDATA[<div class="kg-card-markdown"><p>Angular 6 has a the new feature to create multiple projects in one workspace with applications and libraries is one workspace. But the problem is the debugging of these projects in visual code.</p>
<h2 id="preperation">Preperation</h2>
<p>In my example I create one root application <em>demo-debug-app</em>, a library <em>demo-debug-lib</em> and a sub application</p></div>]]></description><link>https://developers.de/2018/09/05/angluar-library-debugging/</link><guid isPermaLink="false">5b8fb52025f0d502ac45b84e</guid><category><![CDATA[angular]]></category><category><![CDATA[debugging]]></category><dc:creator><![CDATA[Rolf Nebhuth]]></dc:creator><pubDate>Wed, 05 Sep 2018 13:38:04 GMT</pubDate><content:encoded><![CDATA[<div class="kg-card-markdown"><p>Angular 6 has a the new feature to create multiple projects in one workspace with applications and libraries is one workspace. But the problem is the debugging of these projects in visual code.</p>
<h2 id="preperation">Preperation</h2>
<p>In my example I create one root application <em>demo-debug-app</em>, a library <em>demo-debug-lib</em> and a sub application <em>demo-debug-app2</em>.</p>
<pre><code class="language-cmd">ng new demo-debug-app
ng generate library demo-debug-lib --prefix=lib
ng generate application demo-debug-app2
</code></pre>
<p>As debugger I use Visual Studio Code and the extension <em>Debugger for Chrome</em>.</p>
<h2 id="rootapplicationdebugging">Root Application Debugging</h2>
<p>To debug the root application you start the application with:</p>
<pre><code class="language-cmd">ng serve 
</code></pre>
<p>and the start the debugger with the configuration in the launch.json</p>
<pre><code class="language-javascript">{
    &quot;type&quot;: &quot;chrome&quot;,
    &quot;request&quot;: &quot;launch&quot;,
    &quot;name&quot;: &quot;Launch demo-debug-app&quot;,
    &quot;url&quot;: &quot;http://localhost:4200&quot;,
    &quot;webRoot&quot;: &quot;${workspaceFolder}&quot;
}
</code></pre>
<h2 id="projectapplicationdebugging">Project Application Debugging</h2>
<p>If you want to debug an application in the projects folder. You first need to start this application with the addition parameter project</p>
<pre><code class="language-cmd">ng serve demo-debug-app2 
</code></pre>
<p>But if you try to set a breakpoint in this application the breakpoint did not match.<br>
<img src="https://developersde.blob.core.windows.net/usercontent/2018/9/5129_Debugging1.PNG" alt="5129_Debugging1"><br>
You need to update or create a new debugging configuration in <em>launch.json</em> whith the a correct webRoot, so the debugger knows where to find the sourcen.</p>
<pre><code class="language-javascript">{
    &quot;type&quot;: &quot;chrome&quot;,
    &quot;request&quot;: &quot;launch&quot;,
    &quot;name&quot;: &quot;Launch demo-debug-app2&quot;,
    &quot;url&quot;: &quot;http://localhost:4200&quot;,
    &quot;webRoot&quot;: &quot;${workspaceFolder}/projects/demo-debug-app2&quot;
}
</code></pre>
<h2 id="debugginglibraries">Debugging Libraries</h2>
<p>For a library you need a host application this could be a test application or the application whitch needs this library, but in both cases you cannot start the application direcly, you need to start the host application, but then you cannot debug into the library.<br>
<img src="https://developersde.blob.core.windows.net/usercontent/2018/9/51235_Debugging2.PNG" alt="51235_Debugging2"><br>
The problem is that this library is handeled like any other library you use and is packaged as part of the vendor.js file, normaly for this file no map files are published when you use ng serve. In the Chrome Debugger only the javascript files exists, and can be debugged.<br>
<img src="https://developersde.blob.core.windows.net/usercontent/2018/9/51249_Debugging3.PNG" alt="51249_Debugging3"><br>
But with a new feature in Angular 6.1 <em>--vendorSourceMap</em> the ng serve can publish all vendor map files, too.</p>
<pre><code class="language-cmd">ng serve --vendorSourceMap
</code></pre>
<p>And now Google Chrome shows the type scripts files<br>
<img src="https://developersde.blob.core.windows.net/usercontent/2018/9/51252_Debugging4.PNG" alt="51252_Debugging4"></p>
<p>But the the Visual Studio Code debugger did not work, because it can not map the &quot;ng://demo-debug-lib/lib&quot; folder to any source code. To do this we need to update the <em>launch.json</em> file and add the the <em>sourceMapPathOverrides</em> property with the mapping where to find the source code.</p>
<pre><code class="language-javascript">{
    &quot;type&quot;: &quot;chrome&quot;,
    &quot;request&quot;: &quot;launch&quot;,
    &quot;name&quot;: &quot;Launch demo-debug-app&quot;,
    &quot;url&quot;: &quot;http://localhost:4200&quot;,
    &quot;webRoot&quot;: &quot;${workspaceFolder}&quot;,
    &quot;sourceMapPathOverrides&quot;: {
        &quot;webpack:///ng://demo-debug-lib/lib/*&quot;: &quot;${workspaceFolder}/projects/src/lib/*&quot;
    },
},
</code></pre>
<p>And now it works fine.<br>
<img src="https://developersde.blob.core.windows.net/usercontent/2018/9/51313_Debugging5.PNG" alt="51313_Debugging5"></p>
<p>For project application project you need to do the same but start the server with the project name and add the sourceMapPathOverrides</p>
<pre><code class="language-cmd">ng serve demo-debug-app2 --vendorSourceMap
</code></pre>
<pre><code class="language-javascript">{
    &quot;type&quot;: &quot;chrome&quot;,
    &quot;request&quot;: &quot;launch&quot;,
    &quot;name&quot;: &quot;Launch demo-debug-app2&quot;,
    &quot;url&quot;: &quot;http://localhost:4200&quot;,
    &quot;webRoot&quot;: &quot;${workspaceFolder}/projects/demo-debug-app2&quot;,
    &quot;sourceMapPathOverrides&quot;: {
        &quot;webpack:///ng://demo-debug-lib/lib/*&quot;: &quot;${workspaceFolder}/projects/src/lib/*&quot;
    },
}
</code></pre>
</div>]]></content:encoded></item></channel></rss>