Replies: 3 comments 3 replies
-
I thought about it more. I kind of like the idea of injecting the module from WASM. If it was done that way, the module would work automatically with both CSR and SSR versions without having to deploy with Actix or Axum. It also would be compatible with most WASM deployments, as it just needs to be able to find the document. I did some searches and found there are some tricks to inline ESM modules, so I might try to do something similar. I also looked through wasm_bindgen again, and noticed that using [wasm_bindgen(inline_js="")] creates snippets which Leptos seems to include correctly, but I don't think there's currently support for static strings with it. I noticed an author for Dixous had opened an issue on wasm_bindgen for inline &str support for it, but I don't think it has changed. I don't know, I might try some of these later, but if there's a better way to do this, I would prefer to do that instead. An easy solution would be to just use like unpkg and link to it in the bindings, but I think that's more unreliable than the above. I've also had many experiences where unpkg seemed to be broken, so I kind of want to avoid doing it that way. |
Beta Was this translation helpful? Give feedback.
-
I'm going to close this discussion because I created a discussion on the wasm_bindgen repository instead. I think this question is more relevant to that repository after my last comment. |
Beta Was this translation helpful? Give feedback.
-
You can use Leptos with Webpack to bundle npm packages easily. More info: #2333. I'm not sure if this would work perfectly for you if you want the server to be written in Rust and not JS. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I want to create a crate with bindings for a bundled NPM module to be used in Leptos.
The goal of doing this is so that rust developers using Leptos do not have to think about the complex build system related to JS, TS, webpack, etc. I understand that there are negative performance and fuctionality impacts from pre-bundling, but, I would prefer to encourage rust developers to create rust library versions of the binded version instead of encouraging every rust developer that uses the crate to understand another language's build system.
At the moment, with my own project that uses Leptos, I've handled this issue by adding the bundle to a location that Actix in Leptos makes accessible online. This works for my project, but, I would prefer for a developer that uses my crate to not have to think about where bundles are being stored for use with Leptos.
Is there a suggested way to accomplish this goal? I don't want a developer that is using multiple crates with bindings to have to follow different instructions for each crate. I would prefer for them to be able to add the crate to their project, and have it work automatically.
Beta Was this translation helpful? Give feedback.
All reactions