When I was in a similar situation a couple of years ago, I seem to remember that the decision was essentially “all the more fun”!
First, I ran the script through Dojo Shrinksafe with very modest compression settings. Since it uses Rhino, it actually interprets JS and then writes out the equivalent version with syntactically valid semicolons.
From there I filed the output in Dean Edward / packer / , which (at that time, at least) was the highest compression of the library, which produce a sequentially functional output. This library requires semicolons at the input, but this was not a problem due to exiting ShrinkSafe.
(Please note that this is from memory, and I have not tested it recently, but there are no reasons why the principle should no longer contain. If ShrinkSafe does not insert a semicolon for you, there may be some other JS preprocessing tool who will automatically do this? The module, of course, is the fact that the semicolon insert is not 100% deterministic).
source share