Skip to content

Commit a47e031

Browse files
committed
Document "build/wasm" scripts
1 parent 033f61f commit a47e031

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

scripts/build/wasm/build-node.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
#!/usr/bin/env bash
2-
32
set -Eeuo pipefail
43

4+
# Description:
5+
# Builds the Kimchi WebAssembly (WASM) bindings for Node.js. This script:
6+
# - Compiles the Kimchi proof system’s Node bindings using Dune, generating
7+
# the WebAssembly and JavaScript interface files:
8+
# - `plonk_wasm_bg.wasm` and its TypeScript definitions.
9+
# - `plonk_wasm.js` (the JS interface) and its type declarations.
10+
# - Copies all generated artifacts into `src/bindings/compiled/node_bindings/`.
11+
# - Converts the output files to CommonJS format (`.cjs` / `.d.cts`) for
12+
# compatibility with Node.js environments.
13+
# - Applies automatic fixes to the generated bindings via
14+
# `src/build/fix-wasm-bindings-node.js` to ensure correct runtime behavior.
15+
#
16+
# Usage:
17+
# npm run build:wasm:node
18+
519
source ./scripts/lib/ux.sh
620

721
setup_script "wasm-node-build" "wasm node build"

scripts/build/wasm/build-web.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,23 @@
11
#!/usr/bin/env bash
2-
32
set -Eeuo pipefail
43

4+
# Description:
5+
# Builds the Kimchi WebAssembly (WASM) bindings for Web (browser) usage. This script:
6+
# - Compiles the Kimchi proof system’s Web bindings using Dune, generating:
7+
# - `plonk_wasm_bg.wasm` (the main WebAssembly module) and its TypeScript definitions.
8+
# - `plonk_wasm.js` (the JavaScript interface) and its type declarations.
9+
# - Copies all generated artifacts into `src/bindings/compiled/web_bindings/`.
10+
# - Optimizes the WebAssembly binary using `wasm-opt` with advanced flags
11+
# (`--detect-features`, `--enable-mutable-globals`, `-O4`) for performance and size reduction.
12+
# - Ensures proper file permissions after optimization.
13+
#
14+
# Note:
15+
# - Requires `wasm-opt` (from Binaryen) to be installed and available in PATH.
16+
#
17+
# Usage:
18+
# npm run build:wasm:web
19+
20+
521
source ./scripts/lib/ux.sh
622

723
setup_script "wasm-web-build" "wasm web build"

0 commit comments

Comments
 (0)