rollup + yarn workspaces 管理多个包
- 如果使用作用域 @lerna-demo ,先要创建org,具体参考官方文档
- 在根目录创建.npmrc,内容为 //registry.npmjs.org/:_authToken=<
token>,方便提交到npm
yarn config set workspaces-experimental true
yarn
yarn add *any_pack* -W
npm run build:all
npm run build:changed
npm run build:w
npm run storybook
打开 http://localhost:6006
如果storybook需要显示jest结果,则要执行该命令
npm run test:generate-output
npm run tslint
npm run release
lerna√tslint√stylelint√storybook√push to npm√jest√husky√lint-staged√
要打上标签,
lerna diff对比的是上个打上标签的提交,和最后提交这俩个提交进行对比的 所以,建议每次发布都打上标签如 v0.0.1,v0.0.2之类的,Annotated Tags语句
填写token到.npmrc中,内容如下
//registry.npmjs.org/:_authToken=.................
git tag -a v0.0.1 -m "my version 0.0.1"
如果没有上Annotated Tags,lerna changed会无法找到改变的包,因为本质是使用git describe命令
- 没有加入Annotated Tags
fatal: No annotated tags can describe 'f87c255432d4fa4656ef37f9f28bdd94f6b55fa5'
.
However, there were unannotated tags: try --tags.
- 加入tag
D:\project-demo\yarn-workspaces-demo>git describe
v0.0.1
lerna publish --no-git-tag-version:取消自动打标签,lerna不会自动更新包的版本了pack1版本是0.0.1,推送到npm后,本地依旧是0.0.1lerna publish:自动更新包的版本,为最后的提交打上每个包的版本标签,然后再推送
lerna只会找当前的分支进行标签对比,然后判断是否要发布,如果标签打在其他分支上面,lerna会忽略
lerna publish --no-git-reset:lerna自动更新包的版本了lerna publish:lerna根据上个标签的更新包的版本
SyntaxError: D:\project-demo\react-bhy\packages\tree\src\components\node\style.scss: Unexpected digit after hash token (1:8) jest.config.js 下面的代码导致的错误
"moduleNameMapper": {
"^lodash-es$": "lodash"
}