google/traceur-compiler — pull request #702 by rolftimmermans (2014-01-24 15:25:55+00:00)
Title: New module compilation option: inline

This PR adds a new module transformer `inline` that produces very trivial module output when compiled as a single file. A module now is compiled to something like this:

```
var $__module__static_47_scripts_47_modules_47_TargetView_46_js__ = (function() {
"use strict";
var __moduleName = "static/scripts/modules/TargetView.js";
// ...
}).call(this);
```

References to the module simply become: `__module__static_47_scripts_47_modules_47_TargetView_46_js__`

As I see it is has the following advantages when compiled in single-file mode:
- friendlier for compression tools like UglifyJS and Google Closure compiler, which can rename the lengthy module names to single variable names
- does not leak information about file structure when minified (`__moduleName` is often unused and is also stripped)
- no need for a module store in the runtime (although obviously this patch does not change the fact that it's there and compressors are not smart enough to remove it when minifying)

I'd love to see the single-file output of Traceur be a little more friendlier for web-use and JS minification tools. I hope this is one step in that direction.

When I apply this change and remove the module store and url module from the runtime I can get a small sample project down from ~21KB uncompressed to ~16KB uncompressed.

Please consider this PR and let me know if there's anything I can do to improve the implementation or the test coverage.