Try   HackMD

Fong - Lerna 的套件管理術

歡迎來到 JSDC 2020 下半場 | 術場 (14:00 ~ 17:00) 共筆

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

共筆入口:https://hackmd.io/9r79EYfvTgW23Yy9fgTFxA

點選主題就可以進到個別場次的共筆

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

tags: jsdc2020, 下半場 - 術場

問題

  • 重複程式
  • 更新舊 npm package
  • 難以追蹤修改程式碼
  • github repos/microservices 中 ci/cd 依賴性難管理

MonoRepo Pros

  • 提升對於整體軟體架構理解力
  • 重用性 & single sources of truth
  • 簡化依賴性管理
  • 跨專案模組的重構 & Debug
  • 一致的 ci/cd pipeline 設定

MonoRepo Cons

  • 各子專案設定的彈性比較少
  • 沒辦法對各個子專案作 Read/Write 權限管理
  • 程式碼 Size 直線上升
  • 導入時的設定較複雜

Lerna

把 JS 專案當作 Multiple package 來管理的工具

在一個 Repo 中,可以獨立地測試、建置 Image、部屬、發佈各個 Package

根據有無被修改來觸發

誰在用

  • babel/babel
  • Facebook / jest

Definitions

  • Lerna Package:被管理的 JS Package 單位
    • 可以做完一個獨立的專案、套件
    • Lerna Package 間可以互相依賴
  • Lerna Workspace:放置、分類 Lerna Packages 的地方

CI/CD

  • 透過 --since <tag> 只對有變更的 package 進行各項操作

Yarn vs Lerna

https://classic.yarnpkg.com/en/docs/workspaces/#toc-how-does-it-compare-to-lerna