---
title: "packModule(): function in Reflection, TypeShade API"
description: "packModule, a function in Reflection. The compiled module's manifest: everything a host needs to create its pipelines and bind its resources…"
url: https://typeshade.dev/api/packmodule/
language: en
---

# `packModule()`

Function in Reflection

The compiled module's manifest: everything a host needs to create its pipelines and bind its resources, in one plain JSON object.

`import { packModule } from 'typeshade'`

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

## Syntax

```ts
function packModule(m: ModuleDecl, options: PackOptions = {}): Pack
```

## Parameters

**`m` `ModuleDecl`**

**`options` optional `PackOptions`**

## Return value

`Pack`

## Exceptions

**`TypeError`**

`TypeError` for a word an emit option does not take, and for `ir` with `emit.plugins`.

## Description

See `buildManifest` in `src/core/manifest.ts`, which builds it from the IR alone, for what each field promises.

`options.console` adds the recorded variant, the WGSL that writes each `console.*` call an entry reaches into the console buffer, with the table the buffer decodes with.

`options.emit` emits the program under other options than the defaults (change 0028): the WGSL writer’s `parens`, `fp64Flavor` and `plugins`, and an optimization `level`. The manifest’s `wgsl`, its recorded variant’s `wgsl`, its `glsl` and its `bindings` are the ones those options emit (`fp64Flavor: 'integer'` binds no `_fp64` guard), and it records `level`, `parens` and `fp64Flavor` in `emit`, so `repack` from `typeshade/emit` emits the program again under them. A plugin is a function, which a manifest cannot record: `options.ir` with a plugin throws a `TypeError`, since the load-time emitter could not emit the program again.

## Examples

### Example

```ts
import { compile, packModule } from 'typeshade';

const program = packModule(compile(source).module, {
  emit: { level: 'O1', parens: 'minimal', fp64Flavor: 'integer' },
});
program.emit; // { level: 'O1', parens: 'minimal', fp64Flavor: 'integer' }
```

## In the guide

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

## Source

[`src/compiler/ts/pack.ts`, line 47](https://github.com/typeshade/typeshade/blob/af54ddad5/src/compiler/ts/pack.ts#L47), at commit af54ddad5
