Tuesday, March 20, 2012

Choosing JS build tool

Lately I was tasked to setup a JS based project together with full build and testing automation. Today I'd like to share the build and testing part, as it turned out to be quite interesting problem.

In short, we have a little JavaScript library that is designed for browsers. During build it should be packaged from source (e.g. multiple extensively documented files) to several different versions (e.g. bundled with other files, minified, etc.); ran against unit tests and validated with JSLint.

Assuming that someone would like to try this library, they might be willing to build and test it as well, so a JS-friendly technology would be a perfect hit, won't it?

Ok, so it was time for a little research on what do others use for building their JS libs. Half of the internet seems to be using Makefiles, while the other half is deep in love with Ant. To be specific, jQuery, Bootstrap, Code9 IDE were using make, while for example Dojo and Firebug were on Ant!
It's actually quite relieving that such serious projects strive for standardization even at the price of dependencies such as Java (Ant) or Linux (make).. Well theoretically you can run make on Mac too, but still that leaves Windows users out.

As much as I wanted to follow best practices, I wished I could avoid build script (be it Ant or Makefile) mixed with external Javascript code calls. Yes build had to be written in Javascript, as it was going to use all JS tooling goodness that already appeared out there, such as JSLint, UglifyJS.

There seemed no other way than just picking Jake and going with it for better or for worse.

No comments:

Post a Comment