Don't run asm.js through babel (#26)

This commit is contained in:
Jaco Greeff
2019-07-19 17:01:12 +02:00
committed by GitHub
parent 1b4b426a98
commit 0772aa8471
3 changed files with 22 additions and 25 deletions
+1 -1
View File
@@ -22,7 +22,7 @@
"devDependencies": {
"@babel/core": "^7.5.4",
"@polkadot/dev": "^0.30.0-beta.23",
"@polkadot/util": "^0.94.0-beta.17",
"@polkadot/util": "^0.94.0-beta.18",
"override-require": "^1.1.1"
}
}
+17 -20
View File
@@ -2,6 +2,13 @@
set -e
BGJ=build/wasm_bg.js
SRC_WASM=build/wasm.js
DEF=build/wasm.d.ts
WSM=build/wasm_bg.wasm
OPT=build/wasm_opt.wasm
ASM=build/wasm_asm.js
echo "*** Building package"
# cleanup old
@@ -13,34 +20,24 @@ echo "*** Building WASM output"
rustup run nightly wasm-pack build --release --scope polkadot --target nodejs
mv pkg build
# shortcuts for files
echo "*** Adjusting output"
BGJ=build/wasm_bg.js
SRC_WASM=build/wasm.js
DEF=build/wasm.d.ts
WSM=build/wasm_bg.wasm
OPT=build/wasm_opt.wasm
ASM=build/wasm_asm.js
TMP=build/wasm_tmp.js
# optimise
echo "*** Optimising WASM output"
../../binaryen/bin/wasm-opt $WSM -Os -o $OPT
# cp -f build/wasm_bg.wasm build/wasm_opt.wasm
# build asmjs version from the input (optimised) WASM
# echo "*** Building asm.js version"
echo "*** Building asm.js version"
../../binaryen/bin/wasm2js --no-validation --output $TMP $OPT
# get babel to take care of making it sane
NODE_OPTIONS=--max_old_space_size=8192 yarn babel $TMP --presets @babel/preset-env --out-file=$ASM
rm -rf $TMP
# convert wasm to base64 structure
echo "*** Packing WASM into base64"
node ../../scripts/pack-wasm-base64.js
# build asmjs version from the input (optimised) WASM
echo "*** Building asm.js version"
../../binaryen/bin/wasm2js --output $ASM $OPT
# cleanup the generated output, sadly there are no node-js outputs above
sed -i -e 's/import {/\/\/ import {/g' $ASM
sed -i -e 's/function asmFunc/var schnorrkel = require('\''\.\/wasm'\''); function asmFunc/g' $ASM
sed -i -e 's/{abort.*},memasmFunc/schnorrkel, memasmFunc/g' $ASM
sed -i -e 's/export var /module\.exports\./g' $ASM
# copy our package interfaces
echo "*** Copying package sources"
cp src/js/* build/
+4 -4
View File
@@ -2030,10 +2030,10 @@
typescript "^3.5.3"
vuepress "^1.0.2"
"@polkadot/util@^0.94.0-beta.17":
version "0.94.0-beta.17"
resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.94.0-beta.17.tgz#998a0cb69d7005d4fcb0c94a9d2db1fa48ae584b"
integrity sha512-NYZF1gN4Yr31uMJe9x6MSTuvBOPn3NOH2RTs5Juz4wCG6Q2ejjPk0l3HG4/6rDq5Uh+x/zw3DREpayBpN36ihw==
"@polkadot/util@^0.94.0-beta.18":
version "0.94.0-beta.18"
resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.94.0-beta.18.tgz#363581e1092a1972d1f14df0db18d85a3a27f380"
integrity sha512-SzcKGFeskHQMdrZDnsRQ72lFYkUBWAJBAhjMrpUZR0iMvOSnjaX663034PLr3hvUKunh9W6NjQHJAOrpBgaFfA==
dependencies:
"@babel/runtime" "^7.5.5"
"@types/bn.js" "^4.11.5"