3 ms·
They're not doing so here, but shipping a wasm-compiled binary with npm that uses node's WASI API is a really easy way to ship a cross-platform CLI utility. Jus
by cobbal 7mo ago
They're not doing so here, but shipping a wasm-compiled binary with npm that uses node's WASI API is a really easy way to ship a cross-platform CLI utility. Just needs ~20 lines of JS wrapping it to set up the args and file system.
- mountainriver 7mo agoDoesn’t this seem excessive over just using rust’s cross platform builds?
- csomar 7mo agoThere's no such thing as a truly "cross-platform" build. Depending on what you use, you might have to target specific combinations of OS and processor architecture. That's actually why WASM (though they went with WASI) is a better choice; especially for libraries, since anyone can drop it into their environment without worrying about compatibility.
- jitl 7mo agothere’s 3 os and 2 architectures minus darwin-amd64 so you just need to do 5 builds to avoid the WASM performance tax. (freebsd runs linux binaries and the openbsd people probably want to build from source anyways)
- rendaw 7mo agoI think GP's point is that instead of having 3 target-specific rust-built binaries, they have 3 target-specific node binaries running rust-built wasm plus wrapper code.
- Lord_Zero 7mo agoCan you link to a sample of how I can do this?
- taskylizard 7mo agohttps://axodotdev.github.io/cargo-dist/ https://axodotdev.github.io/cargo-dist/