-
Notifications
You must be signed in to change notification settings - Fork 59
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-npm-packager: what to write it in #35
Comments
To clarify: is the tool specific to packaging Rust projects, or does it work with arbitrary .wasm files? |
In planning, @lukewagner and I have been thinking this could work with C++ modules as well. I believe the info in the relevant custom section could be completely decoupled from Rust. Because of this, I think writing in JS makes the most sense. |
I really like the idea of using Rust for CLI tools but if it's for arbitrary wasm files then I think JS is probably the better choice. Mostly because if someone is publishing to npm they already have node. It would be easier to integrate it into npm possibly. I would think decoupling from Rust is good. Yes I want Rust to succeed but a useful tool shouldn't be tied to any one lang in my opinion. I guess I have a few questions:
Knowing what and for whom we're trying to solve this problem for with the tool changes what we do. Was there some group or user base you had in mind as part of this @ashleygwilliams? |
One thing we are hoping to push for in general is using Rust to write pure wasm tooling, which is already happening with the tools you can see at that issue. This is part of a bid to set up Rust as the predominant "systems language" for both writing in and around wasm. If we're successful on that front, we can probably expect a Rust toolchain to be available. re: integration, I imagine there eventually being a Cargo subcommand that invokes this tool, but I don't think the tool itself needs to be coupled. To me the high-order bits here are:
|
so, given the workflow i currently have in my head, i believe that writing it in Rust makes the most sense. here's why?
i think the interesting idea is the ability to also allow C++ devs and other WASM backends to use the same tool. because Rust is distributed via a binary that seems ideal for multiple envs as we dont have to assume a runtime (which we would with node). i dont think we can assume that people compiling to WASM necessarily have a node env, and i dont think we should (though if we had to i dont think it would be the end of the world). anyways. i'm leaning toward Rust, unless that really blocks C++ and other WASM backend devs, based on the ability to not depend on a runtime being present. |
As a user, I wouldn't have a preference between rust, go or C++ because I can just download binaries. When I see arbitrary tools I want to use requiring ruby or node I tend to wince because I don't have that installed (shell and python would also work for me personally, but think of the windows users!). Then again, if you're publishing to npm it follows that you're likely pulling from npm, implying that you do have npm installed...unless https://github.com/rust-lang-nursery/rust-wasm/issues/36 ends up with NPM integration in cargo. So for me the answer hinges around how you consume the packages after publishing. If the only way is with a tool that requires node then...requiring node to publish isn't such a big deal. |
OK, my two cents from running secure, productive environments:-
So, that means such a tool should be either Rust (already has to be present to compile) or Shell (easy to install and always supported). Personally, I find shell hard to maintain and manage dependencies in (and I wrote shellfire and even cross-platform packagers in it), but it is the lowest common denominator for everything bar Windows - and even Windows these days with the new Linux subsystem or Cygwin, cough. However, shell sucks for anything which needs to work with binary data. |
I also feel like writing in JS would have a broader coverage and wider audience. |
@sendilkumarn Do you mean for people making improvements to the tool itself? You're right, that is an advantage, since many programmers know JavaScript. But if you're talking about people simply using the tool, I think Rust has the same coverage as Node/JavaScript: Rust is cross-platform, so a compiled Rust binary will work everywhere that Node/JavaScript works. And a Rust binary has the advantage of not requiring a runtime, unlike JavaScript which requires Node. |
That is a valid point no runtime for rust. But this compiled packages will always have IMO (just an opinion) having this library in Do you think, rust projects will use these compiled binaries as dependencies? Is that possible? |
They probably wouldn't include it as a direct dependency in Cargo, but they would be using the binary during the compilation process. This is how the tool works:
The end result is that you have a folder which contains a The only thing the tool does is extract npm dependencies and JavaScript code out of the As you can see, the tool is very simple and it doesn't do much, therefore it doesn't really need to keep up with the changing JavaScript ecosystem. Given the above, do you still think writing it in JavaScript would help? If so, would you mind explaining your viewpoint in more detail? You might be wondering why it does it in two steps (combining the information into the
|
Thanks for the detailed explanation. It makes sense. This raises another interesting question. Do we have any example of converting an entire lib into one wasm file. For example, converting a converter in binaryen / emscripten into wasm. How big will that single wasm be? So many use case so lil time 😛 |
There is a Rust WebAssembly book which contains some simple examples. There is work being done on expanding and improving the book. WebAssembly support for Rust is still in the early stages: there is a lot of discussion happening but it will take time for things to be implemented and stabilized. If you want examples, right now the best way is to write them yourself. I have written a ~4,000 line Rust program and then used It works great, though there are a lot of intricacies with the JavaScript interop. In general I've found that the |
@Pauan Thanks for the information again. I will start exploring cargo-web and std-web. well I did an attempt to convert the binaryen wat to wasm converter into wasm module. Since for wasm it is hard (impossible) to link (send) the file (as input parameter to the generated wasm). I have changed it into asm.js. But the output was a huge one. I feel the same will happen for wasm. Is there any discussion splitting the wasm ? |
In general the wasm output is dramatically smaller than asm.js, even for the exact same program. But I think this is straying pretty far off-topic, so let's continue this conversation here.
I don't see any discussion about splitting the |
wasm-pack now exists, so I'm gonna close this |
i'm currently tasked with writing a tool to take compiled WASM and package it up for publishing to npm, the requirements for which are documented in #34. in thinking about this workflow, i realize that the question of what to write this tool in is an interesting one.
current candidates:
questions to think about:
would love to hear ya'lls thoughts on the matter.
The text was updated successfully, but these errors were encountered: