geoadmin/mf-geoadmin3 — pull request #12 by elemoine (2013-06-14 08:59:14+00:00)
Title: Build js with Closure Compiler

This PR adds support for building the js code using the Closure Compiler in SIMPLE mode, and for auto-loading of js scripts in DEBUG mode.

The approach taken is the following:

- One Angular module per file/script
- One Closure module per Angular module

There are three types of modules: the "main" module, the "features" modules, and the "technical" modules.

The "main" module (the entry-point module) is "ga". The "main" module depends on "feature" modules: "ga_map", "ga_backgroundlayerselector", etc. The "feature" modules depends on "technical" modules. For example "ga_map" depends on "ga_map_directive".

This is what the "main" module looks like:

```
(function() {
goog.provide('ga');
goog.require('ga_map');
...

angular.module('ga', [
'ga_map',
...
]);
})();
```

For consistency reasons the Angular module and the Closure module have the same name. And because the Closure Compiler considers module names including dashes as invalid underscores are used.

With one Angular module per file the scripts can be loaded in any order in debug mode – the evaluation of a script doesn't depend on the evaluation of other scripts.

The purpose of Closure modules (goog.provide and goog.require) is the auto-loading of scripts in debug mode.

By making non-namespaced Closure modules (no dots in the module names), and by calling goog.provide from within "self-executing" functions, the Closure Compiler in SIMPLE mode removes calls to goog.provide entirely. That's what we want – we certainly don't want to add objects to the global "window" object.

Note that I've added an index_prod.html file. This is temporary. I need to find a better way, this will be done in a separate PR.

Please review.