There's nothing great or particularly amazing about Angular and its build processes
Jan
21
2018
23:30
published in:
Originally published as a gist
There's nothing great or particularly amazing about Angular and its build processes.
Everything Angular does is fighting against its own architectural decisions. On a high level it's like this:
- We write in Typescript, we need to compile to Javascript
- Typescript cannot compile our templates because they are custom templates
- We need to compile templates
- Typescript compiler barfs at some of our code, we need to fix the code, or the compiler, or both, or hack in between them
- The resulting Javascript is hundreds of kilobytes larger than any competition.
- We need to somehow reduce the size
- Let's throw Google Closure Compiler in
- It cannot reliably process JS code produced by Typescript compiler (side note: it cannot reliably process any JS code outside of Google's 'goog:module' and Closure Library even with "SIMPLE" optimisations)
- Let's create a separate tool, Tsickle, that will help convert TypeScript code into Closure-compatible Javascript code. The tool is a hack, because Typescript compiler doesn't expose compiler-as-a-service
- And also let's do "Ahead-of-time" compilation on templates etc.
- So now we produce marginally less code. It takes insane amounts of time to not only build, but even rebuild and do incremental changes
- Oh, let's take Google's Bazel! It promises to be so fast!
- Only doesn't know anything about compiling Typescript.
- So we write new rules (aka configs) for typescript, for typescript code server, and a bunch of other stuff.
-
So now we will have:
- Typescript compiling
- Tsickle converting
- Templates compiling
- Closure Compiler compiling
- Bazel orchestrating
So, nothing really changed (only the build chain is becoming increasingly complex and impossible to reason about), and yet "OMG Angular is so great: Google makes it possible to use it with Bazel and Closurescript instead of the circus that is Webpack and UglifyJS" 😂
Fanboys are fanboys.