# ondine/compiler/wasm

Compile Mermaid in browsers and edge runtimes with modules supplied by the caller.

`ondine/compiler/wasm` contains the JavaScript glue (about 1 kB gzip) and no WebAssembly. The caller passes modules to `create`, such as the module from `ondine/compiler/wasm/all`. The [In-Browser Compilation](/docs/guides/browser) guide shows common tasks.

```ts title="preview.ts"
import { create } from 'ondine/compiler/wasm'
import { wasm as all } from 'ondine/compiler/wasm/all'

// Compiles a flowchart in the browser
const { svg } = create({ modules: { all } }).render('flowchart LR\n  A --> B')
```

## Functions

- [create](/docs/api/compiler/create): Create a renderer over modules supplied by the caller.

## Errors

- [RenderError](/docs/api/compiler/RenderError): Thrown when source cannot be rendered, with its position.

## Modules

- [ondine/compiler/wasm/all](/docs/api/compiler-wasm/all): The size-optimized module for every diagram type.

- [ondine/compiler/wasm/<type>](/docs/api/compiler-wasm/types): One size-optimized module per diagram type, as base64 or a .wasm file.

## Namespaces

| Export   | Contents                                                                                                                         |
| -------- | -------------------------------------------------------------------------------------------------------------------------------- |
| `Render` | The types behind `create`: `create.Options`, `create.ReturnType`, `render.Options`, `render.ReturnType`, and `RenderError.Code`. |
