<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Paweł Fraś</title>
    <description>The latest articles on DEV Community by Paweł Fraś (@pawelfras).</description>
    <link>https://dev.to/pawelfras</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F842250%2Fdb98162b-e708-4e49-a105-855d66f367ef.png</url>
      <title>DEV Community: Paweł Fraś</title>
      <link>https://dev.to/pawelfras</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pawelfras"/>
    <language>en</language>
    <item>
      <title>How overwriting NODE_OPTIONS can ruin your debugger in Visual Studio Code 😬</title>
      <dc:creator>Paweł Fraś</dc:creator>
      <pubDate>Mon, 18 Nov 2024 21:36:59 +0000</pubDate>
      <link>https://dev.to/pawelfras/how-overwriting-nodeoptions-can-ruin-your-debugger-in-visual-studio-code-kgo</link>
      <guid>https://dev.to/pawelfras/how-overwriting-nodeoptions-can-ruin-your-debugger-in-visual-studio-code-kgo</guid>
      <description>&lt;p&gt;When using Visual Studio Code daily, you may use &lt;code&gt;JavaScript Debug Terminal&lt;/code&gt; to debug your Node.js apps. If you do so, one day, you may struggle with the same issue I did some time ago.&lt;/p&gt;

&lt;h1&gt;
  
  
  Problem
&lt;/h1&gt;

&lt;p&gt;When I tried to run a Node.js application in the Javascript Debug Terminal, I noticed the debugger was not attaching to the process as it used to, regardless of whether breakpoints were set. &lt;/p&gt;

&lt;p&gt;The problem was related to the &lt;code&gt;NODE_OPTIONS&lt;/code&gt; I set in my terminal config file—not the fact that I added it, but the way I did it. It turned out that the debugger in VSC uses the special &lt;code&gt;NODE_OPTIONS&lt;/code&gt; environment variable, and overwriting it may lead to unexpected behaviors.&lt;/p&gt;

&lt;h1&gt;
  
  
  Solution
&lt;/h1&gt;

&lt;p&gt;Instead of overwriting the variable, you should extend it with your options. For example, the config file (&lt;code&gt;.zshrc&lt;/code&gt; in my case) might contain something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;&lt;span class="gd"&gt;- export NODE_OPTIONS="--some-other-option=here"
&lt;/span&gt;&lt;span class="gi"&gt;+ export NODE_OPTIONS="$NODE_OPTIONS --some-other-option=here"
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;sidenote:&lt;/strong&gt; This also applies to Cursor!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;source:&lt;/em&gt; &lt;a href="https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_how-can-i-set-nodeoptions" rel="noopener noreferrer"&gt;https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_how-can-i-set-nodeoptions&lt;/a&gt;&lt;/p&gt;

</description>
      <category>vscode</category>
      <category>node</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Angular 17: Overcoming SSR Challenges Of The New 'application' Builder 🔎</title>
      <dc:creator>Paweł Fraś</dc:creator>
      <pubDate>Tue, 12 Dec 2023 15:18:47 +0000</pubDate>
      <link>https://dev.to/pawelfras/angular-17-overcoming-ssr-challenges-with-the-new-application-builder-1i82</link>
      <guid>https://dev.to/pawelfras/angular-17-overcoming-ssr-challenges-with-the-new-application-builder-1i82</guid>
      <description>&lt;p&gt;The new Angular builder introduced in version 17, named &lt;a href="https://angular.io/guide/esbuild#using-the-application-builder" rel="noopener noreferrer"&gt;&lt;code&gt;application&lt;/code&gt;&lt;/a&gt;, consolidates separate builders for CRS, SSR, and SSG into a single entity. This becomes the default choice when creating a new application.&lt;/p&gt;

