rules_closure
rules_closure copied to clipboard
Disable default externs
Closure Compiler by default is --env=BROWSER
which causes 28,606 lines of @externs
code to be added to each compilation. This has a four second impact on compilation time. It can't really be optimized away because externs aren't namespaced. So we'd be better off if we:
- Only load es{3,5,6}.js by default, depending on the input language.
- Define a
closure_js_library
for each browser externs file, e.g.//closure/externs/browser:html5
- Update
//closure/library
to have the minimum number of deps on these externs. Break hard edges if possible. For example, if only one .js file in Closure Library depends on the giganticwebgl.js
externs, then maybe that part of Closure Library should be broken out into a separate build rule. - Define a combined
//closure/externs/browser
rule for the lazy, that basicallyexports
all the libraries in the package. Adding that as a dep will be equivalent to saying--env=BROWSER
. - Repeat for contrib externs, e.g.
//closure/externs/contrib/angular:v1_5
, as per #51. - Write a
file_test()
that checks the directory listing of externs.zip so Closure Rules maintainers integrating a compiler new release can be informed when they need to update our externs rules.
This is a breaking change that deviates from the design chosen by the Closure Compiler team. I think this is a good idea for two reasons:
- It makes compiles go four seconds faster.
- It will teach new users about externs.
If the user gets an error saying, "hey! document
is undefined. you probably want to depend on @io_bazel_rules_closure//closure/externs/browser:window
!" Then he's going to wonder what externs are. He'll read the file. See how Closure rigorously defines type information for everything—even code that isn't in the compilation. And then he's going to begin to understand the Closure Compiler and why it is good.
Blocked by: #80