---
title: "emitModule(): function in Emit, TypeShade API reference"
description: "emitModule, a function in Emit. Emit a ModuleDecl as a complete WGSL module string, ready for device.createShaderModule."
url: https://typeshade.dev/api/emitmodule/
language: en
---

# `emitModule()`

Function in Emit

Emit a ModuleDecl as a complete WGSL module string, ready for device.createShaderModule.

`import { emitModule } from 'typeshade'`

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

## Syntax

```ts
const emitModule: (m: ModuleDecl, opts?: EmitOptions) => string
```

## Parameters

**`m` `ModuleDecl`**

**`opts` optional `EmitOptions`**

## Return value

`string`

## Description

Runs validation, the capability check, the lowering passes and the optimizer, then assembles the `enable` directives, structs, bindings, constants and functions.

`opts` is an optional [`EmitOptions`](https://typeshade.dev/api/emitoptions/): `plugins` for emit-time transforms such as the production ones on the `typeshade/emit-prod` subpath, and `parens` to choose how many parentheses the expressions carry.

## Targets

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

## In the guide

- [Language guide](https://typeshade.dev/guide/internals/)
- [Emitting and reflection](https://typeshade.dev/guide/internals/emitting-and-reflection/)
- [Diagnostics](https://typeshade.dev/guide/internals/diagnostics/)
- [Production emit](https://typeshade.dev/guide/internals/production-emit/)

## See also

- [`ModuleDecl`](https://typeshade.dev/api/moduledecl/)
- [`EmitOptions`](https://typeshade.dev/api/emitoptions/)
- [`emitGlslModule`](https://typeshade.dev/api/emitglslmodule/)

## Source

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