&lt;p&gt;Unfortunately, for applications with SSR, changes to the &lt;code&gt;server.ts&lt;/code&gt; file, which contains the server implementation, are not reflected when running &lt;code&gt;ng serve&lt;/code&gt;. This is cumbersome if you have some custom providers for your application specific for the server side. The same when comes to custom logic that depends on the request/response. In developer mode, these changes simply won't work.&lt;/p&gt;

&lt;p&gt;As a workaround, you can run &lt;code&gt;watch&lt;/code&gt; script for re-building your app on changes made in code and in the separate terminal, serve &lt;code&gt;server.mjs&lt;/code&gt; file with flag &lt;code&gt;--watch&lt;/code&gt; to be eager to changes in &lt;code&gt;dist&lt;/code&gt; folder. It can be achievable by small adjustment in &lt;code&gt;package.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight diff"&gt;&lt;code&gt;"watch": "ng build --watch --configuration=development",
&lt;span class="gd"&gt;- "serve:ssr:&amp;lt;your-app-name&amp;gt;": "node dist/&amp;lt;your-app-name&amp;gt;/server/server.mjs"
&lt;/span&gt;&lt;span class="gi"&gt;+ "serve:ssr:&amp;lt;your-app-name&amp;gt;": "node --watch dist/&amp;lt;your-app-name&amp;gt;/server/server.mjs"
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can try this suggestion or switch back to previous  builders: &lt;code&gt;browser&lt;/code&gt;, &lt;code&gt;server&lt;/code&gt; and &lt;code&gt;ssr-dev-server&lt;/code&gt; - they are still supported, but by choosing them you'll lost advantages of &lt;code&gt;esbuild&lt;/code&gt; .&lt;/p&gt;

&lt;p&gt;There is a &lt;a href="https://github.com/angular/angular-cli/issues/26323" rel="noopener noreferrer"&gt;GitHub issue&lt;/a&gt; in Angular-CLI repository describing mentioned issue. Don't hesitate to share your thoughts and leave there 👍 reaction - let Angular Core team know about our struggles :)&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>angular</category>
      <category>ssr</category>
    </item>
    <item>
      <title>Angular 17 ✨mapToCanActivate✨: Your Class Guards' Best Friend</title>
      <dc:creator>Paweł Fraś</dc:creator>
      <pubDate>Mon, 09 Oct 2023 15:58:06 +0000</pubDate>
      <link>https://dev.to/pawelfras/angular-17-maptocanactivate-your-class-guards-best-friend-519g</link>
      <guid>https://dev.to/pawelfras/angular-17-maptocanactivate-your-class-guards-best-friend-519g</guid>
      <description>&lt;p&gt;When you're updating your Angular app to version 16, you might notice that the &lt;code&gt;CanActivate&lt;/code&gt; interface is now deprecated. If you're thinking about changing your class guards to functional ones (or injecting the class in a wrapper function like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;() =&amp;gt; inject(MyGuard).canActivate()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;here's the deal - Angular 17 will probably come with a handy function called &lt;code&gt;mapToCanActivate&lt;/code&gt; that should let you stick with your class guards as they are. Let's check out this example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Injectable&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;providedIn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;root&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AdminGuard&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;canActivate&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;route&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Route&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;admin&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;canActivate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;mapToCanActivate&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="nx"&gt;AdminGuard&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The function accepts an array as an argument, allowing you to pass all your guards for a specific route without having to create a separate wrapper for each one.&lt;/p&gt;

&lt;p&gt;It seems like you can delay the refactoring for a bit and concentrate on your business requirements! 🙂&lt;/p&gt;

&lt;p&gt;&lt;em&gt;source: &lt;a href="https://next.angular.io/api/router/mapToCanActivate" rel="noopener noreferrer"&gt;https://next.angular.io/api/router/mapToCanActivate&lt;/a&gt;&lt;/em&gt; &lt;/p&gt;

</description>
      <category>angular</category>
      <category>guard</category>
      <category>programming</category>
      <category>routing</category>
    </item>
  </channel>
</rss>
