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