cargo-component icon indicating copy to clipboard operation
cargo-component copied to clipboard

Document `package.metadata.component` configuration

Open vwkd opened this issue 1 year ago • 4 comments

I'm looking for documentation on package.metadata.component configurations that can be specified in Cargo.toml.

Currently, cargo-component-bindings only documents the [package.metadata.component.bindings] table.

The default Cargo.toml added with cargo component new --reactor foo contains these tables.

[package.metadata.component]
package = "component:foo"
# ...

[package.metadata.component.target]
path = "wit"
# ...

[package.metadata.component.dependencies]
# ...

It seems the complete set of options are documented in the code.

Can the documentation for all package.metadata.component configurations be made accessible somewhere?

vwkd avatar Nov 19 '23 10:11 vwkd

Thanks for opening this issue!

I think it makes sense to create an mdBook for cargo-compnent that both documents the settings in Cargo.toml fully and also has HOWTOs for various ways of creating components; we could serve it from GitHub pages.

I will hopefully have time to do that in December, but otherwise contributions are always welcomed!

peterhuene avatar Nov 23 '23 19:11 peterhuene

I'm also wondering what's the difference between package.metadata.component.dependencies and ~~package.metadata.component.dependencies~~ package.metadata.component.target.dependencies. The former is modified using cargo component add, but unless I add the dependency to the latter I get package not found in cargo component build :thinking:

tomasol avatar Jan 25 '24 09:01 tomasol

@tomasol sorry, do you mean the difference between package.metadata.component.target.dependencies and package.metadata.component.dependencies?

The former is for the dependencies of the world you're targeting via a local WIT package (i.e. not referencing a registry package). The dependencies are expected to be WIT packages.

The latter is for dependencies on other components (either by path or by registry package). Whatever these components export are automatically turned into imports and merged with the target world for bindings generation.

Both can be added to Cargo.toml with cargo component add, but the former requires the --target option.

peterhuene avatar Jan 25 '24 21:01 peterhuene

@peterhuene Sorry for the confusion, yeah that's what I meant (I've edited the comment). Thanks for the explanation, the difference is now clear.

tomasol avatar Jan 26 '24 18:01 tomasol