You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 26, 2020. It is now read-only.
At least in the https://github.com/polkadot-js projects we need to support Browser/Node/React Native. wasm-pack is great, however the output options either creates something just for the browser or just for node.
Browser assumed webpack so does import * from 'schnorrkel_js_bg' - which is a WASM file, cannot be done on Node without webpack. The node output (--target nodejs) emits something where fs.readySync is used, once again, not quite usable in the Browser or RN.
Basically to get this working, I'm using the following scripts to support both environments.
build.sh -
#!/bin/sh# install wasm-pack as requiredif! [ -x"$(command -v wasm-pack)" ];then
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
fi
rm -rf ./pkg
rustup default nightly
wasm-pack build --target nodejs
rustup default stable
# make a backup of the original, use it, don't use it (useful for checking)
mv ./pkg/schnorrkel_js_bg.js ./pkg/schnorrkel_js_bg_node.js
./wasm2js.js
At least in the https://github.com/polkadot-js projects we need to support Browser/Node/React Native. wasm-pack is great, however the output options either creates something just for the browser or just for node.
Browser assumed webpack so does
import * from 'schnorrkel_js_bg'
- which is a WASM file, cannot be done on Node without webpack. The node output (--target nodejs
) emits something wherefs.readySync
is used, once again, not quite usable in the Browser or RN.Basically to get this working, I'm using the following scripts to support both environments.
build.sh -
wasm2js.js -
By far from the prettiest hack around, but it basically yields something that I can use as-is.
The text was updated successfully, but these errors were encountered: