-
Notifications
You must be signed in to change notification settings - Fork 10
Architecture
- Monorepo
- Multi - package split logic, combined release
- Pure ESM, since
v1.0.1
Monorepo was used for the repository and initially I planned to use yarn + lerna
to manage the workspace and dependency distribution, but after more than half a year of evaluation in other projects, I decided to use pnpm + changeset
instead, as it seems to be more concise and flexible than the previous solution
@vrn-deco/cli
is split from a single package
into multiple sub-packages
, all of which are prefixed with @vrn-deco/cli-
. Each sub-package
is only responsible for implementing its own functional logic, and they also depend on each other for reuse, and finally the functionality of all sub-packages
is aggregated to @vrn-deco/cli
.
Each sub-package
is a separate npm package
, but the version number is managed uniformly (unlike the vrn-boilerplate
repository)
For example, there are two packages
, a
and b
, both with version 1.0.0
.
When a
releases patch
because of fix
, a
and b
are both updated to 1.0.1
When b
releases Minor
because of feat
, both a
and b
are updated to 1.1.0
Whenever a package
changes in the repository, all packages
are synchronized with the updated version
Finally, these packages
are build and published in a uniform topological order
Well, it was a impulsive decision, and it wasn't in the original plan. The reason for this is that there has been a wave of ESMization in the community over the last half year, led by Sindresorhus, and the fact that since Node.js 14.13.1
, ESM is no longer marked as an experimental feature, and many libraries that were originally written in CommonJS or compiled as CommonJS libraries have been converted to Pure ESM
. After all, this is the future trend of Node.js and browser unification, so I started to explore how to convert packages from my own repository to Pure ESM
.
Thanks to Sindresorhus for the article Pure ESM package, everything went smoothly and following that guide I managed to convert all packages in the repository to Pure ESM
and run it successfully in ^14.13.1 || >=16.0.0
of Node.js. Unfortunately, as of February 2022, Jest
didn't have very good support for ESM, so I had a lot of trouble testing it and very few valid solutions to the problem on Google, but it was solved