Great Question!
I've worked with a process with similar requirements, but we took somewhat of a different approach. I realise its maybe not exactly what you're after, but would still make some recommendations:
- Make the compression/compilation part of the shipping process.(You may already be doing this, but it wasn't clear from the above).
- Compress/compile it on the development servers too. It might be a hassle for debugging/testing but you want to be able ensure the production version and test versions are as similar as possible. If you have the luxury of multiple development stages, then you could possibly compress on one of them.
- Only do the compression/compilation if it passes some sort of quality scan (e.g. jslint)
- Don't combine the modules - keep them separate. The performance benefits you will gain will be so negligible, as to be almost pointless.
- Don't change the HTML, just change the dependant modules content.
I realise its a bit different from what you were intending, but in my experience it leads to a more robust development promotion model.