Experiment on using component functionality in an ts actor:
- Build the component that exposes a
hello-world
function:
cargo component build --release --target=wasm32-unknown-unknown
- Check for the component interface is present
wasm-tools component wit target/wasm32-unknown-unknown/release/rust.wasm
- Transpile component to js
jco transpile target/wasm32-unknown-unknown/release/rust.wasm -o jco-transpile
- Import the resulting js as documented inside actor.
import { helloWorld } from "./components/rust/jco-transpile/rust.js";
- Build the actor
npm install
tsc
jco componentize -w wit -o dist/http-hello-world.wasm dist/http-hello-world.js
it fails with
failed to build actor with custom command: "Import './components/rust/jco-transpile/rust.js' in source.js is not defined as a world import