bazelbuild / bazelbuild/rules_closure
JsChecker should check global symbols
- Dominant language
- Java
- Stars
- 159
- Forks
- 111
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
Assessment
This issue has not been assessed yet.