rules_closure
rules_closure copied to clipboard
JsChecker should check global symbols
If a closure_js_library
has a strict language, then JsChecker's strict dependency checking should also apply to global symbols—not just goog / es6 namespaces. For example, if I say doodle = 6;
then an error should be thrown if my library does not depend on a rule that defines var doodle = ...;
. Either as source code or externs.
Furthermore, we should enforce a strict ordering. If I have multiple .js
files in a single library rule, an error should be thrown if they share globals, if and only if they don't use namespaces (i.e. don't call goog.provides
.) In other words, we enforce that the ordering within srcs
be undefined for files without namespaces. This forces the user to either: a) adopt namespaces; or b) write really precise build rules that correctly model the relationships between files.
Implementation: For each defined symbol in both srcs and externs, add a global:foo
line to the library-provided.txt file. Then validate referenced symbols against those, using the existing JsChecker infrastructure. Easy peasy.