Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Monorepos: Lerna VS npm/yarn/pnpm workspace #274

Open
yaofly2012 opened this issue May 16, 2023 · 1 comment
Open

Monorepos: Lerna VS npm/yarn/pnpm workspace #274

yaofly2012 opened this issue May 16, 2023 · 1 comment

Comments

@yaofly2012
Copy link
Owner

yaofly2012 commented May 16, 2023

Monorepo架构

image

  1. Monolith: 所有模块都在一个git仓库,一起发布部署
  2. Multi-Repo:一个模块一个git仓库
  3. Mono-Repo:所有模块都在一个git仓库,但是模块可以单独发布

Lerna

常用命令

Lerna本身命令就不多。

lerna init    // 初始化项目
lerna clean    // 清除项目中所有 node_modules
lerna create    // 创建项目中的子package'

lerna bootstrap // 会把所有包的依赖安装到项目根node_modules  
lerna add // 增加本地或者远程package 做为当前项目 packages 里面的依赖  例: `lerna add packageA --scope=packageB`  
lerna run // 运行所有包里面的有这个script的命令  
lerna exec // 在每个包中执行任意命令,例: `lerna exec 'npm remove lodash'`

// 发布相关
lerna changed // 列出下次发版lerna publish 要更新的包
lerna diff       // 自上次发布以来,对所有包或单个包进行区分 
lerna publish // 发布版本  

package权限控制 ???

由于所有的模块都在一个Git仓库里,一旦有了Git访问权限意味着你可以修改所有package的代码。比如说,开发web和开发mobile平台的是两个不同的团队,假如我作为web组的一员,一不小心修改了或删除了mobile项目的文件该怎么办?假如不加入任何限制,这种事情迟早会发生。
怎么办呢?

workspaces能替换Lerna吗

参考

  1. Lerna
  2. Is Lerna needed anymore with NPM 7.0.0's workspaces?
  3. Replacing Lerna + Yarn with PNPM Workspaces
  4. 为什么前端工程越来越爱使用Monorepo架构
@yaofly2012
Copy link
Owner Author

npm workspaces

@yaofly2012 yaofly2012 changed the title Monorepos: Lerna, npm workspace Monorepos: Lerna, npm/yarn/pnpm workspace May 16, 2023
@yaofly2012 yaofly2012 changed the title Monorepos: Lerna, npm/yarn/pnpm workspace Monorepos: Lerna VS npm/yarn/pnpm workspace May 16, 2023
@yaofly2012 yaofly2012 changed the title Monorepos: Lerna VS npm/yarn/pnpm workspace Monorepos: Lerna vs npm/yarn/pnpm workspace May 16, 2023
@yaofly2012 yaofly2012 changed the title Monorepos: Lerna vs npm/yarn/pnpm workspace Monorepos: Lerna VS npm/yarn/pnpm workspace May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant