Trunk build fails for the simplest example

840 Views Asked by At

I am trying to learn to use Trunk and Yew so I tried to follow a very simple example of Trunk, created a neatly empty index.html in the root of my rust project (just the main tags and made trunk build

the thing fails with: trunk build 2023-03-13T16:56:38.507326Z INFO starting build 2023-03-13T16:56:38.507905Z INFO spawning asset pipelines 2023-03-13T16:56:38.643288Z INFO building rust-frontend-example-yew Finished dev [unoptimized + debuginfo] target(s) in 0.07s 2023-03-13T16:56:38.773599Z INFO fetching cargo artifacts 2023-03-13T16:56:38.915318Z ERROR ❌ error error from HTML pipeline

Caused by: 0: error from asset pipeline 1: could not find WASM output after cargo build Error: error from HTML pipeline

Caused by: 0: error from asset pipeline 1: could not find WASM output after cargo build

There is nothing in /dist

I cannot find ANYONE in the internet with this exact error and I am at loss on why the simplest example fails. Does anyone have a clue on what I can look for?

I already installed wasm-bindgen-cli by cargo install btw.

1

There are 1 best solutions below

0
On

I had the same error when I tried to serve a combined project of lib and bin:

// src/lib.rs
use yew::prelude::*;

#[function_component]
pub fn App() -> Html {
    ...
}
// src/main.rs
use project::App;

fn main() {
    yew::Renderer::<App>::new().render();
}
#Cargo.toml
[package]
name = "project"
version = "0.1.0"
edition = "2021"

[[bin]]
name = "bin"
path = "src/main.rs"

[dependencies]
yew = { version = "0.21.0", features = ["csr"] }

<!doctype html>
<html>
    <head>
        <link data-trunk rel="rust" data-bin="bin" />
        <meta charset="utf-8" />
        <title>Yew App</title>
    </head>
    <body></body>
</html>

The index.html file needs <link data-trunk rel="rust" data-bin="bin" />

and I had to update the wasm-bindgen-cli:

cargo install -f wasm-bindgen-cli