-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds visibility check to
prerender_component
.
This uses an aspect so `prerender_component` can inspect its component slices dependencies. The aspect provides the `visibility` attribute which `prerender_component` asserts on. The idea is that slices for a component _must_ be defined in the same package as the component _and_ must have private visibility. With both of these and assuming a structure where each `prerender_component` gets its own Bazel package, it should be impossible to accidentally depend on a component slice without going through the `prerender_component` reexports. This implements option 4 in [this dicussion](#40 (comment)).
- Loading branch information
Showing
4 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
visibility("private") | ||
|
||
VisibilityInfo = provider(fields = { | ||
"visibility": "Visibility of the target.", | ||
}) | ||
|
||
def _visibility_aspect_impl(target, ctx): | ||
return [VisibilityInfo(visibility = ctx.rule.attr.visibility)] | ||
|
||
visibility_aspect = aspect( | ||
implementation = _visibility_aspect_impl, | ||
# Don't actually walk the depgraph. This aspect should be directly placed on | ||
# any attributes it needs to process. Since it only needs read direct | ||
# dependencies there is no need transitive dependency processing. | ||
attr_aspects = [], | ||
doc = """ | ||
Returns a `VisibilityInfo` provider with the visibility declaration of | ||
the target. | ||
""", | ||
) |