---
title: "emitModuleAt(): function in Emit, TypeShade API reference"
description: "emitModuleAt, a function in Emit. Emit a ModuleDecl as WGSL at an explicit optimization level."
url: https://typeshade.dev/api/emitmoduleat/
language: en
---

# `emitModuleAt()`

Function in Emit

Emit a ModuleDecl as WGSL at an explicit optimization level.

`import { emitModuleAt } from 'typeshade'`

The signature, the description and the examples come from the compiler's own source at commit af54ddad5.

## Syntax

```ts
const emitModuleAt: (m: ModuleDecl, level: OptLevel) => string
```

## Parameters

**`m` `ModuleDecl`**

**`level` `OptLevel`**

## Return value

`string`

## Description

`emitModuleAt(m, 'O2')` produces the same string as `emitModule(m)`; `'O0'` skips the optimizer and writes the lowered module as authored; `'O1'` runs only the passes that cannot change a computed value. Useful for debug builds and for comparing emitted size across levels. See [`OptLevel`](https://typeshade.dev/api/optlevel/).

## Targets

| Target | Support | Notes |
| --- | --- | --- |
| WGSL (WebGPU) | Supported | Writes WGSL for WebGPU. |
| GLSL ES 3.00 (WebGL2) | Does not apply | |
| CPU oracle | Does not apply | |

## See also

- [`ModuleDecl`](https://typeshade.dev/api/moduledecl/)
- [`OptLevel`](https://typeshade.dev/api/optlevel/)

## Source

[`src/core/backends/wgsl.ts`, line 263](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/backends/wgsl.ts#L263), at commit af54ddad5
