-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Optional" and "nodep" external dependencies #25214
Comments
cc @meteorcloudy @fmeum for thoughts |
…to elemental2 and not pollute the dep graph in Bzlmod. This is related to issue bazelbuild/bazel#25214. PiperOrigin-RevId: 723713089
This should be doable today: Module A can provide a module extension that creates a repo with the "protected" targets and fail if any module not called B uses that extension. I'm using that pattern for the This does require more effort, but for the use case in the linked commit, that would seem reasonable. I'm worried of optional deps becoming too common if it's too easy to add one. |
I do think we should add no-dep deps though and also like the |
I actually encountered the same issue a few times and had similar ideas. So in general, I agree we should do it. Maybe we could achieve this by adding one
I also agree this has to be backported to Bazel 7 so that future modules still work with Bazel 7.x |
While this is quite ingenious, I see a couple of problems with it: 1) it requires protected targets to be moved to a repo generated by a module extension, which can be quite the hassle for development (even if you use
That's a very valid concern. While I wouldn't say it trumps everything else, it does require the use cases to be very convincing. Also it makes it all the more important that we resolve some big questions surrounding optional deps -- in particular, what happens when the dep is not there? It's fine for the visibility use case, since an invalid label in the visibility spec is simply ignored. But what happens to re nodep deps, I agree with Yun that |
You could keep the protected targets in place, open up their visibility to the extension repo only and then add aliases to the extension repo. Only the consumer would need to change their reference to the extension repo.
Do you have an example for this? If you trust another module enough to carve out a visibility exception for it, why would you need to further restrict this on a more granular level? After all, that module might as well declare a publicly visible alias for your target to circumvent that. This sounds like it would only come up in a corporate monorepo-turned-polyrepo based on |
This gets out of hand fast. If there are multiple targets, you'd need multiple aliases; if entire packages have Either way, this setup suffers from poor usability (again, for a good reason). I'm reminded of the "just write a trivial module extension" advice we had early on, and how
I don't have an example handy. I don't think "trusting another module" necessarily means "trust all of it"; the other module could be published by the same author, and they want granular visibility specs for this link just as they'd want granular visibility specifications for packages inside the module.
Well, yes, but the same could be said for another package. If you think of this other module as something the same author controls, it sounds less adversarial.
I wouldn't say that's the only use case where this is useful (see above). And also, I don't think we've been discouraging the case, rather that we haven't had a good answer for the visibility problem there. |
…to jsinterop-generator and jsinterop-base and not pollute the dep graph in Bzlmod. This is related to issue bazelbuild/bazel#25214. PiperOrigin-RevId: 724049143
…to elemental2 and not pollute the dep graph in Bzlmod. This is related to issue bazelbuild/bazel#25214. PiperOrigin-RevId: 724500733
small update -- I'm working on a design doc and a proof of concept implementation. Version resolution with optional deps is turning out out to be much more complex than I anticipated. Nevertheless, nodep deps should be fairly good to go. I think we'll probably try to ship nodep deps before optional deps. The doc should be out by tomorrow. |
These are two related feature requests for external dependencies.
//visibility:public
, which is less than ideal.protobuf
up intoprotobuf-core
and the various language-specific bindingsprotobuf-<LANG>
. The language bindings need to maintain version parity with the core runtime, but we don't wantprotobuf-core
to depend on all possibleprotobuf-<LANG>
modules (which would defeat the whole purpose of splitting).repo_name=""
?)The text was updated successfully, but these errors were encountered: