Release a monorepo
This guide shows how to release several packages from one repository. Each package is a scope, with its own version, changelog section, and tags.
Declare one scope per package
Section titled “Declare one scope per package”List each package in scopes, with its path relative to the configuration file:
import { defineConfig } from "@unirelman/cli";import { createChangelogPlugin } from "@unirelman/plugin-changelog";import { createChangesetsPlugin } from "@unirelman/plugin-changesets";import { createGitPlugin } from "@unirelman/plugin-git";import { createNpmPlugin } from "@unirelman/plugin-npm";import { createSemverPlugin } from "@unirelman/plugin-semver";
export default defineConfig({ scopes: { "@example/core": "packages/core", "@example/cli": "packages/cli", "@example/ui": "packages/ui", }, plugins: [ createChangesetsPlugin(), createChangelogPlugin(), createNpmPlugin(), createGitPlugin(), createSemverPlugin(), ],});Name each scope after its package: the name appears in tags and changelog sections. See scopes.
Record a change for several scopes
Section titled “Record a change for several scopes”List the scopes of the change, separated by commas:
npx unirelman changesets create --scopes "@example/core,@example/ui" --level patch --message "fix a bug"pnpm unirelman changesets create --scopes "@example/core,@example/ui" --level patch --message "fix a bug"yarn unirelman changesets create --scopes "@example/core,@example/ui" --level patch --message "fix a bug"bunx unirelman changesets create --scopes "@example/core,@example/ui" --level patch --message "fix a bug"Update the dependents of a package
Section titled “Update the dependents of a package”The npm plugin gives a change to the packages that depend on a released scope, and updates their dependency ranges. See Internal dependencies.
To update the dependents on every release of their dependency:
createNpmPlugin({ updateInternalDependencies: { dependents: "always" } });Write one changelog per scope
Section titled “Write one changelog per scope”The Changelog plugin writes one CHANGELOG.md at the root by default. To write one in each scope folder:
createChangelogPlugin({ mode: "scope" });Version scopes together
Section titled “Version scopes together”To give every scope the same version, use fixed versioning:
createSemverPlugin({ fixed: true });To version only some scopes together, name the groups. The other scopes stay independent:
createSemverPlugin({ fixed: { product: ["@example/core", "@example/cli"], },});The scopes of a group start from the same current version.
Version scopes with different schemes
Section titled “Version scopes with different schemes”Register each versioning plugin for its scopes:
import { defineConfig } from "@unirelman/cli";import { createCalverPlugin } from "@unirelman/plugin-calver";// ...
export default defineConfig({ scopes: { "@example/core": "packages/core", "@example/ui": "packages/ui", }, plugins: [ createChangesetsPlugin(), createChangelogPlugin(), { plugin: createSemverPlugin(), scopes: ["@example/core"], }, { plugin: createCalverPlugin(), scopes: ["@example/ui"], }, // ... ],});Each scope with changes needs a plugin that reads its current version, such as npm, and one that computes its next version, such as SemVer or CalVer.
Release the repository root
Section titled “Release the repository root”The root of the repository can be a scope too, such as a root package.json you also release:
scopes: { root: "./", "@example/core": "packages/core",},Its tags are the bare version, such as 1.0.1. See Tag names.