FR: allow modules to define aliases for extensions #25112
Labels
area-Bzlmod
Bzlmod-specific PRs, issues, and feature requests
P2
We'll consider working on this in future. (Assignee optional)
team-ExternalDeps
External dependency handling, remote repositiories, WORKSPACE file.
type: feature request
Description of the feature request:
Today, a problem module extension owners have is its very difficult to refactor or grow the APIs for their module extensions. Effectively, they are locked into the
(path, name)
they initially choose. Trying to refactor an extension means either (a) changing the path (which breaks dependencies), or (b) using a new path (and then neither extension can see info about the other, even though they do the same thing). Similar problems occur if trying to merge different extensions into one extension.The net effect is authors have to make the perfect choice on their first try, which is when they're least likely to do so. As an example, many modules put all their extensions in a single
extensions.bzl
. Meanwhile, the advice is to have separate files for each extension because it allows, if desired in the future, one extension to load() files generated by another.To help address this, I propose having a way for MODULE files to say that one
(path, name)
has the same underlying identity as another(path, name)
. The overarching goal is to give module and extension owners some flexibility in refactoring and growing their bzlmod-phase APIs.e.g., if I was factoring
extensions.bzl%foo
into a separate file,foo_overrides.bzl%foo_overrides
, in my MODULE file I would put:Under the hood, Bazel would transparently give
use_extension(":extensions.bzl", "foo")
the internal identifier offoo_overrides.bzl%foo_overrides
. And thus when a user does:They merge into the same bzlmod thing (not sure on what the internal terms are), such that in the module_extension implementation, it sees the calls from both usages.
I don't know much about how things work internally, so don't want to proscribe much.
I think the first-order use case is:
Second order:
cc @Wyverald
Which category does this issue belong to?
External Dependency
What underlying problem are you trying to solve with this feature?
No response
Which operating system are you running Bazel on?
No response
What is the output of
bazel info release
?No response
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.No response
What's the output of
git remote get-url origin; git rev-parse HEAD
?Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
No response
The text was updated successfully, but these errors were encountered: