cloudius-systems/osv-gui — pull request #107 by dzautner (2014-10-01 13:02:03+00:00)
Title: Changed the applications module system to CommonJS

This pull request changed the module system in the application to CommonJS.

Up until now, the way we have managed modules in the application was inserting them to a global object named OSv in the following format: OSv.NAMESPACE.MODULE.

While this method worked until now, it came with the price of a complex Makefile, where the dependency management was done by hand and introduced new bugs and regressions once in a while.

This problem is solved by using r.js to manage the dependency tree for us.

Other than this, CommonJS introduces more advantages:

* Less robust syntax

The CommonJS syntax is much clearer and simpler, saving a lot of boilerplate every time a module is to be declared.

* A standard in the JS community

CommonJS has become the standard in the community, changing to CommonJS based module system will help new contributors.

* Embedded optimization and minification in the build system

The new build system, r.js, uses Google Closure Compiler to optimize and minify the application, leading to a smaller compiled file and a faster application.

* Syntax check in build time

r.js runs a basic syntax check during the build time, saving the developer from small mistakes before in build time

The new module system assumes java is installed on the client, but considering it is already a dependency in the main OSv repository, it should not be a problem.