<?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:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[reality-loop - Medium]]></title>
        <description><![CDATA[Writings about interesting and funny topics in software development and the IT industry in general. - Medium]]></description>
        <link>https://medium.jonasbandi.net?source=rss----c6f8509685f---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>reality-loop - Medium</title>
            <link>https://medium.jonasbandi.net?source=rss----c6f8509685f---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 11 Mar 2026 12:08:40 GMT</lastBuildDate>
        <atom:link href="https://medium.jonasbandi.net/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Frontend Monoliths: Run if you can! — Voxxed Day Zuerich, 2019]]></title>
            <link>https://medium.jonasbandi.net/frontend-monoliths-run-if-you-can-voxxed-day-zuerich-2019-d8d714ff361a?source=rss----c6f8509685f---4</link>
            <guid isPermaLink="false">https://medium.com/p/d8d714ff361a</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[front-end-development]]></category>
            <dc:creator><![CDATA[Jonas Bandi]]></dc:creator>
            <pubDate>Wed, 20 Mar 2019 22:34:40 GMT</pubDate>
            <atom:updated>2019-03-26T21:14:57.134Z</atom:updated>
            <content:encoded><![CDATA[<h3>Frontend Monoliths: Run if you can! — Voxxed Day Zuerich, 2019</h3><p>This week <a href="https://twitter.com/danielwiehl">Dani Wiehl</a> and I were giving a presentation about <a href="https://micro-frontends.org/">Microfrontends</a> and the <a href="https://github.com/SchweizerischeBundesbahnen/scion-workbench">SCION Workbench</a> at <a href="https://voxxeddays.com/zurich/">Voxxed Day Zuerich</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nqE6OVNjeyRmUZVPyDLIPQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WAVFxTuXkqhOs-K9f0SCcA.jpeg" /></figure><p>The slides are <a href="https://www.slideshare.net/JonasBandi/frontend-monoliths-run-if-you-can-137391467">available on Slideshare</a>:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.slideshare.net%2Fslideshow%2Fembed_code%2Fkey%2FvVkDKf4z7bWZds&amp;url=https%3A%2F%2Fwww.slideshare.net%2FJonasBandi%2Ffrontend-monoliths-run-if-you-can-137391467&amp;image=https%3A%2F%2Fcdn.slidesharecdn.com%2Fss_thumbnails%2F20190319voxxed-190320223151-thumbnail-4.jpg%3Fcb%3D1553121155&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=slideshare" width="600" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/02215f2755c9e3c7d471742c0e3b91a8/href">https://medium.com/media/02215f2755c9e3c7d471742c0e3b91a8/href</a></iframe><p>The recorded presentation is <a href="https://www.youtube.com/watch?v=9SG2lI5_t1Q&amp;index=12&amp;list=PLRsbF2sD7JVrRCnhTo8DoN_9JAMpZThtW">available on YouTube</a>:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fvideoseries%3Flist%3DPLRsbF2sD7JVrRCnhTo8DoN_9JAMpZThtW&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D9SG2lI5_t1Q&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F9SG2lI5_t1Q%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/3d4046669ed4203956a3998b154dba8b/href">https://medium.com/media/3d4046669ed4203956a3998b154dba8b/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8d714ff361a" width="1" height="1" alt=""><hr><p><a href="https://medium.jonasbandi.net/frontend-monoliths-run-if-you-can-voxxed-day-zuerich-2019-d8d714ff361a">Frontend Monoliths: Run if you can! — Voxxed Day Zuerich, 2019</a> was originally published in <a href="https://medium.jonasbandi.net">reality-loop</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Most Simple State Management Solution for Angular]]></title>
            <link>https://medium.jonasbandi.net/the-most-simple-state-management-solution-for-angular-1d32706e6f1c?source=rss----c6f8509685f---4</link>
            <guid isPermaLink="false">https://medium.com/p/1d32706e6f1c</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Jonas Bandi]]></dc:creator>
            <pubDate>Tue, 12 Mar 2019 22:33:54 GMT</pubDate>
            <atom:updated>2019-03-12T22:26:47.964Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*IPF3BXy8yWXHkgAz7t094w.png" /></figure><blockquote><a href="https://www.youtube.com/watch?v=hoZervGXQyI">Es könnt’ alles so einfach sein, isses aber nicht .</a></blockquote><p>TLDR: Find the <a href="https://github.com/jbandi/ng-subject-vs-getter">demo code here</a>.</p><p>State-management in Angular can be a complicated topic. There is an abundance of 3rd party state management libraries: <a href="https://ngrx.io/">NgRx</a>, <a href="https://ngxs.gitbook.io/ngxs">ngxs</a>, <a href="https://netbasal.gitbook.io/akita/">Akita</a> … to only mention the most popular ones. These libraries are opinionated and have heavy implications on the architecture of an application. They imply concepts for separation of concern and immutability that are not easy to understand and implement.</p><p>I have seen a great share of over-engineered Angular applications, where zealous engineers implemented state management that looks like a fully automated Tesla Gigafactory … for simple “forms over data” applications.</p><p>As a consequence I regularly see teams struggle to extend and maintain these applications once the zealous engineers switched to the next project.</p><p>Yet there is also a desire for simpler state management:</p><ul><li><a href="https://medium.com/@amcdnl/the-future-of-javascript-state-management-is-less-state-management-ba1d97b99308">The future of JavaScript state management is less state management…</a></li><li><a href="https://medium.com/@rmcavin/my-favorite-state-management-technique-in-angular-rxjs-behavior-subjects-49f18daa31a7">My favorite state management technique in Angular — RxJS Behavior Subjects</a></li></ul><p>Both articles suggest <a href="https://blog.angular-university.io/how-to-build-angular2-apps-using-rxjs-observable-data-services-pitfalls-to-avoid/">observable data services</a> as a simple alternative to a full fledged state management library. The official angular documentation also <a href="https://angular.io/guide/component-interaction#parent-and-children-communicate-via-a-service">suggests a similar design</a>.</p><p>The pattern of the observable data service looks similar like this:</p><pre>export class CounterComponent implements OnInit, OnDestroy {<br>  currentCount: number;<br><br>  constructor(private counter: CounterService) { }<br> <br>  ngOnInit(): void {<br>    this.subscription = this.counter.getCount().subscribe(<br>      res =&gt; {<br>        this.currentCount = res.value;<br>      });<br>  }<br>...</pre><p>Yet there is an even simpler and more intuitive way to do state management in Angular…</p><blockquote>Just use Angular Change Detection!</blockquote><pre>export class CounterComponent {<br>   <br>  constructor(private counter: CounterService) { }<br><br>  get currentCount() {<br>    return this.counter.currentCount.value;<br>  }<br>...</pre><p>Here we just leverage the default change detection of Angular with a stateful service:</p><ul><li>In templates you can just bind to properties of the service (using getters on the component).</li><li>Then you can simply mutate these properties on the service.</li><li>Angular default change detection will do the rest.</li></ul><p>I created a <a href="https://github.com/jbandi/ng-subject-vs-getter">demo project</a> illustrating the concept by implementing the same simple counter demo from the post <a href="https://medium.com/@rmcavin/my-favorite-state-management-technique-in-angular-rxjs-behavior-subjects-49f18daa31a7">My favorite state management technique in Angular — RxJS Behavior Subjects</a>.</p><p>I think this is the simplest and most intuitive way to implement state management. It is a form of <a href="https://github.com/meteor/docs/blob/version-NEXT/long-form/tracker-manual.md">“transparent reactivity”</a>:</p><ul><li>The state is mutable data</li><li>Any change (mutation) of the state is automatically shown in the UI (the framework “reacts” by updating the UI)</li></ul><p>Angular gives us “transparent reactivity” out of the box when we use the default change detection.</p><p>This works with any shape of state. You can use deeply nested state and just mutate any desired property.</p><p>There is no need to implement a concept of “immutable state” (which is a paradox in most applications anyway).</p><p>There is no need to model state changes and reactions explicitly via observables and subscriptions. No need for RxJS at all!</p><blockquote>The key takeaway: Default Angular change detection enables real simple state management!</blockquote><p>I wonder why this is not documented more prominently …</p><p>Sometimes a simple solution is good enough. You should carefully consider if you really need ChangeDetectionStrategy.OnPush or even RxJS for state-management. What are the advantages compared to a simpler architecture? What are the trade-offs for your specific project? Can you really prove that a more complicated architecture pays off?</p><p>If you are going for a more complicated architecture, make sure that you get real benefits out of it. If we look at the demo from <a href="https://medium.com/@rmcavin/my-favorite-state-management-technique-in-angular-rxjs-behavior-subjects-49f18daa31a7">My favorite state management technique in Angular — RxJS Behavior Subjects</a> I see more disadvantages than advantages:</p><ul><li>With a Subject-based solutions like this we often have not a single source of truth any more: Each component instance that subscribes to the service has its own state. These distributed states are programmatically synchronized via pub-sub of the Subject (this could be avoided by using the async pipe instead of subscribing programmatically).</li><li>Moving away from a single source of truth for state-management to distributed state opens up the potential for many bugs where the states might diverge (i.e. race conditions)</li><li>Moving away from managing a single source of truth to the notion of message-passing between components via a service might quickly lead to a tangled web of communication paths (remember “scope-soup” of AngularJS)</li><li>Additionally subscribing to Observables comes with the need of unsubscribing which is another type of state (typically managed by the component lifecycle). When you rely on Angular default change tracking the components can be pure and stateless.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d32706e6f1c" width="1" height="1" alt=""><hr><p><a href="https://medium.jonasbandi.net/the-most-simple-state-management-solution-for-angular-1d32706e6f1c">The Most Simple State Management Solution for Angular</a> was originally published in <a href="https://medium.jonasbandi.net">reality-loop</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hidden Features of create-react-app]]></title>
            <link>https://medium.jonasbandi.net/hidden-features-of-create-react-app-52db3a17acc0?source=rss----c6f8509685f---4</link>
            <guid isPermaLink="false">https://medium.com/p/52db3a17acc0</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Jonas Bandi]]></dc:creator>
            <pubDate>Fri, 04 Jan 2019 00:23:21 GMT</pubDate>
            <atom:updated>2019-03-29T23:44:48.026Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*vwF15n_7MXfqLy6PolflJA.png" /></figure><h4>Initialize with TypeScript</h4><p>create-react-app officially supports TypeScript since <a href="https://github.com/facebook/create-react-app/releases/tag/v2.1.0">version 2.1</a> (as a consequence the fork <a href="https://github.com/wmonk/create-react-app-typescript">create-react-app-typescript </a>has been deprecated).</p><p>The documentation of <a href="https://github.com/wmonk/create-react-app-typescript">create-react-app</a> nicely <a href="https://facebook.github.io/create-react-app/docs/adding-typescript">describes how to transition from a JavaScript based project to TypeScript.</a></p><p>However if you want to start a new project with TypeScript there is the undocumented --typescript command-line argument:</p><pre>npx create-react-app —typescript my-awesome-project</pre><p>This is even easier than to create a plain React project and then adding TypeScript later on.</p><h4>Using webpack-bundle-analyzer</h4><p><strong>Update 2019–03–30:</strong> Using webpack-bundle-analyzer has been deprecated an the flag —-stats <a href="https://github.com/facebook/create-react-app/commit/140e182e7d7fbeb8d507b6be4813a4ce0bf9b6d8#diff-8d717038a105d8c7993616152faa1a38">has been removed in CRA v3</a>. You should be using source-map-explorer instead by running: npm i -g source-map-explorer and source-map-explorer &#39;build/static/js/*.js&#39;.<br>The following paragraph is deprecated:</p><p><a href="https://github.com/webpack-contrib/webpack-bundle-analyzer">webpack-bundle-analyzer</a> is a nice tool to visualize the content of JavaScript bundles/chunks.</p><p>In order to use <a href="https://github.com/webpack-contrib/webpack-bundle-analyzer">webpack-bundle-analyzer</a> webpack has to be run with the flag --stats. But create-react-app hides the call and configuration of webpack.</p><p>Fortunately you can pass the flag --stats to react-scripts (the build abstraction of cra) like this:</p><pre>npm run build -- --stats</pre><p>This generates the file bundle-stats.json in the public directory, which you then can use with webpack-bundle-analyzer:</p><pre>npx webpack-bundle-analyzer ./build/bundle-stats-json</pre><p>This feature is currently undocumented (documentation was removed), because the CRA team thinks the labelling of webpack-bundle-analyzer misleading, see this <a href="https://github.com/facebook/create-react-app/issues/4563">GitHub issue</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=52db3a17acc0" width="1" height="1" alt=""><hr><p><a href="https://medium.jonasbandi.net/hidden-features-of-create-react-app-52db3a17acc0">Hidden Features of create-react-app</a> was originally published in <a href="https://medium.jonasbandi.net">reality-loop</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hosting multiple React applications on the same document]]></title>
            <link>https://medium.jonasbandi.net/hosting-multiple-react-applications-on-the-same-document-c887df1a1fcd?source=rss----c6f8509685f---4</link>
            <guid isPermaLink="false">https://medium.com/p/c887df1a1fcd</guid>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Jonas Bandi]]></dc:creator>
            <pubDate>Sat, 01 Dec 2018 23:13:19 GMT</pubDate>
            <atom:updated>2019-03-17T22:44:09.635Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AErTctqokpzHxptQzfmwpQ.jpeg" /></figure><p>One simple/naive approach to break up a big single page application is to split it into different single page applications which then are loaded on the same html document.</p><p>Unfortunately it is not possible to run several <a href="https://github.com/facebook/create-react-app">create-react-app</a> applications on the same document because the JavaScript bundles resulting from a create-react-app project is not without side-effects: The bundled WebPack runtime writes an object on the global scope, which prevents to load several such bundles.</p><p>The following steps illustrate the problem and show how to fix it.<br>The resulting code is available here: <a href="https://github.com/jbandi/multi-spa-experiment">https://github.com/jbandi/multi-spa-experiment</a></p><h4>The Setup</h4><pre>npx create-react-app react-app1 --use-npm<br>npx create-react-app react-app2 --use-npm</pre><p>Changing the second React app to run on another port in development mode:</p><pre>// package.json<br>scripts: {<br>	&quot;start&quot;:&quot;PORT=3001 react-scripts start&quot;<br>..}</pre><p>Change the DOM node on which the second React app is bootstrapped:</p><pre>//index.html<br>&lt;div id=&quot;app2-root&quot;&gt;&lt;/div&gt;<br><br>// index.js<br>ReactDOM.render(&lt;App /&gt;, document.getElementById(&#39;app2-root&#39;));</pre><p>Run the first React application:</p><pre>cd react-app1<br>npm start</pre><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*M7672OEAtSSzg3bnObxg9A.png" /></figure><p>Run the second React application:</p><pre>cd react-app2<br>npm start</pre><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*D7aEUpJ_CNv36FhDAWvUUA.png" /></figure><p>Load the second React app on the document of the first React app:</p><pre>// index.html<br>&lt;div id=&quot;app2-root&quot;&gt;&lt;/div&gt;<br><br>&lt;script src=&quot;http://localhost:3001/static/js/bundle.js&quot;&gt;&lt;/script&gt;<br>&lt;script src=&quot;http://localhost:3001/static/js/1.chunk.js&quot;&gt;&lt;/script&gt;<br>&lt;script src=&quot;http://localhost:3001/static/js/main.chunk.js&quot;&gt;&lt;/script&gt;</pre><p>Unfortunately this does not have the expected result: We only see the second React app bootstrapped on the page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Rqrwy8bXDKMEknuM4zZbrg.png" /></figure><h4>The Problem</h4><p>Somehow loading the scripts of the second React app has a side effect and prevents the bootstrapping of the first React app!</p><p>It turns out that the WebPack runtime is the problem here. The WebPack runtime adds an object to the global scope which is used to lazy-load chunks. The default name for this object is webpackJsonp.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Ygko3sevJ_Y89bBjBPUt4A.png" /></figure><h4>The Solution</h4><p>The name of the webpackJsonp object can be <a href="https://webpack.js.org/configuration/output/#output-jsonpfunction">configured in the WebPack config</a>.</p><blockquote>This needs to be changed if multiple webpack runtimes (from different compilation) are used on the same webpage.</blockquote><p>To get access to the WebPack config of a create-react-app project, you need to <a href="https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#npm-run-eject">eject</a> or use another customization mechanism like <a href="https://github.com/arackaf/customize-cra">customize-cra</a>.</p><p>Then you can change the Webpack config like this:</p><pre>// webpack.config.dev.json<br>...<br>output: {<br>	...<br>	jsonpFunction: &#39;jsonpApp2&#39;<br>}</pre><p>Once you have changed the jsonpFunction of your second React app to a unique value, you must restart the development server (npm start)</p><p>Make sure that the document of the first app still references the correct scripts from the second app. Sometimes WebPack decides to rename the chunks…</p><p>And voilà: Both applications are bootstrapped on the same document:</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*LFot7cRGxqS8dX2s_fSNEA.png" /></figure><p><em>Note: </em>I only showed here how to adjust the WebPack configuration for the development build. The same change is needed for the production WebPack configuration.<br>For production the project also has to solve the challenge of adding the correct script names to the integrating document, since WebPack is typically configured (i.e in create-react-app) to add a hash of the script content to the script name.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c887df1a1fcd" width="1" height="1" alt=""><hr><p><a href="https://medium.jonasbandi.net/hosting-multiple-react-applications-on-the-same-document-c887df1a1fcd">Hosting multiple React applications on the same document</a> was originally published in <a href="https://medium.jonasbandi.net">reality-loop</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular CLI and Moment.js: A recipe for disaster … and how to fix it.]]></title>
            <link>https://medium.jonasbandi.net/angular-cli-and-moment-js-a-recipe-for-disaster-and-how-to-fix-it-163a79180173?source=rss----c6f8509685f---4</link>
            <guid isPermaLink="false">https://medium.com/p/163a79180173</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Jonas Bandi]]></dc:creator>
            <pubDate>Wed, 19 Sep 2018 22:22:33 GMT</pubDate>
            <atom:updated>2018-12-29T01:32:31.494Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kPsSsCOsxVcp7VvDlzywWA.png" /></figure><p>When I wrote about “<a href="https://medium.jonasbandi.net/to-use-angular-cli-or-not-187f87d0b550">To use Angular CLI or not?</a>”, I claimed that there was not much risk involved in starting a project with Angular CLI, since ng ejectallowed you to change your mind later and jump to a vanilla Webpack setup.</p><p>This has changed since AngularCLI 6: the eject <a href="https://github.com/angular/angular-cli/issues/10618">command is now disabled</a>.</p><blockquote>Relying on Angular CLI has just become a much bigger risk for your project.</blockquote><p>When I wrote about <a href="https://medium.jonasbandi.net/angular-vs-react-the-cli-d8af18063006">“Angular vs. React: The CLI”</a> I claimed that I have not yet had a mandatory reason to eject. In the meantime I have come across several cases where the is a need to modify the webpack config of an Angular CLI project, which could be achieved witheject … but not any more.</p><p>One reasons is an integration with <a href="https://threejs.org/">three.js</a>. Many three.js extension rely on the global variable THREE. <a href="https://gist.github.com/cecilemuller/0be98dcbb0c7efff64762919ca486a59">The typical solution</a> in a webpack build is to expose THREE globally <a href="https://webpack.js.org/plugins/provide-plugin/">via webpack config</a>… bad luck, with Angular CLI v6 you don’t have that option any more.<br>Other solutions <a href="https://github.com/jbandi/angulr-three-project-demo/commit/c492e60e3c84e91c120654aba273350ca771ca9a">are much more hacky</a> …</p><p>Another nasty example where you typically need access to the webpack configuration is when you want to use the popular library <a href="http://momentjs.com/">Moment.js.</a></p><p>Let me illustrate the problem:</p><pre>npx @angular/cli@6.1 new my-project<br>cd my-project<br>npm i moment @types/moment</pre><p>Now use <em>Moment.js</em> in your project, i.e. in main.ts :</p><pre>import * as moment from &#39;moment&#39;<br>console.log(moment());</pre><p>Now run the build and have look at the bundle:</p><pre>npm run build -- --prod --stats-json<br>npx webpack-bundle-analyzer dist/my-project/stats.json</pre><p>You get the following scary picture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8YCtqyaKSdxoEpUPgj84hw.png" /></figure><p>The main bundle of your application has a size of 498 KB of which <em>Moment.js</em> is 329 KB! The biggest part of <em>Moment.js</em> consists of a bunch of locales, which you most probably do not need!</p><p>Of course this is <a href="https://github.com/moment/moment/issues/1435#issuecomment-33106268">a shortcoming of Moment.js in combination with webpack</a>. This is not inherently a problem of the Angular CLI. However <em>Moment.js</em> is a very popular library, many Angular projects want/need to use it. Maybe only because some other library depends on <em>Moment.js</em> (<a href="https://www.npmjs.com/browse/depended/moment">many do!</a>).</p><p>There is an easy fix for the problem: <a href="http://how-to-optimize-momentjs-with-webpack">how-to-optimize-momentjs-with-webpack</a>.<br>However you need to modify the webpack config… which is not possible in a plain Angular CLI project! Bummer!</p><p>The answer of the Angular CLI is: <a href="https://github.com/angular/angular-cli/issues/5166">that this is unfortunate, but they can’t deal with such special cases</a>… bummer again!<br>Note: <a href="https://github.com/facebook/create-react-app">create-react-app</a> accepts that <em>Moment.js,</em> as a very common library, deserves special handling and <a href="https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#momentjs-locales-are-missing">solves the problem out of the box</a>.</p><blockquote>At this point your project has a problem…</blockquote><p>Of course the JavaScript ecosystem has a solution for everything:</p><h3>Wayne Maurer on Twitter</h3><p>@jbandi Monkey patch node_modules with https://t.co/p7p7L5FtDi</p><p>… but I don’t like that a “state-of-the-art” framework forces me into hacks like this.</p><h4>A solution (sort of …)</h4><h3>Rob Wormald on Twitter</h3><p>@jbandi https://t.co/1ObTgoXZ2L use this if you want to override config for some library without ejecting.</p><p>With <a href="https://github.com/manfredsteyer/ngx-build-plus">ngx-build-plus</a> you can change the webpack configuration in an Angular CLI project without ejecting.</p><p><em>(Note: The section below was updated on 2018–12–29 for Angular CLI 7.1.4)</em></p><p>In the example from above you can do the following:</p><pre>ng add ngx-build-plus</pre><p>Add a file webpack.extra.js in the root of your project:</p><pre>const webpack = require(&#39;webpack&#39;);</pre><pre>module.exports = {<br>  plugins: [<br>    new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),<br>  ]<br>}</pre><p>And run:</p><pre>npm run build -- --prod --stats-json --extra-webpack-config webpack.extra.js</pre><pre>npx webpack-bundle-analyzer dist/my-project/stats.json</pre><p>Yay! All the locales have disappeared from the bundle:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W6yBneWabOlz9Iw-iX8Aqw.png" /></figure><p>You have now solved the problem! … But did you consider the price of the solution?</p><blockquote>At best I can congratulate someone for quickly and simply solving a problem on top of the shit that they are given. The only software that I like is one that I can easily understand and solves my problems.<br>- <a href="https://gist.github.com/cookrn/4015437">Ryan Dahl on Software</a></blockquote><p>Yup, ngx-build-plus is yet another “arcane” library you now depend on. Are you prepared to maintain that library yourself?</p><p>For Angular CLI v7.1.4 using <a href="https://github.com/manfredsteyer/ngx-build-plus">ngx-build-plus</a> is a working solution.</p><p>… but <a href="https://github.com/manfredsteyer/ngx-build-plus">ngx-build-plus</a> is was broken for Angular CLI 6.2:</p><h3>Jonas Bandi on Twitter</h3><p>Attempting an Angular CLI upgrade from 6.1 -&amp;gt; 6.2:</p><p>… bummer!</p><p>Note: There are other projects similar to <a href="https://github.com/manfredsteyer/ngx-build-plus">ngx-build-plus</a>, maybe they make you happy:</p><p><a href="https://github.com/meltedspark/angular-cli-builders">https://github.com/meltedspark/angular-cli-builders</a><br><a href="https://github.com/Angular-RU/angular-cli-webpack">https://github.com/Angular-RU/angular-cli-webpack</a></p><p>The source code for the above example is available here: <a href="https://github.com/jbandi/ng-moment-problem">https://github.com/jbandi/ng-moment-problem</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=163a79180173" width="1" height="1" alt=""><hr><p><a href="https://medium.jonasbandi.net/angular-cli-and-moment-js-a-recipe-for-disaster-and-how-to-fix-it-163a79180173">Angular CLI and Moment.js: A recipe for disaster … and how to fix it.</a> was originally published in <a href="https://medium.jonasbandi.net">reality-loop</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Modern JavaScript Frameworks: Angular, React & Vue.js]]></title>
            <link>https://medium.jonasbandi.net/modern-javascript-frameworks-angular-react-vue-js-3d6150282afa?source=rss----c6f8509685f---4</link>
            <guid isPermaLink="false">https://medium.com/p/3d6150282afa</guid>
            <dc:creator><![CDATA[Jonas Bandi]]></dc:creator>
            <pubDate>Thu, 06 Sep 2018 22:32:27 GMT</pubDate>
            <atom:updated>2018-09-06T22:32:27.234Z</atom:updated>
            <content:encoded><![CDATA[<p>Today I was speaking about Angular, React &amp; Vue.js at the seminar “Webtechnologien für die Industrie 4.0” at <a href="https://www.m-f.ch/">m&amp;f engineering</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B2vVmttk3WGVigxAr_ri3g.jpeg" /></figure><p>Here are the slides:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.slideshare.net%2Fslideshow%2Fembed_code%2Fkey%2F3PKm0ynkyzxMzu&amp;url=https%3A%2F%2Fwww.slideshare.net%2FJonasBandi%2Fmodern-javascript-frameworks-angular-react-vuejs%2F&amp;image=https%3A%2F%2Fcdn.slidesharecdn.com%2Fss_thumbnails%2Fangularreactvue-180906220754-thumbnail-4.jpg%3Fcb%3D1536271902&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=slideshare" width="600" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/c9e96891c1012900e6fd7f679ee086a5/href">https://medium.com/media/c9e96891c1012900e6fd7f679ee086a5/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d6150282afa" width="1" height="1" alt=""><hr><p><a href="https://medium.jonasbandi.net/modern-javascript-frameworks-angular-react-vue-js-3d6150282afa">Modern JavaScript Frameworks: Angular, React &amp; Vue.js</a> was originally published in <a href="https://medium.jonasbandi.net">reality-loop</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Frontend Monoliths: Run if you can!]]></title>
            <link>https://medium.jonasbandi.net/frontend-monoliths-run-if-you-can-310bfcb3e298?source=rss----c6f8509685f---4</link>
            <guid isPermaLink="false">https://medium.com/p/310bfcb3e298</guid>
            <dc:creator><![CDATA[Jonas Bandi]]></dc:creator>
            <pubDate>Tue, 04 Sep 2018 21:42:17 GMT</pubDate>
            <atom:updated>2018-09-05T18:50:56.434Z</atom:updated>
            <content:encoded><![CDATA[<p>Last week I was invited to give a talk at the SBB Developer Day 2018.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ch6FpPkIscyhoM421GzNwA.jpeg" /></figure><p>Here are my slides:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.slideshare.net%2Fslideshow%2Fembed_code%2Fkey%2FHD6VieKgEzv7xP&amp;url=https%3A%2F%2Fwww.slideshare.net%2FJonasBandi%2Ffrontend-monoliths-run-if-you-can%2FJonasBandi%2Ffrontend-monoliths-run-if-you-can&amp;image=https%3A%2F%2Fcdn.slidesharecdn.com%2Fss_thumbnails%2F20180829frontendmonolith-180904194642-thumbnail-4.jpg%3Fcb%3D1536090545&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=slideshare" width="600" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/c7e7a3183438adda0fb0a0eddeda95af/href">https://medium.com/media/c7e7a3183438adda0fb0a0eddeda95af/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=310bfcb3e298" width="1" height="1" alt=""><hr><p><a href="https://medium.jonasbandi.net/frontend-monoliths-run-if-you-can-310bfcb3e298">Frontend Monoliths: Run if you can!</a> was originally published in <a href="https://medium.jonasbandi.net">reality-loop</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Weekend Reader 2018.15: JavaScript is Chaos]]></title>
            <link>https://medium.jonasbandi.net/weekend-reader-2018-15-javascript-is-chaos-5b0131a4b4d8?source=rss----c6f8509685f---4</link>
            <guid isPermaLink="false">https://medium.com/p/5b0131a4b4d8</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Jonas Bandi]]></dc:creator>
            <pubDate>Sat, 14 Apr 2018 22:12:13 GMT</pubDate>
            <atom:updated>2018-04-14T22:12:13.444Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*lf4L9_t06OyGU7VH2W_Tpg.png" /></figure><h4><a href="https://medium.com/@caspervonb/the-internet-is-at-the-mercy-of-a-handful-of-people-73fac4bc5068">The Node.js Ecosystem Is Chaos</a></h4><p>A critical view on the dependency problems of modern javascript development …</p><h4><a href="https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/">ES modules: A cartoon deep-dive</a></h4><p>In-depth explanation of the mechanics of modules in ECMAScript.</p><h4><a href="https://blog.kentcdodds.com/application-state-management-66de608ccb24">Application State Management</a></h4><p>This article by Kent C. Dodds discussing state management options for React applications. The discussion is also interesting for Angular development. My take-away: There is no one-size-fits-all solution for state management. The solution you choose should be specific to your project. Sometimes it even makes sense to use different state management techniques in the same app</p><h4><a href="http://blog.isquaredsoftware.com/2018/03/redux-not-dead-yet/">Redux — Not Dead Yet!</a></h4><p>The <a href="http://wesbos.com/react-context/">new Context API of React 16.3</a> provides an elegant and simple solution for the <a href="https://blog.kentcdodds.com/application-state-management-66de608ccb24">“prop drilling” problem</a> of state management in a component architecture. The “prop drilling” problem is probably the most prominent reason for using Redux (and arguably a wrong reason, if “prop drilling” is the only problem you need to solve, since there are much simpler solutions). <br>The maintainer of Redux explains why Redux still is here to stay.</p><h4>Podcast: <a href="https://egghead.simplecast.fm/94ad357b">Michel Weststrate creator of Mobx and Immer Libraries for JavaScript</a></h4><p>An interesting conversation with information about MobX and Redux and the different paradigms behind those two state management libraries.</p><h4>Video: <a href="https://www.youtube.com/watch?v=NQta2urK3zk">10 tips for React Redux At Scale</a></h4><p>My personal opinion is that for most projects there are better state-management techniques than Redux/NgRx. But if you go down the Redux path this short video has some valuable tips.</p><h4><a href="https://github.com/erikras/ducks-modular-redux">Redux Ducks</a></h4><p>If you are following a typical Redux tutorial, you find building a project where you jump a lot between files: actions, action-creators, reducers and selectors are all defined in separate files. Redux Ducks proposes another approach: structure your application by features.</p><p>A similar way is described as re-ducks in this post: <a href="https://medium.freecodecamp.org/scaling-your-redux-app-with-ducks-6115955638be">Scaling your Redux App with ducks</a>. There is also a <a href="https://github.com/michaeljota/ngrx-ducks">ducks proposal for ngrx/Angular</a>.</p><h4><a href="https://medium.com/slalom-engineering/contract-first-design-with-angular-4-and-swagger-d3bb374096f">Contract First Design with Angular 4 and Swagger</a></h4><p>Code generation of typescript classes/interfaces from a backend definitions is an interesting topic for enterprise applications. This article uses <a href="https://github.com/wcandillon/swagger-js-codegen">swagger-js-codegen</a>, which is implemented in JavaScript and allows to customize templates. However the projects seems not very active. I have seen other projects using <a href="swagger-codegen">swagger-codegen</a> or <a href="typescript-generator">typescript-generator</a> (both of them require Java).</p><h4><a href="https://projectfailures.wordpress.com/2008/06/24/project-from-hell/">Project from Hell</a></h4><p>A funny description of a completely dysfunctional project.</p><h4>Tweets of the week</h4><h3>Martin Fowler on Twitter</h3><p>I believe that the principles of good programming are more important than what language we code in. I&#39;d rather work with well-written JavaScript than badly-written Smalltalk.</p><h3>Steve Drew on Twitter</h3><p>https://t.co/o9GcJnd7Z0</p><h3>Enrique 🐘 on Twitter</h3><p>The year is 2040. The Information Superhighway is littered on both sides with discarded blockchains, carcasses of Docker containers, and rolled up kubernetes clusters. If you squint, you can see all those abandoned JS frameworks lying everywhere, like metal dust.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b0131a4b4d8" width="1" height="1" alt=""><hr><p><a href="https://medium.jonasbandi.net/weekend-reader-2018-15-javascript-is-chaos-5b0131a4b4d8">Weekend Reader 2018.15: JavaScript is Chaos</a> was originally published in <a href="https://medium.jonasbandi.net">reality-loop</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Here is why you might NOT want to use TypeScript — Part 3: TypeScript is not JavaScript]]></title>
            <link>https://medium.jonasbandi.net/here-is-why-you-might-not-want-to-use-typescript-50ab0d225bdd?source=rss----c6f8509685f---4</link>
            <guid isPermaLink="false">https://medium.com/p/50ab0d225bdd</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Jonas Bandi]]></dc:creator>
            <pubDate>Thu, 12 Apr 2018 21:54:41 GMT</pubDate>
            <atom:updated>2018-06-08T08:56:22.837Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Of4wYvgLswIXfhs9kq7ymQ.png" /></figure><p>Recently I read a post called <a href="http://jonathancreamer.com/why-would-you-not-use-typescript/">“Why would you NOT use TypeScript?”</a>. I found that post a bit biased, so I decided to play advocatus diaboli…</p><blockquote>Disclaimer: I am working as a consultant and trainer for modern web development in the enterprise. <strong>For most of those projects I unconditionally recommend to use TypeScript. But there are also many reasons not to use TypeScript in some projects.</strong></blockquote><p>When starting a new project or reviewing an existing project, I evaluate on a case-by-case basis:</p><ul><li>Is a static type checker for JavaScript worth the effort?</li><li>Is TypeScript the right tool for static type checking or should we consider an alternative?</li></ul><p>In this second post about the topic, I look into the overhead TypeScript adds to a project.<br><a href="https://medium.jonasbandi.net/here-is-why-you-might-not-want-to-use-typescript-part-1-alternatives-ec1248bb6dc">In the first post I wrote about alternatives to TypeScript.</a> <br><a href="https://medium.jonasbandi.net/here-is-why-you-might-not-want-to-use-typescript-part-2-typescript-adds-overhead-20b670b9105a">In the second post I looked into the overhead TypeScript adds to a project.</a></p><p>In this post I will wrap up with some negative implications of TypeScript not being JavaScript.</p><h3>TypeScript is not JavaScript: LipStick on the Pig</h3><p>TypeScript might be misleading. It tries to hide the “bad parts” of JavaScript and gives developers from traditional OO-languages a more familiar experience: They can work with constructs they know: namespaces, classes, interfaces, enums, access modifiers and types. But these are often just compile-time constructs. They are transpiled to JavaScript constructs (i.e. IIFEs) or they are just removed (i.e. types). The code that is actually executed at runtime does therefore still expose quirks that come with JavaScript (i.e. dynamic binding of this and no type-checks). Ultimately this is a leaky abstraction and developers must understand the concepts of JavaScript to debug and truly understand their TypeScript code.</p><blockquote>So at the end of the day, TypeScript complies down to the same prototypal, functional, object-oriented Frankenstein’s monster that we know as Javascript.<br>- <a href="https://www.quora.com/Are-there-reasons-I-should-not-use-Typescript-for-my-new-React-based-web-application">from Quora</a></blockquote><h3>Jonas Bandi on Twitter</h3><p>I talked to several &quot;Angular experts&quot; lately ... I am amazed at their lack of JS knowhow ... &quot;TS allows us to program like Java&quot; ...</p><p>One thing that many beginners do not understand about TypeScript is that it does not guarantee type-correctness at runtime. Your TypeScript code might be fully typed and the compiler ensures you that everything must be correct… but at runtime you still get errors because your variables might be of the wrong types! Type error might still enter your system at the “untyped” boundaries … i.e. when getting json from the network or from local storage or even from the DOM. <br><strong>By design TypeScript does no type checks at runtime. </strong>If you want type checks at runtime you have to implement them. Typically this means some duplication between the types you implement for compile-time checking and the types you build for run-time checking. Libraries like <a href="https://www.npmjs.com/package/prop-types">prop-types</a> or <a href="https://github.com/gcanti/io-ts">io-ts</a> help with defining type-checks at runtime. But there will be some duplication.</p><h3>Jonas Bandi on Twitter</h3><p>@tomastrajan Unfortunately TypeScript does not not make &quot;invalid states unrepresentable&quot; ... it just prevents *your* code to put the system in a invalid state... from my teaching experience many developers (especially Angular developers) don&#39;t get that ...</p><h3>TypeScript is not JavaScript: Hiring Implications</h3><blockquote>Software is eating the world. The web is eating software &amp; JavaScript Rules the web.<br>- <a href="https://medium.com/javascript-scene/forget-the-click-bait-here-s-what-the-javascript-job-market-really-looks-like-in-2016-ddfe0d39b467">Eric Elliot</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*H40Ix9PrXHyHKrYRDNHyHw.png" /></figure><p>JavaScript is extremely popular. By using TypeScript, you are focusing on a language that is less popular, therefore the pool of developers that can or want to work on your projects is smaller.<br>Depending on your project this might be a limitation or a factor that helps to ensure the right developers get on the project.</p><p><strong>By choosing TypeScript, you are limiting the pool of developers that might work on your project.</strong></p><h3>TypeScript is not JavaScript: Lock-In</h3><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*YcNwD2mpEtRTKIqugjhUHg.jpeg" /></figure><p>TypeScript claims to be a superset of JavaScript. <a href="http://blog.jonasbandi.net/2016/10/myth-of-superset.html">That claim alone is questionable, since typical JavaScript code produces errors in TypeScript.</a></p><p>As a consequence migrating a project to TypeScript might be more work than just renaming the files from .js to .ts.</p><p>When you start using TypeScript features (types, generics, enums, access modifiers …), your code does not run directly in a JavaScript runtime any more.<br>Your project becomes dependent on TypeScript. For a big code base written in TypeScript it would be a lot of work to get back to plain JavaScript.</p><p>Right now this might not look like a problem, since TypeScript provides you with all its benefits.</p><p>The problem might arise in the long term. The current strength of TypeScript is that it is so closely aligned to JavaScript. This enables easy integration with the huge JavaScript ecosystem. Currently you can use TypeScript with almost every JavaScript library and framework. The TypeScript team clearly stated that this is also the goal for the future. This means new JavaScript features are also compatible with TypeScript.</p><p>However in a far future TypeScript might decide to deviate further away from JavaScript. This might impact the ease of integration with the JavaScript ecosystem a lot. Then TypeScript would just become another language that compiles to JavaScript, <a href="https://github.com/jashkenas/coffeescript/wiki/list-of-languages-that-compile-to-js">there are already a lot of those</a> …</p><p>Another danger is that certain TypeScript features might clash with future JavaScript features and TypeScript has to change. This happened before with modules (I think TypeScript handled it gracefully, but there is <a href="https://www.typescriptlang.org/docs/handbook/namespaces-and-modules.html">still some friction</a> in TypeScript aroundnamespace and module).</p><p>The next clash that is on the horizon is <a href="https://github.com/tc39/proposal-class-fields">JavaScript introducing private fields</a>.</p><blockquote>I worry about building up a large codebase using TypeScript, only to have the ECMAScript spec introduce conflicting keywords and type features<br>- Eric Elliot, <a href="https://medium.com/javascript-scene/the-shocking-secret-about-static-types-514d39bf30a3">The Shocking Secret About Static Types</a></blockquote><h3>TypeScript does not have the same momentum as JavaScript. By using TypeScript you choose a path that bears some more risks than <a href="https://www.slideshare.net/BrendanEich/jslol-9539395/110-Always_bet_on_JS_First">betting on JavaScript</a>.<br>Also TypeScript does not shield you from having to deeply understand JavaScript. A TypeScript expert must also be a JavaScript expert!</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50ab0d225bdd" width="1" height="1" alt=""><hr><p><a href="https://medium.jonasbandi.net/here-is-why-you-might-not-want-to-use-typescript-50ab0d225bdd">Here is why you might NOT want to use TypeScript — Part 3: TypeScript is not JavaScript</a> was originally published in <a href="https://medium.jonasbandi.net">reality-loop</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Here is why you might NOT want to use TypeScript — Part 2: TypeScript adds Overhead]]></title>
            <link>https://medium.jonasbandi.net/here-is-why-you-might-not-want-to-use-typescript-part-2-typescript-adds-overhead-20b670b9105a?source=rss----c6f8509685f---4</link>
            <guid isPermaLink="false">https://medium.com/p/20b670b9105a</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Jonas Bandi]]></dc:creator>
            <pubDate>Sun, 08 Apr 2018 23:50:26 GMT</pubDate>
            <atom:updated>2018-06-08T08:58:04.122Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*Of4wYvgLswIXfhs9kq7ymQ.png" /></figure><p>Recently I read a post called <a href="http://jonathancreamer.com/why-would-you-not-use-typescript/">“Why would you NOT use TypeScript?”</a>. I found that post a bit biased, so I decided to play advocatus diaboli…</p><blockquote>Disclaimer: I am working as a consultant and trainer for modern web development in the enterprise. <strong>For most of those projects I unconditionally recommend to use TypeScript. But there are also many reasons not to use TypeScript in some projects.</strong></blockquote><p>When starting a new project or reviewing an existing project, I evaluate on a case-by-case basis:</p><ul><li>Is a static type checker for JavaScript worth the effort?</li><li>Is TypeScript the right tool for static type checking or should we consider an alternative?</li></ul><p>In this second post about the topic, I look into the overhead TypeScript adds to a project.<br><a href="https://medium.jonasbandi.net/here-is-why-you-might-not-want-to-use-typescript-part-1-alternatives-ec1248bb6dc">In the first post I wrote about alternatives to TypeScript.</a> <br><a href="https://medium.jonasbandi.net/here-is-why-you-might-not-want-to-use-typescript-50ab0d225bdd">In a third post I wrap up with some negative implications of TypeScript not being JavaScript.</a></p><h3>TypeScript is an Overhead: Introducing a static type system</h3><p>The main value of TypeScript today is adding a static type system at compile time. Depending on your project as well as the background and mindset of the team, the value of a static type system and thus the value of TypeScript might be questionable.</p><p>The value of a static type system is not undisputed. There are many claims that a static type system doe not prevent bugs or increase the quality of a project. The disadvantages of a static type system are about loosing the flexibility and elegance of a dynamically typed language and the additional complexity, noise and effort introduced by the type system.</p><p>Modeling generic code with a static type system can quickly become complicated , noisy and difficult to understand. Here is an example <a href="https://github.com/mobxjs/mobx-react/issues/256">from this GitHub thread</a>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/78de79e7da685e4e3681a2dd01a2fe95/href">https://medium.com/media/78de79e7da685e4e3681a2dd01a2fe95/href</a></iframe><blockquote>I think that JavaScript’s loose typing is one of its best features and that type checking is way overrated. TypeScript adds sweetness, but at a price. It is not a price I am willing to pay.<br>- <a href="https://plus.google.com/+DouglasCrockfordEsq/posts/MgzNUSTwjRt">Douglas Crockford</a></blockquote><blockquote>In many smaller-scale use cases, introducing a type system may result in more overhead than productivity gain.<br>- <a href="[https://vuejs.org/v2/guide/comparison.html#TypeScript]">Vue.js Developers Guide</a></blockquote><blockquote>Static typing is an additional layer of complexity. You are basically writing the code again, on a different level.<br>- Dr. Axel Rauschmayer, <a href="http://2ality.com/2018/03/javascript-typescript-reasonml.html">JavaScript vs. TypeScript vs. ReasonML</a></blockquote><blockquote>TypeScript comes with a substantial cost, and it wouldn’t be wise to ignore it.<br>- Eric Elliot, <a href="https://medium.com/javascript-scene/you-might-not-need-typescript-or-static-types-aa7cb670a77b">You might not need TypeScript (or Static Types)</a></blockquote><blockquote>Static types give you a false sense of security. Type correctness does not guarantee program correctness.<br>- Eric Elliot, <a href="https://medium.com/javascript-scene/the-shocking-secret-about-static-types-514d39bf30a3">The Shocking Secret About Static Types</a></blockquote><p>Here is <a href="https://danluu.com/empirical-pl/">a list of studies that research the topic of Static vs. Dynamic languages</a>.</p><h3>TypeScript is an Overhead: Implying a build step</h3><p>TypeScript is a compiled language, this implies you need a build step for compilation.</p><p>There are many projects out there where a build step does not makes sense. Especially regarding the fact, that the state-of-the-art build tooling in the JavaScript ecosystem is re-invented every year.</p><blockquote>Perhaps you don’t want to set up an entire build system for some small abstractions you could feasibly do without.<br>- <a href="https://www.smashingmagazine.com/2018/02/jquery-vue-javascript/">Replacing jQuery With Vue.js: No Build Step Necessary</a></blockquote><blockquote>If your project does not need a build step, then you can’t use TypeScript.</blockquote><p>The “real frontend engineers” among the audience will claim that projects without build step are just no “real projects”.</p><p>I see in most enterprises many small web pages providing some functionality or information for different end-users (process monitors, reports, simple process controls of data input …). <strong>The strength of the traditional web platform is that it is very easy to build a small html site, which is enhanced with JavaScript. This can provide immense value at a very low cost.</strong></p><p>Also I think the pendulum will swing back from the current SPA-hype to server-rendered and “client-side enhanced” pages for many use cases line-of-business applications.</p><p>In these scenarios the model of adding some simple &lt;script src=&quot;...&quot;&gt; to small pages is very productive. Optimising steps are often not needed for such in-house line-of-business applications.</p><h3>TypeScript is an Overhead: Complicating existing build toolchains</h3><p>Starting with the TypeScript compiler is not difficult: tsc --watch</p><p>But if you already have a build pipeline (maybe still based on grunt or gulp then you are probably doing some other processing steps that have to play well with the TypeScript compiler. i.e. template preprocessing/inlining, minification, source map generation … understanding and maintaining modern frontend build toolchains is a lot of work and a constantly moving target. Sometimes it is just not worth the effort to introduce yet another tool, sometimes it is really not feasible to do it.</p><p>Tools like the angular-cli or create-react-app help tremendously to reduce the effort to create/maintain a modern frontend build, but for some legacy projects these are just not an option.</p><p>Also there have been repeated cases where a new versions of TypeScript breaks existing code. Prominent examples that come to my mind are:</p><ul><li><a href="https://github.com/Microsoft/TypeScript/issues/16593">New errors with RxJS on 2.4.1</a></li><li><a href="https://github.com/angular/angular/issues/17863">@angular/core is not compatible with Typescript 2.4.1</a></li></ul><p>With TypeScript your build toolchain gets more complicated. This might be a cost that you are not willing to pay.</p><h3>TypeScript adds an overhead on a conceptual level by introducing types and on a technical level by requiring a build step. For some projects this overhead is just not worth it.</h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20b670b9105a" width="1" height="1" alt=""><hr><p><a href="https://medium.jonasbandi.net/here-is-why-you-might-not-want-to-use-typescript-part-2-typescript-adds-overhead-20b670b9105a">Here is why you might NOT want to use TypeScript — Part 2: TypeScript adds Overhead</a> was originally published in <a href="https://medium.jonasbandi.net">reality-loop</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>