Skip to content

Npm

@simple-release/npm describes projects managed with npm: NpmProject for a single package and NpmWorkspacesProject for an npm workspaces monorepo. Publishing runs npm publish.

pnpm add @simple-release/npm

Single package:

.simple-release.json
{
"project": "@simple-release/npm#NpmProject"
}

Workspaces monorepo — NpmWorkspacesProject reads the workspaces list from the package.json in the project root:

.simple-release.json
{
"project": ["@simple-release/npm#NpmWorkspacesProject", {
"mode": "fixed"
}]
}
OptionDescription
pathPath to the package.json manifest file. Defaults to 'package.json'.
changelogFilePath to the changelog file. Defaults to 'CHANGELOG.md'.
composeFunction to compose the main manifest with secondary manifests where the version should also be updated. Optional.
OptionDescription
modeVersioning mode. Required. independent — each package has its own version; fixed — all packages share the same version.
rootPath to the monorepo root. Defaults to the current working directory.
changelogFilePath to the changelog file. Defaults to 'CHANGELOG.md'.
composeSame as for NpmProject, called for each manifest in the monorepo. Optional.
scopeFunction to format the scope name from the package name. By default the scope part of the package name is dropped: @scope/pkg-name → pkg-name.
tagPrefixFunction to format the tag prefix from the scope name. Defaults to pkg-name@ in independent mode and an empty string in fixed mode.

In monorepos, commits are attributed to packages by the commit scope — fix(pkg-name): ... bumps pkg-name. The scope must match the package name without the npm scope (or whatever your scope function returns).

In fixed mode, only packages with changes get the new version. When it is breaking for one of them — a major bump, a minor bump of a 0.x version or a patch bump of a 0.0.x version, including a major prerelease and its graduation — the packages without changes are bumped too, so all packages are released together. Set the force bump option to false to turn it off, or to true to always bump all packages. npm publishes version ranges of workspace dependencies as written, so update them along with breaking releases.

Options of the publish step for both classes:

OptionDescription
skipSkip publishing.
accessAccess level for the package.
tagnpm dist-tag — a string or a function of the version and prerelease components. When not set, prereleases get their prerelease identifier and maintenance releases of previous majors get release-N.x, so they never overwrite latest.
otpOne-time password for publishing.
envEnvironment variables to set before publishing. Defaults to process.env.