---
title: "bundle"
description: "Measure the client bundle per role and per shared part, in raw and gzip bytes."
source: "https://permdock.com/docs/cli/bundle"
---

# bundle

Source: https://permdock.com/docs/cli/bundle

Measure the client bundle per role and per shared part, in raw and gzip bytes.

`permdock bundle size` reports the size of `clientBundle(policy)`, the module `permdock gen --kind bundle` writes and a snapshot written with `omitStatic` resolves against. Sizes are bytes of `JSON.stringify(bundle)`.

## Usage [#usage]

```bash
permdock bundle size
permdock bundle size --budget 32768 --json
```

| Flag | Meaning |
| --- | --- |
| `--policy <module>` | Module exporting the policy; default `policy` in the config |
| `--budget <bytes>` | Bytes the bundle may weigh. Default `budgets.bundle`. Never a failure |
| `--json` | Print the report as JSON |

The report lists `conditions`, the grant terms every role shares, and each other top-level part, then one row per role, largest first, with the total and the largest part. The generated module records the same total on the line under its header:

```ts
// @generated by permdock generate bundle@0.35.1 from policy.ts sha-256:…; do not edit
// clientBundle: 1840 bytes of JSON, 412 gzip
```

## Budgets [#budgets]

`budgets` in `permdock.config.ts` sets a byte budget for the bundle, the snapshot and the token claim. `permdock generate --check` exits 1 and doctor reports [PD132](/docs/cli/doctor#pd132-over-a-size-budget) when the policy is over one; both print the size, the budget and the largest part.

```ts title="permdock.config.ts"
export default defineConfig({
  policy: "./src/policy.ts",
  budgets: {
    bundle: 32_768,
    snapshot: { bytes: 65_536, memberships: 12 },
    claims: 1_024,
  },
});
```

| Key | Measures |
| --- | --- |
| `bundle` | `JSON.stringify(clientBundle(policy))` |
| `snapshot.bytes` | The snapshot of the role with the most grants, as [`snapshot size`](/docs/cli/snapshot) measures it |
| `snapshot.memberships` | Memberships of that probe subject. Default 3 |
| `claims` | The `memberships` claim for `snapshot.memberships` memberships of one role each |

The snapshot probe passes `omitStatic` when `gen.kinds` includes `bundle`, as the pages that render the generated bundle do.

## Side effects [#side-effects]

| Command | Effects |
| --- | --- |
| `permdock bundle size` | None |
