Open SachaMorard opened 4 days ago
Ok, I have played a bit with the amplitude-component. If I use wasm32-wasip2 as target, some slight Cargo.toml wrangling, and Rust nightly, it just works without adaptation.
I'm not sure what our stance is on Rust nightly? For me nightly seems to work better than stable, at least for WASM.
Ok, I have played a bit with the amplitude-component. If I use wasm32-wasip2 as target, some slight Cargo.toml wrangling, and Rust nightly, it just works without adaptation.
Can you describe the changes needed in Cargo.toml ? Otherwise, regarding nightly, (and wasip2), I guess as long as stuff doesn't break, lets go for it!
Why was the decision made initially to download wasi_snapshot_preview1.reactor.wasm
manually instead of including it directly as a dependency in Cargo.toml
?
Was there a specific limitation or compatibility issue that led to this approach? Understanding the original reasoning might help us avoid potential pitfalls.
I would suggest taking a loot at wasmtime's wasi-preview1-component-adapter-provider
crate, we could integrate that into the build process (like using Rust build.rs
"build script"):
// build.rs
use wasi_preview1_component_adapter_provider::WASI_SNAPSHOT_PREVIEW1_REACTOR_ADAPTER;
fn main() {
std::fs::write(
"wasi_snapshot_preview1.reactor.wasm",
WASI_SNAPSHOT_PREVIEW1_REACTOR_ADAPTER
).expect("failed to write bytes to file");
}
And maybe later get the whole component building into a dedicated tool (and integrate later into the future edgee
CLI?), so we wouldn't have to ask component developers to "manually" write the wasm-tools
command
Question @SachaMorard
Why was the decision made initially to download
wasi_snapshot_preview1.reactor.wasm
manually instead of including it directly as a dependency inCargo.toml
?Was there a specific limitation or compatibility issue that led to this approach? Understanding the original reasoning might help us avoid potential pitfalls.
Unfortunately, I don't know. I'm not the one who built the first component ;)
I would suggest taking a loot at wasmtime's
wasi-preview1-component-adapter-provider
crate, we could integrate that into the build process (like using Rustbuild.rs
"build script"):// build.rs use wasi_preview1_component_adapter_provider::WASI_SNAPSHOT_PREVIEW1_REACTOR_ADAPTER; fn main() { std::fs::write( "wasi_snapshot_preview1.reactor.wasm", WASI_SNAPSHOT_PREVIEW1_REACTOR_ADAPTER ).expect("failed to write bytes to file"); }
And maybe later get the whole component building into a dedicated tool (and integrate later into the future
edgee
CLI?), so we wouldn't have to ask component developers to "manually" write thewasm-tools
command
Ok for the rust components, but what about the js/python/go/... components?
I'm not sure what our stance is on Rust nightly? For me nightly seems to work better than stable, at least for WASM.
I assume that using Rust nightly to build a component requires the same Rust version for the proxy, right?
I don't think so, the component doesn't even need to be based on Rust at all.
Even with something like ./edgee component build
? ;)
The Rust version used to build a Rust-based component is completely unrelated to the Rust version used to build Edgee CLI even when using edgee component build
since there's no interaction at ABI-level between the two (or not even Rust binary code at all in general if using JS or Golang-based component), the only interfacing done is at the proxy with WASM Component which has its own ABI, so you could build a Rust component using Rust nightly and another one with Rust 1.80.0 if you really want to and it would still works :)
From a developer experience (DX) point of view, the ideal would be NOT having to install Rust locally to build and run a new component in Go, JS, Python, etc.
Ideally, you just brew install edgee
and then edgee component create/build/run
without having to worry about Rust or wasi_snapshot_preview1.reactor.wasm
.
Would it be possible to include the .wasm file directly in the edgee
binary? it's only 54KB, right?
So some updates:
So in conclusion: I think the discussion about nightly will be irrelevant very soon.
We could use the crate i mentioned earlier in the edgee crate to include the .wasm file into the final executable
Description
Currently, to build an Edgee WASM component, we need to download wasi_snapshot_preview1.reactor.wasm manually.
Investigate the current build process and identify potential optimizations.
Explore the possibility of adding wasi_snapshot_preview1.reactor.wasm as a direct dependency in Cargo.toml ?
Implement any feasible optimizations to streamline the build process.
Additional Context
This improvement will help streamline the build process, making it more efficient and user-friendly, especially to be prepared for Edgee component registry.
References
Our components repos are: