Avoid losing the reference to Module in the promise.

by @buu700
This commit is contained in:
Frank Denis 2017-09-29 19:31:42 +02:00
parent 24ff2a7049
commit 3659d342af

View File

@ -77,11 +77,14 @@ if [ "$DIST" = yes ]; then
if (typeof Module === 'undefined') { if (typeof Module === 'undefined') {
var Module = {}; var Module = {};
} }
var _Module = Module;
Module.ready = new Promise(function (resolve, reject) { Module.ready = new Promise(function (resolve, reject) {
var Module = _Module;
Module.onAbort = reject; Module.onAbort = reject;
Module.onRuntimeInitialized = resolve; Module.onRuntimeInitialized = resolve;
$(cat "${PREFIX}/lib/libsodium.wasm.tmp.js") $(cat "${PREFIX}/lib/libsodium.wasm.tmp.js")
}).catch(function () { }).catch(function () {
var Module = _Module;
Module.onAbort = undefined; Module.onAbort = undefined;
Module.onRuntimeInitialized = undefined; Module.onRuntimeInitialized = undefined;
$(cat "${PREFIX}/lib/libsodium.asm.tmp.js" | sed 's|use asm||g') $(cat "${PREFIX}/lib/libsodium.asm.tmp.js" | sed 's|use asm||g')