Wednesday, December 26, 2018

Hot reloading in Node.js

While experimenting with Node.js, I was writing a small webserver to see how the things assembled together. Then I noticed that, each time I made a change in any file, I had to stop the Node server with Ctrl+C, and then restart it back again.

Obviously there’s an easier way. The nodemon utility is a direct replace for node command, and watches all files to reload the Node server automatically. Huge time saver, and very well done.

I installed it as a global NPM package, so I can promptly use it anywhere.

Thursday, December 6, 2018

Wikipedia Templates, using React and TypeScript

I’ve been testing out React recently with great joy. The ability to grow a web application with components is really good, so much I was able to refactor an old application, a Wikipedia template generator, making it easier to mantain while increasing its complexity, becoming multi-language.

First I started writing ES6 JavaScript, but soon TypeScript caught my eye. My previous experience with TypeScript was a bit traumatic, since it involved the awful Angular 2, but after an initial struggling to make everything work, I can say that I can’t imagine a large scale project written without the aid of TypeScript.

I struggled with some things like HTML5 routing, which seems to be a pain to deploy, so I just used HashRouter. Also, the deployment to gh-pages branch is neatly made with gh-pages utility. Also, I used Redux in a very simple way; I’ve seen overengineered examples that put me off at first, but Redux itself is very simple, and I ended up choosing it instead of MobX. I used hooks from the upcoming React 16.7, and I believe it will completely change the way React components are written, it’s really different.

The Wikipedia Templates project is open source and it’s hosted on GitHub. The project isn’t ready yet, but the basics are done, and I plan to grow it as I have time.