Tuesday, February 3, 2015

Switching from Angular to Aurelia

We chose to develop in AngularJS over a year ago. At that time, the two main contenders where Angular and Backbone. Angular seemed to be less hassle in providing us what we needed using less code. An easier and consistent framework that included a standard set of modules, unlike Backbone. Angular was great. It was the new flavor of the month. It was rich and powerful and seemed to be the answer to all our problems.

A year later, and find things are not so nice and shiny. Don't get me wrong, AngularJS is still a great framework. But once you start pushing it to more than using some basic directives with an ng-repeat, it starts cracking. The scopes are a bit unpredictable and dynamic DOM injection is nearly impossible when used outside the templates.

There is a reason the team is throwing out the code and starting from scratch. Yes, the biggest disappointment was hearing that the update to Angular 2.0 was going to require a re-write of the current Angular 1.3 code based projects. This is a good thing and bad. The good side, is that the team saw that the concept of Angular was so popular that people have pushed it to its limits and instead of duct taping the framework, have decided to take the direction of the framework and make it solid. The bad, of course, is that developers using the framework know their code will be a waste in about a year or two.

Then a bit of news caught our attention. One of the Angular 2.0 developers, Rob Eisenburg, left the team to fork his own version of the concept. He called it, Aurelia. It, like Angular 2.0, also uses ES6. The preview code is already available for download and looks to be very promising.

The decision to switch all current projects to Aurelia came for two reasons, both looking at the future of the code. The first is that the framework is available now and will be around for quite some time. Second, if Angular 2.0 does seem to be better once released, switching a project from Aurelia to Angular 2.0 seems to be a smaller step than from Angular 1.3.

We found the biggest obstacle is documentation, when switching our projects from Angular 1.3 to Aurelia. While there is documentation, it is very new and some advanced features are available but not yet documented. The documentation only shows a setup using jspm, SystemJS, and Gulp. Our Angular projects are using Bower, Grunt, and RequireJS. I can see a good reason to change from Grunt to Gulp -- easier to configure and use. I can also see reasons to switch from RequireJS to SystemJS. But there was a problem switching from bower to jspm. While jspm helped automate the configuration process for you, it was not able to automatically download the Bootstrap LESS files like Bower did.

In the end, everything switched over just fine and working out better than planned. It would be nice to have the code less broken up. Maybe a handful of consolidated javascript files. It would make for an easier SystemJS configuration.

For those of you wanting to use a similar setup, we have the source code up on Github, click here to download.


No comments:

Post a Comment