From 3659d342af0b3aee953b11fbbd48986c39f60cab Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Fri, 29 Sep 2017 19:31:42 +0200 Subject: [PATCH] Avoid losing the reference to Module in the promise. by @buu700 --- dist-build/emscripten.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dist-build/emscripten.sh b/dist-build/emscripten.sh index a60809c6..694f7ee3 100755 --- a/dist-build/emscripten.sh +++ b/dist-build/emscripten.sh @@ -77,11 +77,14 @@ if [ "$DIST" = yes ]; then if (typeof Module === 'undefined') { var Module = {}; } + var _Module = Module; Module.ready = new Promise(function (resolve, reject) { + var Module = _Module; Module.onAbort = reject; Module.onRuntimeInitialized = resolve; $(cat "${PREFIX}/lib/libsodium.wasm.tmp.js") }).catch(function () { + var Module = _Module; Module.onAbort = undefined; Module.onRuntimeInitialized = undefined; $(cat "${PREFIX}/lib/libsodium.asm.tmp.js" | sed 's|use asm||g')