Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasm-bindgen version issue #47

Open
dimitrilw opened this issue Oct 25, 2024 · 4 comments
Open

wasm-bindgen version issue #47

dimitrilw opened this issue Oct 25, 2024 · 4 comments

Comments

@dimitrilw
Copy link

I apologize for being a bit of a surface-level Rust user. I am unsure what tweaks to make to get this building so I can start playing with Leptos SSR on Fermyon Spin. Please advise.

Platform

  • MacOS 15.1
  • Spin 2.7.0
  • rustc 1.82.0
  • cargo 1.82.0

Steps taken

I simply followed the readme.

  • one-time prep:
    • spin templates install --git https://github.com/fermyon/leptos-spin
    • cargo install cargo-leptos
  • template setup:
    • spin new -t leptos-ssr my-leptos-app -a
    • cd my-leptos-app
    • spin build --up

Result

Build command failed due to version-mismatch on wasm-bindgen. Full details in pic.

image

Fix Option-1 Fails

When trying to update the wasm-bindgen dependency with cargo update -p wasm-bindgen --precise 0.2.93, it resulted in:

image

Fix Option-2 Fails

First, I did a clean walk-through of the "steps taken" section to ensure it was a clean attempt at the second option. When attempting to resolve via updating the binary with cargo install -f wasm-bindgen-cli --version 0.2.95, it appeared to update some stuff (pic).

image

However, spin up --build led to the same version error as before, shown in the "result" section's image.

@ogghead
Copy link
Contributor

ogghead commented Oct 26, 2024

Thanks for mentioning this! I ran into this recently, and was able to fix it by creating a branch of cargo-leptos that uses 0.2.95 bindgen -- https://github.com/ogghead/cargo-leptos has the branch.

I will look into upstreaming this today

@ogghead
Copy link
Contributor

ogghead commented Oct 26, 2024

Actually, it looks like someone else beat me to it 😄 so the version on their GitHub should work for you (I suspect). Can you try installing it with cargo install --git https://github.com/leptos-rs/cargo-leptos --locked cargo-leptos and see if that gets your build working?

@dimitrilw
Copy link
Author

dimitrilw commented Oct 26, 2024

TLDR: Worked. Thank you!

(but not closing issue; see bottom)

Long version:

It was a bit of a wild ride and I admit deep unfamiliarity with Rust and a bit of uncertainty why it appeared to run full recompilation multiple times.

I started with a clean template:

image

Then I issued the suggested command (cargo install --git https://github.com/leptos-rs/cargo-leptos --locked cargo-leptos ), which appeared to compile all of the template's dependencies:

image

After that finished, I ran spin up --build, which appeared to compile things three times.

image image

On the third pass, there were a ton of duplicate errors and the "look out, wasi going away" warning:

image

In the end, it finished, started serving, and was saving button clicks to the SQLite DB.

image image

I do not understand why the issuance of spin up --build appeared to have three cycles of compilation, the final one giving all the warning flags. But it worked. Thank you @ogghead . I can do some experimentation and see how things go with this setup.

Not closing issue

I am not marking this issue as closed because the method to get things working did not match the Readme. For whatever reason, when I followed the readme steps, I was building on v0.2.93. Perhaps the template requires further updating? Perhaps there is something with Spin? Perhaps there is dark magic at work. Regardless, something needs updating, even if that thing is only the readme adding a line to do the cargo command provided by @ogghead .

@ogghead
Copy link
Contributor

ogghead commented Oct 26, 2024

Glad to hear that worked! On the observation of multiple compilation cycles, I suspect this is caused because the command Spin runs to build your Leptos component is cargo leptos build --release && LEPTOS_OUTPUT_NAME=test cargo build --lib --target wasm32-wasi --release --no-default-features --features ssr which performs two builds.

Agreed that updating the README to list the command to install cargo-leptos from GitHub would be ideal -- is that something you might be interested in creating a PR for?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants