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

refactor: change the package manager to pnpm #3438

Merged
merged 10 commits into from
Feb 18, 2025

Conversation

oljc
Copy link
Member

@oljc oljc commented Feb 13, 2025

Types of changes

  • New feature
  • Bug fix
  • Enhancement
  • Component style change
  • Typescript definition change
  • Documentation change
  • Coding style change
  • Refactoring
  • Test cases
  • Continuous integration
  • Breaking change
  • Others

Background and context

Closes #2841

现有的 Monorepo 采用 lerna + yarn workspace 方案,目前社区开源环境下存在诸多问题,影响维护和贡献体验,包括:

  • 安装复杂: 依赖安装过程繁琐,存在多个命令步骤,容易导致环境不一致和安装失败
  • 依赖管理混乱: 存在幻影依赖、幽灵依赖、隐式依赖问题各包对依赖的引用可能不明确,整体依赖关系不可控,不利于自动化管理增加了维护难度
  • 性能问题: 新开发者首次克隆和安装依赖的时间较长,lerna 需要手动处理链接和安装的逻辑

此次迁移旨在提升整体开发体验、优化依赖管理,并降低维护成本,让项目更适应开源协作环境。

Solution

变更包管理为 PNPM

将原本的 lerna + yarn 多包方案迁移至 pnpm workspaces 方案

How is the change tested?

测试工作:

  1. 环境兼容性 在不同的 Node.js 版本和包管理器环境下,验证安装和初始化流程是否正常
  2. 依赖完整性 确保各子包依赖关系正确,无幽灵依赖或缺失问题
  3. 脚本执行 运行每个子包下的 scripts 命令检查是否报错
  4. 构建及输出对比 组件及文档站点进行打包,确保产物与之前版本一致,无异常变更

Changelog

Component Changelog(CN) Changelog(EN) Related issues

Checklist:

  • Test suite passes (npm run test)
  • Provide changelog for relevant changes (e.g. bug fixes and new features) if applicable.
  • Changes are submitted to the appropriate branch (e.g. features should be submitted to feature branch and others
    should be submitted to main branch)

Other information

发包 pnpm publish

Copy link

codesandbox bot commented Feb 13, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@oljc
Copy link
Member Author

oljc commented Feb 14, 2025

迁移过程中遇到的问题和解决方案

此处记录迁移过程中遇到的问题、思考及解决方案,如有错误或更优方案,欢迎提出,积极采纳!

1. 关于各包间软链问题

之前的方案中采用 lerna link 来在工作区间内建立各个包的依赖关系。

方案:

  1. 配置 link-workspace-packages 自动建立链接
 link-workspace-packages=true
  1. 工作空间协议 workspace(目前采用):
"dependencies": {
    "@arco-design/arco-vue-scripts": "workspace:*",
}

pnpm 天然支持基于内容寻址和硬链接的依赖管理,无需额外 link 操作,pnpm install 时会自动处理 workspaces 之间的链接。

2. 首次安装依赖找不到工作区产物

这需要子包中必须存在bin/dist产物,但需要安装依赖才能编译产物。

先有鸡先有蛋?

image

目前是在 run init 的时候编译好所需产物后 pnpm i 重新建立链接解决🪄

@flsion flsion merged commit d692f54 into arco-design:main Feb 18, 2025
@Loongphy
Copy link
Contributor

一年前尝试过,很多坑,没想到今天解决了,爱你😘

@oljc oljc mentioned this pull request Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

yarn install, init 失败
3 participants