Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Today, one can publish a
cargo-component
generated component to a registry and then add it as a dependency in anothercargo-component
project. However, the consuming component's wit will not refer to a foreign package if an interface is imported, but instead will define that interface inline. The example below should help make this clear.Given a simple component with the following wit:
That is added via
cargo-component add
to another component, we can reference it in the project that is added to like so:However, when printing out the wit of the compiled component, the
greeter
interface appears as follows:We can see that it is not surfaced to the wit that this interface is defined by the dependency. The use case I specifically am motivated by is in is docs gen so that a UI can link to the package where the type is actually defined.
These changes will produce a binary with the following wit
For the motivating use case, this would surface sufficient information for robust docgen.
Note that as it stands, in order for these changes to function properly would also require that the
wit-bindgen
branch referenced gets merged, which has the side effect of prepending the namespace to the module exposed in rust bindings, and the rust import would then look like so