Coder Social home page Coder Social logo

monorepo 新浪潮 | introduce lerna about blog HOT 22 OPEN

soda-x avatar soda-x commented on August 28, 2024 41
monorepo 新浪潮 | introduce lerna

from blog.

Comments (22)

soda-x avatar soda-x commented on August 28, 2024 1

@ZengTianShengZ 命令行直接输 export

from blog.

oMaten avatar oMaten commented on August 28, 2024

$ git commit -a -m "core-bugfix: the xxx problem had fixed, Close #1"
这里的 commit 中的 tag 似乎笔误写倒了

from blog.

soda-x avatar soda-x commented on August 28, 2024

@oMaten commit 中的 message 不需要包含 tag,label 的内容即 tag 所 map 的内容最终在 pr 阶段选择 所对应的 label 来生效

from blog.

oMaten avatar oMaten commented on August 28, 2024

@pigcan 好的谢谢~

from blog.

HenryYong avatar HenryYong commented on August 28, 2024

正在用lerna做组件库,及时雨啊。。

from blog.

okoala avatar okoala commented on August 28, 2024

commit message 不用 angular style 了,还真有点不习惯了。

from blog.

lijialiang avatar lijialiang commented on August 28, 2024

汇总一个仓库时候,会有提交日志混在同一分支线的情况。如果分多个 repos,每个 repos 的分支线都仅仅表示当前模块相关的,请问这样的问题,有什么好避免的想法?

from blog.

soda-x avatar soda-x commented on August 28, 2024

汇总一个仓库,前提是适合放在一起。

前提成立的情况下,还行日志清晰,这个就和自身 git commit message 相关了。可以参看我另外一篇文章,适合一个给自己项目的 adaptor 就可以了。

from blog.

kybetter avatar kybetter commented on August 28, 2024

放到 packages 里面的每一个 mudule,别人怎么使用呢?

比如原来multiRepo的时候,babel,babel-core 和 babel-dore 是单独的repo,我使用的时候是:npm install babel babel-core babel-dore 来进行安装使用。
现在把babel-core和babel-dore都放在babel的packages目录下作为子模块了,安装使用方式还是一样的吗?

from blog.

soda-x avatar soda-x commented on August 28, 2024

@kybetter 一样的

from blog.

kybetter avatar kybetter commented on August 28, 2024

谢谢,
如果是一样的方式,其中的逻辑我有点不太明白,想请教一下作者,这里面是什么样的机制?
如果想要在自己的本地仓库或者是私有仓库里面使用,要做哪些配置呢?还是只有npm支持这种机制?

from blog.

soda-x avatar soda-x commented on August 28, 2024

@kybetter 不管是 multiRepo 还是 monoRepo 包本质上还是独立的,只是 monoRepo 中会在 bootstrap 时把这些子包 link 起来。

不需要额外配置什么,跟着我的流程走就可以了。

from blog.

kybetter avatar kybetter commented on August 28, 2024

@pigcan
据我所知,不管是 workspace 还是 link 的方式,也仅仅在开发的时候有用,bootstrap 的时候你也看到了,它会在每个模块下进行依赖安装和 link。
但是这跟我们 build 一个项目没有多大关系啊。build 完以后成啥样了?我现在脑子里是一团糟,绕不出来。

from blog.

soda-x avatar soda-x commented on August 28, 2024

@kybetter 其实我不太理解你的问题

但还是尝试回答下:
bootstrap 时就是把你的依赖给 link 起来,即如果一个 monorepo 中有模块 a,b,c,其中 c 依赖 a 和 b,link 的作用是,a 和 b 更改后并不需要被发布, c 可以随时用最新的 a 和 b。

但是 build,我不清楚这里的 build 的含义是什么,有两种解释

  • build 指代码模块 transform

如果作为 babel transform 的话,那么就是因为我们正常情况下引用模块是用的 transform 完的(通常在 lib 下),而本地则是源码,那么就需要单独跑一个 watch 实时把源码文件 src 编译到 lib,但是这种情况下也会出现一个问题即如果我们调试 c ,却发现 a 中有报错,但是 a 是被编译后的代码,这并不利于调试,当然也有办法解决,记得我在一个脚手架中有说明,其中就是借鉴了 cssnano 的设计方式。

  • build 指项目构建

如果指的是项目构建(构建到 web 或者 electron 等),那么你在采用 monoRepo 时就是混用了项目和模块,建议分开,项目即项目,模块即模块;当然一定要合在一起也可以,那么项目构建应该和 monoRepo 的流程没啥关系。这个时候的 build 更多意思是构建一份可在目标容器执行的代码。

from blog.

kybetter avatar kybetter commented on August 28, 2024

@pigcan 非常感谢,通过学习我知道 monoRepo 和它的管理方式了,我之前提的问题可能是把 multiRepo 的概念混合进来了,所以造成了理解偏差。

from blog.

qq13836848 avatar qq13836848 commented on August 28, 2024

请问下,lerna下项目和模块怎么管理呢,是把项目和模块放在lerna下座位不同的package吗,我这样理解对吗。

from blog.

soda-x avatar soda-x commented on August 28, 2024

@qq13836848 en

from blog.

yanhaijing avatar yanhaijing commented on August 28, 2024

感谢

from blog.

AimLuo avatar AimLuo commented on August 28, 2024

请教个问题:如何发布组件库到git,而不是npm仓库?

前提描述

公司只有git仓库可用。
我使用lerna开发组件库,仓库名为my-component
lerna.json配置如下:

{
  "packages": [
    "packages/*"
  ],
  "useWorkspaces": true,
  "npmClient": "yarn",
  "version": "0.0.1",
  "publishConfig": {
    "directory": "dist"
  }
}

根目录的package.json配置中增加:

"private": true,
"workspaces": [
  "packages/**"
]

packages中每个组件(项目)的package.json增加:

"private": true

问题描述:

lerna publish命令可以设置发布组件打包后的distnpm或者私人搭建的npm仓库。但是公司代码是不可能发布到npm的,而且也没有搭建私人npm仓库。这就造成我的业务代码也只能放在packages中开发,这样才能import我开发的组件。

疑问?

能否通过lerna publish发布到本地,我把这些文件(只有打包后的dist文件)上传到公司git,再通过yarn add xxxx/my-component-release.git下载到对应的业务代码项目中。主要就是想通过yarn add xxxx/my-component-release.git来添加私有依赖包

我现在的解决方案

通过git subtree拉取my-component,然后根目录的package.json配置:

"private": true,
"workspaces": [
  "my-component/**"
]

这样我就可以在业务项目中使用自己开发的组件库了。

from blog.

soda-x avatar soda-x commented on August 28, 2024

@AimLuo

lerna publish 可能有默认的行为(比如打 tag,发包等),但是这些行为可以通过配置项去除。

如果你想要建立在现有工作流方式上做,建议自己写发布脚本,但是在发布脚本内,可以调用 lerna 来管理流程,但是最终比如到发布环节,直接走你自己的流程就好了。

from blog.

ZengTianShengZ avatar ZengTianShengZ commented on August 28, 2024

step 3:

$ export GITHUB_AUTH="..."

这步骤啥意思呢,我已经拿到了github 的 token,哪里配置 export

from blog.

AlenOne avatar AlenOne commented on August 28, 2024

在执行node_modules/.bin/lerna-changelog的时候报错Could not infer "repo" from the "package.json" file.,但是我配置了"repo": "AlenOne/lerna"

from blog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.