Migrate from yarn to pnpm and drop lerna in the process#1931
Migrate from yarn to pnpm and drop lerna in the process#1931
yarn to pnpm and drop lerna in the process#1931Conversation
🦋 Changeset detectedLatest commit: 8f7de67 The changes in this PR will be included in the next version bump. This PR includes changesets to release 33 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
| - &restore_yarn_cache_node_18 | ||
| keys: | ||
| - v1-yarn-cache-node_18-{{ .Branch }}-{{ checksum "yarn.lock" }} | ||
| - v1-yarn-cache-node_18-{{ .Branch }} | ||
| - v1-yarn-cache-node_18 | ||
|
|
||
| - &save_yarn_cache_node_18 | ||
| key: v1-yarn-cache-node_18-{{ .Branch }}-{{ checksum "yarn.lock" }} | ||
| paths: | ||
| - ~/.cache/yarn | ||
|
|
||
|
|
||
| - &restore_yarn_cache_node_20 | ||
| keys: | ||
| - v1-yarn-cache-node_20-{{ .Branch }}-{{ checksum "yarn.lock" }} | ||
| - v1-yarn-cache-node_20-{{ .Branch }} | ||
| - v1-yarn-cache-node_20 | ||
|
|
||
| - &save_yarn_cache_node_20 | ||
| key: v1-yarn-cache-node_20-{{ .Branch }}-{{ checksum "yarn.lock" }} | ||
| paths: | ||
| - ~/.cache/yarn | ||
|
|
||
| - &restore_yarn_cache_node_22 | ||
| keys: | ||
| - v1-yarn-cache-node_22-{{ .Branch }}-{{ checksum "yarn.lock" }} | ||
| - v1-yarn-cache-node_22-{{ .Branch }} | ||
| - v1-yarn-cache-node_22 | ||
|
|
||
| - &save_yarn_cache_node_22 | ||
| key: v1-yarn-cache-node_22-{{ .Branch }}-{{ checksum "yarn.lock" }} | ||
| paths: | ||
| - ~/.cache/yarn | ||
|
|
||
| - &yarn_install | ||
| name: Installing | ||
| command: yarn --frozen-lockfile |
There was a problem hiding this comment.
We can simplify large parts of this:
- We don't need a cache per Node.js version. Package managers don't install differently based on Node.js versions
- We can migrate this into a command. That way it's native to CircleCI and validated by its language server also locally
| working_directory: *working_directory | ||
|
|
||
| commands: | ||
| pnpm_install: |
There was a problem hiding this comment.
This is the command to replace everything above.
| - run: *yarn_install | ||
| - save_cache: *save_yarn_cache_node_18 | ||
| - pnpm_install | ||
| - run: |
There was a problem hiding this comment.
I suggest not to build as a post install. It's not needed and frustrating. If we don't do that we must do it here.
| - name: Read .nvmrc | ||
| run: echo ::set-output name=NVMRC::$(cat .nvmrc) | ||
| id: nvm | ||
|
|
||
| - name: Setup Node (uses version in .nvmrc) | ||
| uses: actions/setup-node@v2 | ||
| - name: Install pnpm | ||
| uses: pnpm/action-setup@v4.1.0 | ||
| with: | ||
| node-version: '${{ steps.nvm.outputs.NVMRC }}' | ||
| run_install: false | ||
|
|
||
| - name: Get yarn cache | ||
| id: yarn-cache | ||
| run: echo "::set-output name=dir::$(yarn cache dir)" | ||
|
|
||
| - uses: actions/cache@v4 | ||
| - name: Setup Node (uses version in .nvmrc) | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| path: ${{ steps.yarn-cache.outputs.dir }} | ||
| key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
| restore-keys: | | ||
| ${{ runner.os }}-yarn- |
There was a problem hiding this comment.
Large parts here can be offloaded to the action-setup.
| @@ -0,0 +1 @@ | |||
| pnpm commitlint --edit $1 | |||
There was a problem hiding this comment.
Husky has to be updated in the process. It has now files here instead of a global config file.
| "clean": "rm -rf coverage; manypkg exec rimraf lib dist node_modules; rm -rf node_modules", | ||
| "commit": "git-cz", | ||
| "build": "lerna run build --no-private", | ||
| "build": "pnpm --recursive run build", |
There was a problem hiding this comment.
pnpm has this which allows us to drop lerna.
| "packages/*" | ||
| ], | ||
| "dependencies": { | ||
| "resolutions": { |
| "chalk": "3.0.0" | ||
| }, | ||
| "packageManager": "pnpm@9.15.6", | ||
| "devDependencies": { |
There was a problem hiding this comment.
Semi important: root package.json files should not contain deps but devDeps. We use things in there for development.
| @@ -0,0 +1,11 @@ | |||
| #!/usr/bin/env bash | |||
There was a problem hiding this comment.
Easier to maintain than an inline run script.
| "target": "esnext", | ||
| "allowJs": false, | ||
| "baseUrl": ".", | ||
| "skipLibCheck": true, |
There was a problem hiding this comment.
Needed at the moment for one package. I don't see a major downside. I plan to enable this later again.
c17fb85 to
4269cf9
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1931 +/- ##
==========================================
+ Coverage 94.65% 97.76% +3.10%
==========================================
Files 148 147 -1
Lines 5105 4779 -326
Branches 1380 1277 -103
==========================================
- Hits 4832 4672 -160
+ Misses 270 104 -166
Partials 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
PR Overview
This PR migrates the project from yarn to pnpm while also dropping lerna in favor of a new dependency management strategy. Key changes include updating changesets, CircleCI configurations, GitHub release workflows, and contributing documentation to reflect the migration.
Reviewed Changes
| File | Description |
|---|---|
| .changeset/silver-tips-serve.md | Adds a changeset specifying major version bumps for several packages. |
| .circleci/config.yml | Replaces yarn commands and cache logic with pnpm alternatives in CI pipelines. |
| .github/workflows/release.yml | Updates the release workflow to use pnpm for dependency installation, building, and publishing. |
| CONTRIBUTING.md | Revises installation and command instructions to use pnpm, though still retains a reference to lerna. |
| husky.config.js | Removes the husky configuration, potentially impacting commit hooks management. |
Copilot reviewed 97 out of 97 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
husky.config.js:1
- The husky.config.js file has been removed; if commit hooks are still needed, please ensure they are configured elsewhere and update the documentation accordingly.
module.exports = {
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
islam3zzat
left a comment
There was a problem hiding this comment.
This clearly involved a great deal of effort, thank you so much!
| command: pnpm test:ci | ||
| - run: | ||
| name: Running test (with coverage report) | ||
| command: yarn test:ci | ||
| command: pnpm test:ci |
There was a problem hiding this comment.
I'm not sure why we used to run the tests twice!
Summary
This migrates from
yarntopnpmwhich we adopted across repositories. It's speedier for installs are more strict about dependency resolution.At the same time we can drop
lernain the process and replace it withmanypkgwhich enforces dependency rules across the repository.