A repository for trying a JS/TS npm library monorepo setup using pnpm
as package manager and parcel
as a build tool.
Development prerequisites:
This is an overview of the most important components of this monorepo's tech stack
- pnpm -- package and monorepo workspace manager
- Parcel -- build tool
- Jest /
ts-jest
-- Unit testing framework - TypeScript /
tsc
-- TypeScript type checking - TypeScript ESLint -- linting
- Prettier -- code formatter
- fliegdoc -- documentation generator
- GitHub Actions -- CI pipeline
- Renovate -- Dependency Update Management
Install the dependencies:
pnpm install
- automatically runs recursively for the workspace, cf. https://pnpm.io/cli/install
- Alias:
pnpm i
npm ci
-equivalent:pnpm i --frozen-lockfile
(automatically true in CI environment)
You can also run pnpm install
when anything about your dependencies becomes out of date to fix it back up.
Run commands in the package's directory:
pnpm add [-D] @fliegwerk/logsemts
pnpm add [-D] --workspace [package-name]
--workspace
ensures that it is installed from the workspace directory.- by default installs as
workspace:^[version]
. I recommend adjusting this toworkspace:^
afterwards to make it an easier workflow for updates (this "version specifier" gets replaced automatically with the correct version on publish)
In root directory:
pnpm add -D -w @parcel/core
-w
"enables" running this in the workspace root (otherwise forbidden to ensure that you don't accidentally install it in the workspace root)
In root directory:
pnpm watch
Install all pacakges in the workspace root (like the development dependencies, but without the -D
argument).
Then, simply run node
in the root directory, and you can require()
all packages.
In root directory:
pnpm test
or
pnpm exec jest
In root directory:
pnpm lint
In root directory:
pnpm prettier:fix
In root directory:
pnpm prettier:check
In root directory:
pnpm build
In root directory:
pnpm docs
This builds a static documentation page to /docs
using fliegdoc
.
After adjusting package versions (TODO: find a way to automate this):
In root directory:
pnpm publish -r
- package versions in subpackages'
package.json
files get replaced automatically in the published version - requires a clean git tree
- Find a way to use conventional commits for automatically adjusting package versions