Comments (6)
With cargo-component
0.9.0, it now componentizes any core module that has bindings type information present (where previously it required [package.metadata.component]
to be present in Cargo.toml
for it to componentize).
Please review the release notes as there were quite a few breaking changes relating to bindings in that release.
from cargo-component.
Could you provide the build error you're encountering?
from cargo-component.
The guest project is missing the package metadata that marks it as a component project; currently cargo-component
does not attempt to componentize just any wasm
target outputs.
If you add [package.metadata.component]
to your guest's Cargo.toml
, does that workaround the issue?
from cargo-component.
Could you provide the build error you're encountering?
Ah sorry I forgot to add this 🤦
I get an error from wasmtime loading the wasm module:
thread 'main' panicked at host/src/main.rs:27:92:
called `Result::unwrap()` on an `Err` value: failed to parse WebAssembly module
Caused by:
attempted to parse a wasm module with a component parser
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
If you add
[package.metadata.component]
to your guest'sCargo.toml
, does that workaround the issue?
It does! However, would cargo component be willing to change this behaviour and add the component metadata no matter if the [package.metadata.component]
is present?
The reason being is that:
-
If someone is compiling their cargo crate with
cargo component build
, then they'd definitely have the intention of building it as a wasm component. -
I'm building a runtime which uses wasmtime, and users of my runtime will compile their modules as cargo components. However telling them that they need to add an empty
[package.metadata.component]
to get it working, despite them already using cargo component is just one extra gotchya that seems not too necessary?Ideally, they could just use
cargo new
, and then addcrate-type = ["cdylib"]
, and my macrothalo::export_aggregate!(Foo)
and it should work withcargo component build
from cargo-component.
Why wouldn't they use cargo component new
which sets both the crate-type
and adds the required [package.metadata.component]
section? As a bonus, it also gives them the opportunity to configure different cargo component values with arguments (e.g. package name, editor, vcs).
Alternatively, they could just use a template you create so you can embed your thalo
macro call for them.
from cargo-component.
Why wouldn't they use
cargo component new
It would indeed be nice, however it also generates the wit directory, and adds cargo-component-rust to the dependencies, etc. These things aren't needed in my case. I don't want them to be concerned with wit files or anything like that, as my library handles it all.
Alternatively, they could just use a template you create so you can embed your thalo macro call for them.
Also a nice idea, but I wanted to keep things as simple as possible for them. So it's just a regular rust crate, and they need thalo
as a dependency. The only complicated thing would be that they need to add the crate-type, but that's just a rust thing with wasm.
As I mentioned, isn't it a little strange to have the behaviour of the cargo component build
silently not generate a wasm component if the meta is not defined?
If someone uses the cargo component build
command then I'd say it's safe to assume they're definitely expecting the resulting wasm to be a valid wasm component
from cargo-component.
Related Issues (20)
- `cargo component check --workspace` should not generate bindings for workspace members without `[package.metadata.component]` set HOT 2
- `cargo-component` is not acquring a file lock for componentization
- Document the schema of the cargo-component Cargo.toml configuration HOT 1
- Hello world example fails when project name contains underscore HOT 1
- Add a `cargo component serve` subcommand that uses a default runner of `wasmtime serve`
- wit pubilsh --init fails to register the WIT package to wa.dev, while it successfully create a pacakge on the registry HOT 4
- Build fails with 'failed to create a target world for package ...' HOT 2
- Use something like nightly.link or a non-re-published release to avoid excess notifications
- Build error: `error: string size out of bounds (at offset {offset})` HOT 10
- Additional `import`s in generated component HOT 2
- Resource Static Methods Cause Build Failure When Imported HOT 5
- Wit package name/version validated against registry publishes
- Some wasi imports added per default into wit HOT 2
- cargo install cargo-component error HOT 5
- Compile error when installing cargo component HOT 7
- Minimum Supported Rust Version (MSRV)
- Bindings are sometimes incorrectly generated type + `Borrow` suffix vs `&` type HOT 2
- `cargo component add` not producing runnable/usable binaries
- Cargo Component install give error in RPI 4 (ARM CORTEX-A72) HOT 3
- Update to `-S cli` instead of `-S common` for wasmtime commands
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cargo-component.