Simplify asm creation (#131)
This commit is contained in:
@@ -9,7 +9,7 @@ let wasm;
|
||||
let cachegetInt32 = null;
|
||||
let cachegetUint8 = null;
|
||||
|
||||
async function initWasm (wasmBytes, asmFallback, wbg) {
|
||||
async function initWasm (wasmBytes, asmFn, wbg) {
|
||||
try {
|
||||
assert(typeof WebAssembly !== 'undefined', 'WebAssembly is not available in your environment');
|
||||
|
||||
@@ -18,8 +18,8 @@ async function initWasm (wasmBytes, asmFallback, wbg) {
|
||||
wasm = source.instance.exports;
|
||||
} catch (error) {
|
||||
// if we have a valid supplied asm.js, return that
|
||||
if (asmFallback && asmFallback.ext_blake2b) {
|
||||
wasm = asmFallback;
|
||||
if (asmFn) {
|
||||
wasm = asmFn(wbg);
|
||||
} else {
|
||||
console.error(`ERROR: Unable to initialize ${pkg.name} ${pkg.version}`);
|
||||
console.error(error);
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
|
||||
// Stub replaced at build time
|
||||
|
||||
module.exports = {};
|
||||
module.exports = null;
|
||||
|
||||
@@ -41,8 +41,7 @@ echo "*** Building asm.js version"
|
||||
|
||||
# cleanup the generated asm, converting to cjs
|
||||
sed -i -e '/import {/d' $ASM
|
||||
echo "const imports = require('../js/imports');
|
||||
$(cat $ASM)" > $ASM
|
||||
sed -i -e 's/{abort.*},memasmFunc/imports, memasmFunc/g' $ASM
|
||||
sed -i -e 's/export var /module\.exports\./g' $ASM
|
||||
sed -i -e '/export var /d' $ASM
|
||||
sed -i -e 's/{abort.*},memasmFunc/wbg, memasmFunc/g' $ASM
|
||||
sed -i -e 's/var retasmFunc = /module.exports = (wbg) => /' $ASM
|
||||
rm -rf build/wasm/*-e
|
||||
|
||||
Reference in New Issue
Block a user