Why I'm not using Google's closure compiler
Table of ContentsSkip to article content
Originally published as a gist
tl;dr: Closure compiler makes little to no sense outside of Google's ecosystem.
This article has made several rounds on Twitter and many people have asked: Why aren't more people using Closure? There are many reasons for that.
There's basically none.
- How do I set up a project to compile my application?
- How do I properly process the multiple modules my application has?
- How do I include/process third-party modules?
- How do I bundle stuff?
All these are unanswered.
Let's download the app then. There could me more info.
To run this you need a library you don't need
The README for the compiler has this nugget:
If you're using globs or many files, you may start to run into problems with managing dependencies between scripts. In this case, you should use the Closure Library. It contains functions for enforcing dependencies between scripts, and Closure Compiler will re-order the inputs automatically.
If you follow the link, this is the page you land on:
I want to handle my dependencies, not have a UI library. Maybe they refer to ClosureBuilder? I have no idea.
Let's maybe run it?
I have some code in my app that consists of multiple modules, relies on some third-library code (
node_modules) etc. The entry point is
How do I run it so that it generates code I need to run my app in the browser?
However you run it, it only produces some minified code that:
- Doesn't include any dependencies (except those directly in the folder)
Generates code that throws a
require is not definederror in the browser
At this point I'm ready to give up because, well, I already have my sweet set up that handles everything, transpiles, and compiles, and minifies, and bundles all code.
ADVANCED compilation modules may pollute your console output with mutiple warnings or errors that are also not helpful in the least.
In (small) conclusion
Google's Closure compiler makes no sense outside Google infrastructure. When you have set up everything the Google way and there are people to help you along as you run into problems, you're ok.
When you're alone (as most devs are), you will either spend an unknown number of hours going through error-messages, disassembling the setups of other projects (ClojureScript, Angular 2)...
Or just use the tools which you kinda sorta can setup without going insane