I have a 'modular' backend where two different services/repos are serving up client side js to the same client. I need the JS from both sources to be minified and work together as one is dependent on the other. They are currently minified independently so the js breaks. edit: To clarify the minification is aggressive and is minifying all names.
Asked
Active
Viewed 114 times
2
-
Minified js should not break the code in any way, since it preserves accessible variable names. Please show the error message and relevant code. – tcooc Oct 25 '16 at 17:14
-
1As long as you don't use the advanced setup, you really shouldn't have errors – Bálint Oct 25 '16 at 17:16
-
1@Bálint advanced setup is being used. – joemillervi Oct 25 '16 at 17:21
-
Why? Just put it to simple – Bálint Oct 25 '16 at 17:22
-
@Bálint it has to be inlined and super small it is for GA stuff – joemillervi Oct 25 '16 at 17:51
-
Can you concatenate the 2 files? – Bálint Oct 25 '16 at 17:52
-
@Bálint no they are from different services / teams. :) – joemillervi Oct 25 '16 at 17:54
-
Then you need to use the simple setup. – Bálint Oct 25 '16 at 17:58
-
How often does code from one script need to call into the other script? If it isn't too often, with Closure Compiler, you can add `@export` on the functions that are in one script but called from the other, and enable the `--generate_exports` flag. There are other approaches that might work but this is probably the simplest. – Tyler Oct 26 '16 at 00:06
1 Answers
3
Compile them together. You can use the code splitting flags to direct distinct inputs into unique output files. You will get maximum renaming with this method.
If you absolutely cannot compile them at the same time, you'll have to eliminate most of the benefits of ADVANCED mode and create externs and exports so that the scripts can coordinate. In this way they are both external to each other.

Community
- 1
- 1

Chad Killingsworth
- 14,360
- 2
- 34
- 57
-
This is the conclusion I came to. Examples listed down the page here: https://developers.google.com/closure/compiler/docs/api-tutorial3 – joemillervi Oct 26 '16 at 21:05