Skip to content

WASM Build

The TypeScript binding ships pre-built WASM, but you can rebuild it from source with wasm-pack.

Terminal window
cargo install wasm-pack

From the bindings/plantuml-ts directory:

Terminal window
npm run build

This runs three steps:

  1. wasm-pack build --target web — builds the browser WASM module into wasm/web/
  2. wasm-pack build --target nodejs — builds the Node.js WASM module into wasm/node/
  3. tsc — compiles the TypeScript wrapper into dist/

To build only the browser target:

Terminal window
npm run build:wasm:web

To build only the Node.js target:

Terminal window
npm run build:wasm:node
TargetOutputUse case
webwasm/web/plantuml_wasm.js + .wasmBrowser (ES module, fetch-based init)
nodejswasm/node/plantuml_wasm.js + .wasmNode.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).