google / google/closure-compiler
i18n makes the compiler painfully slow
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 1.2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 6
Description
We're using Closure Compiler to build a moderately-sized codebase, via plovr. Compiling it all once takes about a minute and a half, which is painful but not unbearable.
Unfortunately we have 40 locales (and counting), and so we compile the same codebase once _for each locale_, with `goog.LOCALE` different each time. This bumps the compile time by an order of magnitude, up to 12+ minutes.
It strikes me that 99% of the work is being repeated 39 times, with only a small bit of inlining actually varying between compilations. Is there _any_ way to deal with this more cleverly? Do a partial compile, clone the result 40 times and finish compiling for each locale? Reuse the parse trees for the input files, at the very least?
I've dug through the Java API but if this is meant to be possible, it's not obvious how. I did find `Compiler.processDefines`, which claims:
```
/**
* Reprocesses the current defines over the AST. This is used by GwtCompiler
* to generate N outputs for different targets from the same (checked) AST.
* For each target, we apply the target-specific defines by calling
* {@code processDefines} and then {@code optimize} to optimize the AST
* specifically for that target.
*/
```
...which _sounds_ like exactly what I want, but I never got it to work and it seems to have finally been removed last month.
Contributor guide
Assessment
This issue has not been assessed yet.