Skip to main content

Setup & requirements

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 command that will configure each package one-by-one. This must be ran in each project.

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.

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

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).

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.

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.

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