WASM Build
WASM Build
Section titled “WASM Build”The TypeScript binding ships pre-built WASM, but you can rebuild it from source with wasm-pack.
Prerequisites
Section titled “Prerequisites”cargo install wasm-packFrom the bindings/plantuml-ts directory:
npm run buildThis runs three steps:
wasm-pack build --target web— builds the browser WASM module intowasm/web/wasm-pack build --target nodejs— builds the Node.js WASM module intowasm/node/tsc— compiles the TypeScript wrapper intodist/
Build a single target
Section titled “Build a single target”To build only the browser target:
npm run build:wasm:webTo build only the Node.js target:
npm run build:wasm:nodeTargets
Section titled “Targets”| Target | Output | Use case |
|---|---|---|
web | wasm/web/plantuml_wasm.js + .wasm | Browser (ES module, fetch-based init) |
nodejs | wasm/node/plantuml_wasm.js + .wasm | Node.js (require-based, auto-init) |
The web target exports render_svg, render_preproc, and a default() init function that accepts a URL to the .wasm file. The nodejs target exports render_svg and render_preproc directly (auto-initialized on require).