bazelbuild / bazelbuild/bazel

`visibility` attr should allow more concise syntax

Open
#17,150 4 comments 0 reactions 0 assignees View on GitHub
not stale P4 team-Loading-API type: feature request
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### Context
Currently, when specifying visibility for a target, you need to use an oddly verbose syntax ([spec](https://bazel.build/concepts/visibility#visibility-specifications)):

> - `//foo/bar:__pkg__`: Grants access to `//foo/bar` (but not its subpackages).
> - `//foo/bar:__subpackages__`: Grants access `//foo/bar` and all of its direct and indirect subpackages.

Here at Stripe, most engineers don't remember this syntax, and struggle to configure visibility. This often results in users simply avoiding visibility, leading to surprising and illegal dependencies being checked into the source code, only to be discovered later.

### Proposal

It would be more ergonomic to allow shorter patterns, consistent with target label patterns:

> - `//foo/bar:all`: Grants access to `//foo/bar` (but not its subpackages).
> - `//foo/bar/...`: Grants access `//foo/bar` and all of its direct and indirect subpackages.

Contributor guide

Open the contributing guide

Research direction

Start by reading the visibility specifications linked in the issue and compare them with the target label patterns described in the proposal. Done means visibility accepts `//foo/bar:all` and `//foo/bar/...` with the stated package-only and recursive-subpackage semantics.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.