This is a sample npm packages in monorepo hosted at GitHub Packages.
Use Lerna to run commands and publish packages.
- Use Yarn Workspaces to install development packages.
- Use Lerna to build and publish packages.
- Import without including
dist
in the path. Copypackage.json
todist
directory when publish packages. - Use tsc-alias to replace alias paths with relative paths.
Sample project is here.
Create .npmrc
:
@himajin-dev:registry=https://npm.pkg.github.com
Install npm packages:
npm install @himajin-dev/sample-monorepo-npm-package-foo
npm install @himajin-dev/sample-monorepo-npm-package-bar
npm install @himajin-dev/sample-monorepo-npm-package-baz
Import packages:
import { bar } from "@himajin-dev/sample-monorepo-npm-package-baz/foo/bar";
bar("hello")
Install dependencies:
yarn install
Transpile to JavaScript:
yarn build
Publish to GitHub Packages:
Note that this is not yarn publish
command.
yarn run publish
If you are not logged in, log in to GitHub Packages:
npm login --registry=https://npm.pkg.github.com