3 ms·
It's not quite the same. It has some aspects of Google's module system in terms of de-duping (our internal version automatically splits up all code referenced i
by cromwellian 9y ago
It's not quite the same. It has some aspects of Google's module system in terms of de-duping (our internal version automatically splits up all code referenced in more than one place into a tree of synthetic modules) But Closure's optimizations go far beyond the "tree shaking" described here, which is really about pruning unused module dependencies.
Closure does pruning of methods, properties, etc at a fine grained level, moves code at a per-method level between modules, it computes whether functions have side effects and elides unused side-effect-free code, it does type-based optimizations (https://github.com/google/closure-compiler/wiki/Type-Based-Property-Renaming https://github.com/google/closure-compiler/wiki/Type-Based-P...), the list goes on and on. It's really like having GCC or LLVM for Javascript code. That's one reason why it's slow, because it does far more than the transpilers and minimizers out there.
(As many in another, GWT does many of the same things, being a fully optimizing true compiler)
- lennelpennel 9y agoI want to add that you can easily write your own compile pass for the closure compiler as well. All the optimisations described above are just compile passes.