Newsletter #10 - Nrwl Nx 10

Sébastien Dubois / July 26, 2020

8 min read

Welcome to the 10th edition of DeveloPassion's newsletter.

Before we start, I'd like to ask all of you to help me out a bit. If you find this newsletter interesting, then please do take a bit of time to share this link to others on social media: https://mailchi.mp/fb661753d54a/developassion-newsletter

With your help, others will also get a chance to discover and enjoy reading it. As an added benefit, it'll also motivate me to continue the experience! Don't forget that you can also follow me on Twitter and Medium where i publish my articles.

10 is going the magic number for this edition. I'm really happy because it's already the tenth edition of my newsletter. I of course intend to make it a 100, one newsletter at a time. I still don't intend to have a more regular schedule as this remains on the back burner, but it's an initiative that I want to continue. You are now 25 to follow this newsletter and I hope that we can make it x10 by the end of the year.. ;-)

I'm also thinking more and more about publishing video content... I haven't taken the time yet to prepare my screencasting setup...

My article about Angular 10 has been especially popular, with over 11K views 700+ claps and almost 200$ earnings, which I find really amazing (and motivating of course). It's the first time that one of my articles is that successful. I imagine that it's due to the magic 10? Anyways, I'll probably run a poll one of these days to see if you guys/girls/whatever are interested in reading more in-depth articles about new open source releases..

TypeScript news

As usual, here are some news about TypeScript.

I've published an introductory article about TypeScript; it doesn't contain any code because I just felt like explaining what the language is about for those who just don't know. It may be a good article to show managers what it is without scaring them away... ;-)

I've updated my article about TypeScript 4 in order to cover Variadic Tuple Types. Those seem really cool and I think that they'll have a great impact on the conciseness and quality of our code.

I've also published an article explaining how you can safely refer to TypeScript interface property names at runtime. I found this technique recently and thought it would be nice to share it. As you know, interfaces are gone at runtime; still, it's possible to write typesafe checks against property names, by leveraging the keyof keyword. I've used this to handle partial updates in my NestJS back-end.

While we're at it, I've also published a small piece showing how to iterate over string enum keys and values using Object.keys and Object.values. It's a basic article, but maybe some of you didn't know that it was possible to use that against TS enums.

Finally, I wrote an article about how to ensure that you never miss a switch case statement. It explains a neat use case for the unknown keyword of TypeScript. Personally, I use this whenever I can to avoid subtle bugs that can easily be introduced when enums backing a switch are modified. If you're curious about how the unknown keyword helps, then check out the article.

Nrwl NX 10

Nrwl NX 10 has finally been released. It came a bit later than expected, but finally includes support for Angular 10. This release also improved the WebStorm/IntelliJ integration for Jest and switched over to solution-style TypeScript configuration files. I've covered those in my article about TS 3.9.

NX 10 brings initial support for Gatsby, which is quite cool. I've used Gatsby to create my company's Website and it felt like a breeze. It's nice that NX now supports that as well. Next to that, NX continues to bring improvements to its React and Next.js support Check out the official blog articles to learn more.

If you ask me, Nx has a great future in front of it. Victor has published plans about NX 11 already. In a few word, they plan to further improve computation caching and performance in general, support custom layouts and continue to improve their support for React, Angular, Cypress, Storybook, Jest, etc.

What I found more interesting is the fact that they're now planning to introduce official support for Java (and thus probably Kotlin as well) in Nx. This could be a game changer for Java projects (based on Gradle!) as the usual approach to marry back-end and front-end has mostly been to either keep them separate and managed separately, or to "host" the front-end part in the back-end, integrating it somehow (e.g., using JHipster and the like). I was never a fan of those integrations as the front-end was most often considered as a secondary concern and didn't get all the attention it deserved.

I've also read that folks are looking at integrating Go support. Awesome! :)

Input validation with NestJS

As you might know, I like everything from front-end to back-end, so it's no wonder that I'm also working on back-end systems. As a matter of fact, I've spent way more time working on back-end than front-end in my carreer. I've worked for over ten years on Java/JEE/Spring based systems.

This week, I've published an article about how to properly handle input validation with NestJS. Input validation is critical for application security, so if you venture in back-end land, don't forget about it. As a matter of fact it's also super important on the front-end ^^.

In that article, I've explained what NestJS supports out of the box as well as what the alternatives are to handle validation. I've also shown exactly how I'm handling this concern (at least at the REST API layer level). It's not enough and I go quite a lot further in the business layer of my application, but that'll be for another article ;-)

While we're onto NestJS, note that version 7.3.0 has been released last month; it doesn't add all that much, but the framework keeps a steady release cycle, so it's well alive and kicking. I must say that NestJS is really a good surprise in Node-land. It's stable, full-featured, powerful and really well documented. Hopefully, it'll keep on improving over time.

Embedding translations in your JS files

I don't know if it's just me, but the idea of having to make additional HTTP requests to load translations always felt wrong to me. I agree that we don't spend our days switching from language to language, but for users who first interact with an app, it's quite regular to have to switch the language at least once to the correct one. Having that happen instantly is something I find valuable... but I might be wrong. Another way to see that is to consider that, since it doesn't happen often at all, it can take a little while... All a matter of opinion I guess.

I wrote an article explaining how to embed translations in your JS bundles, so that switching the language can happen instantly: https://medium.com/javascript-in-plain-english/embedding-translations-in-your-js-bundles-with-ngx-translate-526ce847acab. I use that in my apps and find it pleasing, especially combined with an offline-first approach.

Even if you don't agree with my point of view on this subject, I think that the article remains interesting to read, as it also shows how to typecheck the translation files and ensure that they're all aligned with each other and some other little tricks ;-)

Pay attention to your bus factor

What's the bus factor of your team? Do you know?

If you're not in charge, then you might not care much, but whatever your position is, it actually matters and can be good to remind managers about. When there's only one person in the team that owns some knowledge / processes, then the whole team is deeply in trouble because you're just one guy away from catastrophe. Unfortunately, it happens a lot in many organizations. I've witnessed this from very small companies to larger companies. This mostly happen due to bad management and carelessness, but sometimes also because of naughty job protection tactics...

If you've never heard of the bus factor, then take a look at my article... ;-)

That's all folks!

I'm really interested to hear about what you think of this newsletter. If you have remarks, ideas/articles to share, then please don't hesitate to contact me through Twitter (https://twitter.com/dSebastien). DMs are open.

If you find this newsletter interesting, then please share the link around: https://mailchi.mp/fb661753d54a/developassion-newsletter

Don't forget that you can also follow me on Medium where I currently publish my articles.

See you next time!

PS: check out my Dev Concepts books, join the Software Crafters community, the Personal Knowledge Management community, and come say hi on Twitter!
Discuss on TwitterEdit on GitHub