Skip to content
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

✨ Add a method for building npm packages from wasm binaries #362

Open
Velnbur opened this issue Aug 4, 2023 · 6 comments
Open

✨ Add a method for building npm packages from wasm binaries #362

Velnbur opened this issue Aug 4, 2023 · 6 comments

Comments

@Velnbur
Copy link

Velnbur commented Aug 4, 2023

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

@Velnbur
Copy link
Author

Velnbur commented Aug 4, 2023

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

@ipetkov
Copy link
Owner

ipetkov commented Aug 4, 2023

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

@Velnbur
Copy link
Author

Velnbur commented Aug 8, 2023

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

@ipetkov
Copy link
Owner

ipetkov commented Aug 10, 2023

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

@Velnbur
Copy link
Author

Velnbur commented Aug 10, 2023

This one has the same error: https://github.com/Velnbur/crane-wasm-pack-example

@ipetkov
Copy link
Owner

ipetkov commented Aug 18, 2023

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants