---
title: Setup & requirements
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

Packemon has been designed to build and prepare packages for distribution, and as such, supports
workspaces (monorepos) or single packages (polyrepo). By default, only packages configured for
Packemon will be built (denoted by a `packemon` block in `package.json`). This allows specific
packages to be completely ignored if need be.

To ease the setup process, Packemon provides an interactive [`init`](./init) command that will
configure each package one-by-one. This _must_ be ran in each project.

```bash
packemon init
```

## Package structure

Regardless of your project type, Packemon makes the following assumptions, some of which are hard
requirements.

- Each package _must_ contain a `package.json` (of course).
- Each package _must_ have a source folder named `src`. Builds will output relative to this.
- Each package _must_ have a source entry point, typically a `src/index.*` file.
- Each package may contain a `tsconfig.json`.
- Each package should contain a `LICENSE(.md)?` and `README(.md)?`.

This would look something like the following.

<Tabs
  groupId="package-structure"
  defaultValue="poly"
  values={[
    { label: 'Polyrepo', value: 'poly' },
    { label: 'Monorepo', value: 'mono' },
  ]}
>
  <TabItem value="poly">

```
/
├── src/
├── package.json
├── LICENSE
└── README.md
```

  </TabItem>
  <TabItem value="mono">

```
/
├── packages/
│   ├── foo/
│   |   ├── src/
│   |   ├── package.json
│   |   ├── LICENSE
│   |   └── README.md
│   ├── bar/
│   |   ├── src/
│   |   ├── package.json
│   |   ├── LICENSE
│   |   └── README.md
│   └── baz/
│       ├── src/
│       ├── package.json
│       ├── LICENSE
│       └── README.md
├── lerna.json
├── package.json
├── LICENSE
└── README.md
```

  </TabItem>
</Tabs>

## TypeScript integration

Integrating with TypeScript can sometimes be tricky, and with Packemon, that is definitely the case.
Since Packemon now handles the build process, TypeScript should be configured for type checking and
declaration generation only.

### Enable emitting

The `noEmit` setting should _only_ be used on the command line (via an npm script) and should not be
configured explicitly. We require emitting of declarations (only for the build oriented config).

```diff title="tsconfig.json"
{
  "compilerOptions": {
-    "noEmit": false
  }
}
```

### Disable JSON resolving

The `resolveJsonModule` setting alters the output folder structure in such a way that it breaks the
guarantees that Packemon needs for handling declarations.

```json title="tsconfig.json"
{
  "compilerOptions": {
    "resolveJsonModule": false
  }
}
```

> If you really need to support this feature, please create an issue so that we can track it
> properly.

### Supporting project references

Alongside the requirements listed above, the `tsconfig.json` within each project reference package
should be updated to only emit declarations to each format, like so. This may require multiple
configs.

```json title="tsconfig.json"
{
  "compilerOptions": {
    "declaration": true,
    "outDir": "lib",
    "rootDir": "src",
    "emitDeclarationOnly": true
  }
}
```
