An npm-type module project release process consists of two phases.
Modern.js Module provides a set of version management and release solutions, which are suitable for single-package scenarios. For npm packages in monorepo, you need to follow the strategies provided by various monorepo solutions.
Changes need to be logged when they happen to the project. Changes that occur in a project are typically.
Once these changes have been made, the current changes need to be documented with the following command.
Executing the modern change
command asks the developer several questions and generates a change log based on the developer's answers. The changelog file contains the type of change and its description, and is committed to the git repository.
When executed successfully, the resulting Markdown file containing the change log is saved in the project's .changeset
directory. The contents will look like the following.
When the project version needs to be updated, execute the following command.
Executing modern bump
will modify the version number in package.json
based on the contents of the Markdown file in the .changeset/
directory where the changes were recorded, and generate the CHANGELOG.md
file. These Markdown files are also deleted when the version update is complete, so they are "consumed ".
To publish a project, you can execute the following command.
The modern release
command publishes the project to the npm Registry.
The release is the latest
version, which is also the official version. If you want to change the dist-tag
, you can specify it with the modern release --tag
command. For example.
However, if you want to change the version number of the current project to a pre-release as well, you need to use the modern pre
command.
dist-tag
can be understood as: tagging the current release. Generally speaking, thedist-tag
for the default release islatest
, so you can considerlatest
as thedist-tag
for the official release.
When a pre-release is needed before the official release, the following command is executed.
First modern pre enter <tag>
to enter pre-release mode, <tag>
can be the same as the tag
specified with the modern release --tag
command when releasing the project.
Then you can update the specific version number with the modern bump
command, which doesn't actually "consume" the Markdown file that records the changes:
Then you can see that the updated version number in package.json
will look like this: 0.1.2-next.0
.
Finally, if you don't need to do a pre-release anymore, be sure to run the modern pre exit
command to exit the pre-release state and to release the official version when you run the modern bump
command again.