-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
wasm-bindgen-cli installation: misguiged by the doc #2167
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
Comments
@MaciekTalaska You shouldn't install or use the wasm-bindgen CLI tool. You should only be using It is only necessary to run
It is correct. wasm-pack is the tool that you should be using, it installs, manages, and runs wasm-bindgen for you, so you don't have to.
Our examples all use wasm-pack, so if you find any samples which aren't using wasm-pack then they are wrong and they need to be changed to use wasm-pack.
We would gladly accept any contributions, if you can figure out a way to explain things more clearly. |
Thank you for your prompt response! I am a bit confused though.
This is what confuses me a lot. I have found that many examples of WASM apps written in Rust which require wasm-bindgen to be built. Many yew examples require wasm-bindgen
I really struggled to figure out why it works differently on my machine. I have made some investigation on this (with the help of my friend) and it seem that the statement in the docs is true, i.e. wasm-bindgen is installed after wasm-pack. The strange thing is this tool is installed in a very strange place ( Is there any reason why wasm-bindgen is not available for the end-user to be invoked? The current situation may lead to the situation of having 2 (possibly different) versions of wasm-bindgen-cli installed: one that is managed by wasm-pack, and the other one by the cargo itself. I am afraid this may result in some hard to track problems.
I am more than happy to help to improve the docs, but the first step for me is to understand if this is something that is not working on my machine or I have misunderstood My current understanding is:
This means that it is a bit inconvenient to use wasm-bindgen directly at the moment. The best solution probably is to have wasm-bindgen-cli installed side by side. Taking all that (what I have written above) under consideration, I suggest to enhance the following part of the "Installation" doc on wasm-bindgen:
I think the following should be added:
Additional info should be added to answer the question: What should I do if I need to invoke wasm-bindgen directly? (This is the case of compiling yew examples - as I have mentioned above). What would you suggest here? Should the user install wasm-bindgen-cli directly? Or should such a person use wam-bindgen installed by wasm-pack (bu mind that this is going to be inconvenient, and build scripts may require some tinkering) |
There's various reasons for that, it's partly because those examples are old and outdated. Another reason is that there is a lot of misinformation about wasm-pack. And another reason is that some people like to be as "bare metal" as they can, so they use as few tools as possible. But the official stance is that wasm-pack should pretty much always be used instead of wasm-bindgen-cli.
Yes, that is a known issue. Yew should use wasm-pack instead.
Yes, that's correct.
Because wasm-pack installs and uses multiple versions of wasm-bindgen simultaneously. There isn't a single version that could be used for This is because it's very important that the version of wasm-bindgen-cli exactly matches with your And you should not be running wasm-bindgen manually. It is an implementation detail, you should be using wasm-pack.
Yes, but why is that a problem? It is intentional that there can (and should) be multiple versions of wasm-bindgen installed simultaneously. The multiple installations do not conflict with each other.
If you use wasm-pack, then there will be no problems, because wasm-pack manages everything for you. If you don't use wasm-pack, then yes you will have problems, but not because of the multiple versions. Instead you will have problems with the version of wasm-bindgen-cli being out of sync (which wasm-pack solves).
The best solution is for yew to change the examples to use wasm-pack. The second best solution is for the end user to use wasm-pack and ignore the yew build script (the yew build scripts are not needed with wasm-pack). The third best solution is for the end user to do |
Thank you for such a detailed explanation! I have the feeling that now I finally understand the relation between wasm-pack and wasm-bindgen and the reason why wasm-bindgen should not be used directly by the user. I think most of what you wrote in your last comment should be included in the docs in the section describing the installation process of the wasm-bindgen command-line tool. I suggest to add the following to the docs, so it is clear for others starting their journey with WASM and wasm-pack (especially that you have stated in your comments that there is a lot of misinformation about wasm-pack):
If you think the above enhancement is ok, I am happy to create a PR for the review. As for your suggestions regarding yew and its examples - I will try to improve yew's build script so that it uses wasm-pack for all the examples. |
as the relevant branch has been merged it is safe to close this (I hope it is ok if I do so). |
The problem still persists. I read https://rustwasm.github.io/wasm-bindgen/reference/cli.html which I found after some googling. All in all I spent >20mins to find out that I have to And as others pointed out: many projects do require |
I did some dissection of wasm-pack to figure out what exactly it does, if this information were presented somewhere (in a more formal manner than I've written), I'm sure it would clear up a lot of confusion for people who prefer to understand what their tools are doing. |
Installation steps for wasm-bindgen-cli are not clear
I have some experience with Rust, but I am very new to the WASM (just started recently) and I have bumped on some problems at the very beginning. I wanted to compile samples downloaded from GitHub, but I was unable to do so due to the fact that I struggled with installing
wasm-bindgen
command-line tool.Steps to Reproduce
wasm-bindgen
wasm-pack
as described on the page mentioned abovewasm-pack build
(as stated in the docs)wasm-bindgen
in the command line - that fails, due to the fact thatwasm-bindgen
is not a part of thewasm-pack
Expected Behavior
I think going step by step by step through the
Installation
section (https://rustwasm.github.io/docs/wasm-bindgen/reference/cli.html) should result in:wasm-pack
being installed and available as a command-line toolwasm-bindgen
being installed and available to invoke from the command lineI suggest that the section describing the installation of the
wasm-bindgen
command-line tool should be altered, for example:The following section of the doc is unclear to me:
Is this a leftover? Was
wasm-pack
responsible for installingwasm-bindgen-cli
in the past? Could anyone clarify on this, please?Actual Behavior
A the moment it is unclear what to do to have
wasm-bindgen
installed. One may figure out that there is additional cratewasm-bindgen-cli
but I think it should be clearly mentioned what to do to have this utility installed.I was not able to compile some of the samples downloaded from Github which required
wasm-bindgen
tool available as part of the build.Additional Context
I think this could possibly be a showstopper for newcomers to the world of WASM in Rust (especially those not having experience with Rust itself).
I am happy to improve the documentation with the PR - if you accept th general direction of the changes (I mean: if I have not misunderstood something here)
The text was updated successfully, but these errors were encountered: