component-docs
component-docs copied to clipboard
Improve ergonomics of Rust examples, re-enable use of published packages
This issue arguably shouldn't go here, but currently UX issues in upstream tooling is making the Rust
The goal is to revert this reverted functionality -- we want to be able to use published WIT packages but there are a few issues stopping us:
cargo-componentdoes not configure/patch wherewkglooks for deps (the target kind) when configured inCargo.toml(i.e. we should be able to specify thatdocsis a known package w/ a known registry)cargo-componentcurrently does not properly resolve targets w/ multiple worlds even ifwkgis configured (via it's global config file)wkgshould be able to use local fconfig
There are at least a few ways to solve this issue:
- Update
cargo-componentto perform the patching of registries for namespaces before usingwasm-pkg-toolsfunctionality - Update
wkgto prefer local config files and include one in the tutorial code - Update the guide to get users to configure
wkgglobal config before attempting usage.
A somewhat hidden requirement/sidequest to this issue is that we need more cargo-component/wasm-pkg-tools maintainers. The current functionality is fantastic for these tools, but the UX needs to be polished just a bit.
So after discussing this with @macovedj , it looks like to make this work we'll need to:
- Introduce a section on configuring
$HOME/.config/.wasm-pkg/config.tomlto ensurecargo componentcan find thedocsnamespace via includedwkgcode - Using
cargo component newlike specified in his comment
There are other options here, but this is the most... tooling-aligned option (i.e. what currently works).
Some other options:
- Fix/Improve
cargo componentso that it use the--registryoption (unlikepublish,cargo component newdoes not use the--registryoption
The ideal solution is almost certainly updating cargo component to take a registry option (and use it) like ghcr.io/bytecodealliance (it should be able to expand this into a registry + namespacePrefix, worst case two separate flags)
Note that cargo component publish and cargo component add already take and use the --registry flag
hey @kate-goldenring any opinion on which direction to go in here
To add to this, after some discussion we're thinking this could probably go on the Language support page, and be linked to from every language.
Something like "To run cargo component new, you'll need to have your global wkg configuration in place. See xxxxx to set it up" (maybe in an alert?).
If we go with this approach we can skip fixing cargo component at present and re-add the WIT-only component driven workflow