When we finish development, we need to add a changeset to declare the current changes for version releases.
A changeset includes:
Which packages are affected by this change.
The type of version for this change, which complies with the semver specification.
Changelog information for this change.
The following example commands are all using pnpm. If you need to use other package managers, please replace them as needed.
After running, a corresponding changeset file will be created in the .changeset
directory of the project, and the file content is as follows:
This file contains all the information of the changeset.
There are three NPM module packages in the monorepo, module-1
, module-2
, and module-3
.
Changesets will categorize the packages in the Monorepo into two categories, changed packages
and unchanged packages
, based on the current code changes (git diff Head...baseBranch
), making it easy for users to choose.
Use the space key to select the corresponding package or category, and then press Enter after the selection is completed:
Changesets will ask about the major
and minor
types. If there are packages that have not selected these two types, the patch
type will be used by default.
After running, a corresponding changeset file will be created in the .changeset
directory of the project, and the file content is as follows:
This file contains all the information of the changeset, and different packages will be marked according to the selected version type.
The change
command supports the following parameters:
--empty
: Adds an empty changeset.After running, an empty changeset file will be created in the .changeset
directory of the project, and the file content is as follows:
--open
: When using this parameter, the system default editor will be opened for filling in the changelog.If the current change is to modify some infrastructure of the repository, such as CI, testing, etc., there is no need to add changesets, or an empty changeset can be added.
When a pull request has multiple feature developments or bug fixes, multiple pnpm run change
commands can be executed to add multiple changeset files. Each file selects the corresponding packages for the feature and adds change information.
When creating a changeset in a Monorepo, all related packages to the feature need to be selected to avoid some packages not being published when releasing.