fat/smoosh — pull request #23 by ThibWeb (2014-10-15 00:01:03+00:00)
Title: Fix missing ending semicolon in UglifyJS output

When files processed with smoosh (UglifyJS) are concatenated to other files, there may be a bug because of a missing semicolon at the end of the compressed output. I encountered this problem when using [ded/domready](https://github.com/ded/domready)'s minified version, which has been created with smoosh.

- The exact error is: `TypeError: (intermediate value)(...) is not a function`.
- Here is a related [SO question](https://stackoverflow.com/questions/20307462/js-cant-combine-lib-files)
- Here is [an archive of the issue in UglifyJS 1](https://web.archive.org/web/20130319222210/https://github.com/mishoo/UglifyJS/issues/126) (quite long, but very informative of the pros & cons of adding the semicolon).
- Here is [a fiddle](http://jsfiddle.net/5sxsk147/) which demonstrates the error with the smoosh output of [ded/domready](https://github.com/ded/domready) + some example code. The fix is also demonstrated.

The fix is directly taken from the UglifyJS [source code](https://github.com/mishoo/UglifyJS/blob/master/bin/uglifyjs#L257). It has to be taken care of in smoosh's code too because smoosh directly uses the UglifyJS v1 API. In UglifyJS, the semicolon is also added after the [gen_code(ast)](https://github.com/mishoo/UglifyJS/blob/master/bin/uglifyjs#L315) call.