lerna &&yarn 开发流程

参考使用流程

  • 独立版本

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/

posted on 2021-04-06 23:24  荣锋亮  阅读(617)  评论(0编辑  收藏  举报

导航