ipetkov/crane

✨ Add a method for building npm packages from wasm binaries

Velnbur opened this issue · 6 comments

I'm looking for a way to build npm packages from compiled wasm binaries. For example, using wasm-pack (but right now I have problems with that see rustwasm/wasm-pack#1318).

I've made a "usable" build with wasm-bindgen and some scripts, but it feels pretty awkward

I've seen the buildTrunkPackage approach, so I could add something similar. I would be thankful for any help

Hi @Velnbur if you run wasm-pack via strace what does it show? I wonder if wasm-pack is trying to write files in a source directory somewhere (instead of some other scratch space like in ./target) which is causing the error

I'm currently using a Mac, and the workaround withdtrace is tricky. So I've tried doing that in the container with colima and the output with strace wasm-pack build -t nodejs --out-dir $out/pkg $src/plugin was :

Error: Permission denied (os error 13)
Caused by: Permission denied (os error 13)

I've tried to use strace with something else and it shows the syscalls as usual. Maybe, I am missing something

Hmm that's disappointing, do you have a flake which reproduces the issue I can peek at?

Running wasm-pack through strace showed statx(AT_FDCWD, "/homeless-shelter", AT_STATX_SYNC_AS_STAT, STATX_ALL, 0x7fffffffa600) = -1 ENOENT (No such file or directory) so it seems the case that wasm-pack cannot handle the situation where $HOME does not exist. Perhaps this should be reported upstream

The other issue with the example is specifying $src to the wasm-pack invocation. $src represents the immutable source in the store (wasm-pack appears to try to cd into the source and create a ./target directory which fails). This is already extracted at the current directory by default so that parameter can be omitted...

So, all-in-all, changing the wasm-pack invocation to HOME=$(mktemp -d fake-homeXXXX) wasm-pack build -t nodejs --out-dir $out/pkg appears to build fine for me. Hope this helps!