參考使用流程
- 獨立版本
lerna.json
{
"packages": [
"packages/*"
],
"version": "independent", // 此處比較重要,推薦基於獨立版本模式
"npmClient": "yarn",
"useWorkspaces": true // 使用workspaces
}
pacakge.json
"private": true,
"workspaces":[
"packages/*"
],
參考命令
- 創建包
可以基於yarn 模式以及lerna 的crate - 添加依賴
可以基於lerna add 模式 - 版本
lerna version --conventional-commits // 版本提升同時包含提交信息
- 發布
lerna publish from-package --registry https://registry.npmjs.org/
- 代碼clone 使用
git clone <gitrepo> // clone 代碼
cd <dir> // 進入目錄
yarn // 安裝依賴
一些說明
- 發布配置
"public": true,
"publishConfig": {
"access": "public"
},
- yarn lock 問題
lerna.json 推薦添加以下配置
"command": {
"bootstrap": {
"npmClient": "yarn",
"npmClientArgs": [
"--frozen-lockfile"
]
}
}
參考資料
https://www.conventionalcommits.org/en/v1.0.0/
https://doppelmutzi.github.io/monorepo-lerna-yarn-workspaces/
https://github.com/lerna/lerna
https://classic.yarnpkg.com/en/docs/usage
https://pnpm.io/