SlexAxton/messageformat.js — pull request #34 by eemeli (2014-02-07 22:54:28+00:00)
Title: Trim output size & complexity

With these changes, any real-world sized localization is likely to shrink by a huge margin. With the sort-of realistic test case I've been using, the output is now 70% smaller than with version 0.1.7. The included examples stay at roughly their current size, as they are rather minimal cases.

The main reason this is possible is by including a small set of utility functions in the generated code, which then allows for removing duplicate code, making some of the inner function calls into strings, inlining all the generated local variables, and some other minor changes.

I've also minified the output slightly (including all the simpler locales), but the output should still be at least as readable as it was before. Programmatically minifying it can probably shave another 10-20% from it, but at the cost of legibility.

The utility functions are included in two places; a new file `lib/messageformat.include.js` and near the top of `lib/messageformat.dev.js`. They differ only in amounts of comments and white space, to make the latter easier to read.

I had to change a couple of the test cases slightly, as they were referring to code that now gets called from a different function. All tests should be valid for all commits.