-
Notifications
You must be signed in to change notification settings - Fork 31
/
build_wasm.sh
executable file
·39 lines (28 loc) · 1.26 KB
/
build_wasm.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
set -e
RUSTFLAGS=""
#cd crates/diamond-wasm
echo "=== Before ==="
ls -l pkg-web pkg-node || true
#wasm-pack build --target nodejs
#wasm-pack build --target bundler
#wasm-pack build --target web --dev
rm -rf pkg-*
#wasm-pack build --target web --out-dir ../../pkg-web --out-name dt crates/dt-wasm --profiling
wasm-pack build --target web --out-dir ../../pkg-web --out-name dt crates/dt-wasm
wasm-pack build --target nodejs --out-dir ../../pkg-node --out-name dt crates/dt-wasm
# sed -i '3i\ \ "type": "module",' pkg/package.json
# Set version
#sed -i.old 's/: "0.1.0"/: "0.1.1"/' pkg-*/package.json
# Web code needs to have "main" defined since its an es6 module package
sed -i.old 's/"module":/"main":/' pkg-web/package.json
sed -i.old 's/"name": "dt-wasm"/"name": "diamond-types-web"/' pkg-web/package.json
sed -i.old 's/"name": "dt-wasm"/"name": "diamond-types-node"/' pkg-node/package.json
sed -i.old 's/"files": \[/"files": \[\n "dt_bg.wasm.br",/' pkg-web/package.json
#perl -wlpi -e 'print " \"type\": \"module\"," if $. == 2' pkg-web/package.json
sed -i.old 's/"0.1.0"/"1.0.2"/' pkg-web/package.json
sed -i.old 's/"0.1.0"/"1.0.2"/' pkg-node/package.json
rm pkg-*/package.json.old
brotli -f pkg-web/*.wasm
echo "=== After ==="
ls -l pkg-web pkg-node
cat pkg-web/package.json