lerna基本试用
安装
yarn global add lerna or npm install -g lerna
基本项目
- 初始化
git init platform cd platform lerna init 效果如下: ├── lerna.json ├── package.json └── packages
- 创建包common && server
mkdir common server common ├── index.js └── package.json index.js module.exports={ name:"dalong-common 1.0.0", type:"common" } package.json { "name": "common", "version": "1.0.0", "main": "index.js", "license": "MIT" } server ├── index.js ├── package-lock.json └── package.json index.js const common =require("common"); console.log(common); package.json { "name": "server", "version": "1.0.0", "main": "index.js", "license": "MIT", "dependencies": { "common": "1.0.0", "shortid": "^2.2.8" } }
处理依赖
lerna bootstrap
效果如下:
测试
node packages/server { name: 'dalong-common 1.0.0', type: 'common' }
说明
这个只是简单的使用,实际可以做的事情的很多,比如changelog issue 。。。 类似的yarn 也是一个不错的工具
参考资料
https://yarnpkg.com/blog/2017/08/02/introducing-workspaces/
https://lernajs.io/
https://github.com/rongfengliang/lerna-demo-project