This repository is a template for managing a monorepo with npm packages. It's designed to streamline the development of TypeScript-based npm packages with a shared core package.
This monorepo includes the following packages:
core
: A foundational package that is used by other packages in this monorepo.package1
: An npm package that depends oncore
.package2
: Another npm package that also depends oncore
.
Each package is configured with TypeScript and includes a Rollup build setup to create distributable artifacts.
- ESLint Configuration: Includes
@mrcointreau/eslint-config-typescript
for consistent TypeScript linting. - TypeScript Configuration: Centralized tsconfig for consistent TypeScript compilation settings.
- Rollup Build: Each package is equipped with a Rollup build configuration to create the
dist
directory for publishing. - Automated Release Workflow: Utilizes GitHub Actions for CI/CD to automate the release process.
To get started with this monorepo, clone the repository and install dependencies:
git clone https://github.com/mrcointreau/npm-packages-monorepo-template
cd npm-packages-monorepo-template
npm install
You can work on each package individually. Navigate to the package directory and start developing:
cd packages/package1
# work on package1
Each package can be built using Rollup. From within a package's directory, run:
npm run build
This command will compile the TypeScript source and create a dist
folder with the build artifacts.
To release a package, follow these steps:
-
Create a Release Branch: Create and switch to a release branch named
release-[package_name]
:git checkout -b release-package1
-
Push to GitHub: Push the branch to GitHub:
git push origin release-package1
-
Trigger the Release CI: The push will trigger the release CI GitHub workflow, which will build, version, and publish your package to the npm registry.
-
Merge the Branch: After the release CI workflow has successfully completed, it will update the
package.json
andCHANGELOG.md
in the package folder. You should then merge the release branch back into your main branch:git checkout main git merge release-package1 git push origin main
This process ensures that your package is versioned, built, and published automatically, while also keeping your repository's main branch up-to-date with the latest changes.