Skip to content

Commit

Permalink
Reduce WASM build size (#427)
Browse files Browse the repository at this point in the history
* reduce wasm build size

* Enable lto for Wasm release

Add `build-dev` task for Wasm for debugging.

Co-authored-by: Craig Bester <craig.bester@iota.org>
  • Loading branch information
2 people authored and PhilippGackstatter committed Oct 15, 2021
1 parent c8aa839 commit e339286
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion bindings/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,8 @@ chrono = { version = "0.4", features = ["wasmbind"] }
getrandom = { version = "0.2", features = ["js"] }

[package.metadata.wasm-pack.profile.release]
wasm-opt = false
wasm-opt = true

[profile.release]
opt-level = 's'
lto = true
7 changes: 5 additions & 2 deletions bindings/wasm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@
"example": "examples"
},
"scripts": {
"build:nodejs": "wasm-pack build --target nodejs --out-dir node && node ./build/node",
"build:web": "wasm-pack build --target web --out-dir web && node ./build/web",
"build:nodejs": "wasm-pack build --target nodejs --release --out-dir node && node ./build/node",
"build:web": "wasm-pack build --target web --release --out-dir web && node ./build/web",
"build-dev:nodejs": "wasm-pack build --target nodejs --dev --out-dir node && node ./build/node",
"build-dev:web": "wasm-pack build --target web --dev --out-dir web && node ./build/web",
"build:docs": "node ./build/docs",
"build:examples": "webpack --config ./examples/webpack.config.js --mode=production",
"build": "npm run build:web && npm run build:nodejs && npm run build:docs",
"build-dev": "npm run build-dev:web && npm run build-dev:nodejs && npm run build:docs",
"pretest": "npm run build:nodejs",
"prepublishOnly": "npm run build",
"serve": "webpack serve",
Expand Down

0 comments on commit e339286

Please sign in to comment.