mirror of
https://github.com/jedisct1/libsodium.git
synced 2024-12-23 20:15:19 -07:00
Node requires an async function to start wasm code
This commit is contained in:
parent
a1f73b8cab
commit
58ae64d319
@ -40,11 +40,12 @@ if [ -z "$WASI_RUNTIME" ] || [ "$WASI_RUNTIME" = "node" ]; then
|
||||
echo "import fs from 'fs'; import { WASI } from 'wasi';"
|
||||
echo "const wasi = new WASI({args: process.argv, env: process.env, preopens: {'.':'.'}});"
|
||||
echo "const importObject = { wasi_snapshot_preview1: wasi.wasiImport };"
|
||||
echo "const wasm = await WebAssembly.compile(fs.readFileSync('${1}'));"
|
||||
echo "const instance = await WebAssembly.instantiate(wasm, importObject);"
|
||||
echo "wasi.start(instance);"
|
||||
echo "(async function() {"
|
||||
echo " const wasm = await WebAssembly.compile(fs.readFileSync('${1}'));"
|
||||
echo " const instance = await WebAssembly.instantiate(wasm, importObject);"
|
||||
echo " wasi.start(instance);"
|
||||
echo "})().catch(e => { console.error(e); process.exit(1); });"
|
||||
} >"${1}.mjs"
|
||||
cat "${1}.mjs" >/tmp/a
|
||||
node --experimental-wasm-bigint --experimental-wasi-unstable-preview1 "${1}.mjs" 2>/tmp/err &&
|
||||
rm -f "${1}.mjs" && exit 0
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user