workers-rs icon indicating copy to clipboard operation
workers-rs copied to clipboard

fix: Update leptos template so that it works OOTB

Open natecox opened this issue 5 months ago • 6 comments

The current leptos template does not work out of the box due to an issue with wasm-bindgen. This PR returns it to a working state via a workaround discussed in the below linked issue by:

  • Bumping workers-rs to 0.6 in Cargo.toml
  • Disabling wasm-opt
  • Adding a call to pub(super) fn __wasm_call_ctors();
  • Adding a start fn to lib.rs

Resolves #772

natecox avatar Aug 16 '25 22:08 natecox

Thanks for fixing this, although I believe the wasm-bindgen issue has now been fixed upstream with https://github.com/wasm-bindgen/wasm-bindgen/pull/4562.

So the question then is if we still need this if that fix goes out this week and we can release to that?

I would at least like to check the root cause has been fixed upstream as well.

guybedford avatar Sep 03 '25 22:09 guybedford

Also - we need to figure out the testing story here, as not realising when templates break is not ideal...

guybedford avatar Sep 03 '25 22:09 guybedford

Well, FWIW, the template was still failing for me even after that PR was merged, but I haven’t tried it again since I submitted this so I guess it’s possible that it just works now? I may be able to set aside some time tomorrow afternoon to test if you don’t get to it by then.

Strong agree that testing would be really good, but given the failure point here was an outside library it feels like the only way to really know if it works is to build a new project from the template and see if it compiles. Maybe something in the CI can just do this?

edit: mobile GitHub is hard to use and I misread your comment haha. I see now that you’re saying the fix will go out soonish.

I still think this should get merged even if it isn’t needed next week, because the experience for me trying to get this working was super frustrating and I’d like to spare a couple of people that if possible.

natecox avatar Sep 04 '25 02:09 natecox

@natecox note that wasm-bindgen has not yet been released since that landed, I expect the next release should be in the coming days though or early next week with some luck. Will update here if you're interested in investigating further then.

guybedford avatar Sep 04 '25 02:09 guybedford

Ah, I suspect you started responding before I added an edit to my comment above; just making sure you see it because it’s relevant.

natecox avatar Sep 04 '25 02:09 natecox

The latest version has now been landed in https://github.com/cloudflare/workers-rs/pull/800.

guybedford avatar Sep 04 '25 20:09 guybedford