Skip to content

Commit 12afb2e

Browse files
Migrate to pnpm (#11358)
1 parent c7dd3d3 commit 12afb2e

25 files changed

+10920
-10527
lines changed

.changeset/config.json

+1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
"access": "public",
1818
"baseBranch": "dev",
1919
"updateInternalDependencies": "patch",
20+
"bumpVersionsWithWorkspaceProtocolOnly": true,
2021
"ignore": []
2122
}

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/fixtures/
22
node_modules/
3+
pnpm-lock.yaml
34
/docs/api
45
examples/**/dist/
56
packages/**/dist/

.github/workflows/deduplicate-yarn.yml .github/workflows/deduplicate-lock-file.yml

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
name: ⚙️ Deduplicate yarn.lock
1+
name: ⚙️ Deduplicate lock file
22

33
on:
44
push:
55
branches:
66
- dev
77
paths:
8-
- ./yarn.lock
8+
- ./pnpm-lock.yaml
99

1010
concurrency:
1111
group: ${{ github.workflow }}-${{ github.ref }}
@@ -20,14 +20,17 @@ jobs:
2020
- name: ⬇️ Checkout repo
2121
uses: actions/checkout@v4
2222

23+
- name: 📦 Setup pnpm
24+
uses: pnpm/[email protected]
25+
2326
- name: ⎔ Setup node
2427
uses: actions/setup-node@v4
2528
with:
2629
node-version-file: ".nvmrc"
27-
cache: "yarn"
30+
cache: "pnpm"
2831

29-
- name: ⚙️ Dedupe yarn.lock
30-
run: npx yarn-deduplicate && rm -rf ./node_modules && yarn
32+
- name: ⚙️ Dedupe lock file
33+
run: pnpm dedupe && rm -rf ./node_modules && pnpm install
3134

3235
- name: 💪 Commit
3336
run: |
@@ -38,6 +41,6 @@ jobs:
3841
echo "💿 no deduplication needed"
3942
exit 0
4043
fi
41-
git commit -m "chore: deduplicate `yarn.lock`"
44+
git commit -m "chore: deduplicate `pnpm-lock.yaml`"
4245
git push
4346
echo "💿 https://github.com/$GITHUB_REPOSITORY/commit/$(git rev-parse HEAD)"

.github/workflows/format.yml

+6-3
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,23 @@ jobs:
2121
with:
2222
token: ${{ secrets.FORMAT_PAT }}
2323

24+
- name: 📦 Setup pnpm
25+
uses: pnpm/[email protected]
26+
2427
- name: ⎔ Setup node
2528
uses: actions/setup-node@v4
2629
with:
27-
cache: yarn
30+
cache: pnpm
2831
node-version-file: ".nvmrc"
2932

3033
- name: 📥 Install deps
31-
run: yarn --frozen-lockfile
34+
run: pnpm install --frozen-lockfile
3235

3336
- name: 🔃 Sort contributors.yml
3437
run: sort --ignore-case --output contributors.yml contributors.yml
3538

3639
- name: 👔 Format
37-
run: yarn format
40+
run: pnpm format
3841

3942
- name: 💪 Commit
4043
run: |

.github/workflows/release-experimental.yml

+7-4
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,25 @@ jobs:
2222
with:
2323
fetch-depth: 0
2424

25+
- name: 📦 Setup pnpm
26+
uses: pnpm/[email protected]
27+
2528
- name: ⎔ Setup node
2629
uses: actions/setup-node@v4
2730
with:
28-
cache: yarn
31+
cache: pnpm
2932
node-version-file: ".nvmrc"
3033

3134
- name: 📥 Install deps
32-
run: yarn --frozen-lockfile
35+
run: pnpm install --frozen-lockfile
3336

3437
- name: 🏗 Build
35-
run: yarn build
38+
run: pnpm build
3639

3740
- name: 🔐 Setup npm auth
3841
run: |
3942
echo "registry=https://registry.npmjs.org" >> ~/.npmrc
4043
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
4144
4245
- name: 🚀 Publish
43-
run: npm run publish
46+
run: pnpm run publish

.github/workflows/release.yml

+11-5
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,17 @@ jobs:
2727
with:
2828
fetch-depth: 0
2929

30+
- name: 📦 Setup pnpm
31+
uses: pnpm/[email protected]
32+
3033
- name: ⎔ Setup node
3134
uses: actions/setup-node@v4
3235
with:
3336
node-version-file: ".nvmrc"
34-
cache: "yarn"
37+
cache: "pnpm"
3538

3639
- name: 📥 Install deps
37-
run: yarn --frozen-lockfile
40+
run: pnpm install --frozen-lockfile
3841

3942
- name: 🔐 Setup npm auth
4043
run: |
@@ -50,10 +53,10 @@ jobs:
5053
id: changesets
5154
uses: changesets/action@v1
5255
with:
53-
version: yarn run version
56+
version: pnpm run version
5457
commit: "chore: Update version for release"
5558
title: "chore: Update version for release"
56-
publish: yarn run release
59+
publish: pnpm run release
5760
createGithubReleases: false
5861
env:
5962
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -70,11 +73,14 @@ jobs:
7073
- name: ⬇️ Checkout repo
7174
uses: actions/checkout@v4
7275

76+
- name: 📦 Setup pnpm
77+
uses: pnpm/[email protected]
78+
7379
- name: ⎔ Setup node
7480
uses: actions/setup-node@v4
7581
with:
7682
node-version: 16
77-
cache: "npm"
83+
cache: "pnpm"
7884

7985
- id: find_package_version
8086
run: |

.github/workflows/test.yml

+9-6
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,13 @@ jobs:
3535
- name: ⬇️ Checkout repo
3636
uses: actions/checkout@v4
3737

38+
- name: 📦 Setup pnpm
39+
uses: pnpm/[email protected]
40+
3841
- name: ⎔ Setup node
3942
uses: actions/setup-node@v4
4043
with:
41-
cache: yarn
44+
cache: pnpm
4245
check-latest: true
4346
node-version: ${{ matrix.node }}
4447

@@ -49,16 +52,16 @@ jobs:
4952
echo "::remove-matcher owner=eslint-stylish::"
5053
5154
- name: 📥 Install deps
52-
run: yarn --frozen-lockfile
55+
run: pnpm install --frozen-lockfile
5356

5457
- name: 🏗 Build
55-
run: yarn build
58+
run: pnpm build
5659

5760
- name: 🔬 Lint
58-
run: yarn lint
61+
run: pnpm lint
5962

6063
- name: 🧪 Run tests
61-
run: yarn test
64+
run: pnpm test
6265

6366
- name: Check bundle size
64-
run: yarn size
67+
run: pnpm size

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ npm-debug.log
66
node_modules/
77

88
/examples/*/yarn.lock
9+
/examples/*/pnpm-lock.yaml
910
/examples/*/dist
1011
/tutorial/dist
1112

.npmrc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
ignore-workspace-cycles=true
2+
enable-pre-post-scripts=true

DEVELOPMENT.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Changesets will do most of the heavy lifting for our releases. When changes are
1616
### Starting a new pre-release
1717

1818
- Ensure you are on the new `release-*` branch.
19-
- Enter Changesets pre-release mode using the `pre` tag: `yarn changeset pre enter pre`.
19+
- Enter Changesets pre-release mode using the `pre` tag: `pnpm changeset pre enter pre`.
2020
- Commit the change and push the `release-*` branch to GitHub.
2121
- Wait for the release workflow to finish. The Changesets action in the workflow will open a PR that will increment all versions and generate the changelogs.
2222
- Review the updated `CHANGELOG` files and make any adjustments necessary, then merge the PR into the `release-*` branch.
@@ -32,7 +32,7 @@ Changesets will do most of the heavy lifting for our releases. When changes are
3232
You may need to make changes to a pre-release prior to publishing a final stable release. To do so:
3333

3434
- Make whatever changes you need.
35-
- Create a new changeset: `yarn changeset`.
35+
- Create a new changeset: `pnpm changeset`.
3636
- **IMPORTANT:** This is required even if you ultimately don't want to include these changes in the logs. Remember, changelogs can be edited prior to publishing, but the Changeset version script needs to see new changesets in order to create a new version.
3737
- Commit the changesets and push the `release-*` branch to GitHub.
3838
- Wait for the release workflow to finish and the Changesets action to open its PR that will increment all versions.
@@ -42,7 +42,7 @@ You may need to make changes to a pre-release prior to publishing a final stable
4242

4343
### Publishing the stable release
4444

45-
- Exit Changesets pre-release mode: `yarn changeset pre exit`.
45+
- Exit Changesets pre-release mode: `pnpm changeset pre exit`.
4646
- Commit the edited pre-release file along with any unpublished changesets, and push the `release-*` branch to GitHub.
4747
- Wait for the release workflow to finish. The Changesets action in the workflow will open a PR that will increment all versions and generate the changelogs for the stable release.
4848
- Review the updated `CHANGELOG` files and make any adjustments necessary.
@@ -71,6 +71,6 @@ Experimental releases and hot-fixes do not need to be branched off of `dev`. Exp
7171

7272
- Create a new branch for the release: `git checkout -b release-experimental`
7373
- Make whatever changes you need and commit them: `git add . && git commit "experimental changes!"`
74-
- Update version numbers and create a release tag: `yarn run version:experimental`
74+
- Update version numbers and create a release tag: `pnpm run version:experimental`
7575
- Push to GitHub: `git push origin --follow-tags`
7676
- The CI workflow should automatically trigger from the experimental tag to publish the release to npm

docs/guides/contributing.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ cd react-router
3030
git checkout dev
3131
```
3232

33-
3. Install dependencies and build. React Router uses [`yarn` (version 1)](https://classic.yarnpkg.com/lang/en/docs/install), so you should too. If you install using `npm`, unnecessary `package-lock.json` files will be generated.
33+
3. Install dependencies and build. React Router uses [pnpm](https://pnpm.io), so you should too. If you install using `npm`, unnecessary `package-lock.json` files will be generated.
3434

3535
## Think You Found a Bug?
3636

@@ -72,22 +72,22 @@ All commits that change or add to the API must be done in a pull request that al
7272

7373
React Router uses a monorepo to host code for multiple packages. These packages live in the `packages` directory.
7474

75-
We use [Yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces/) to manage installation of dependencies and running various scripts. To get everything installed, make sure you have [Yarn (version 1) installed](https://classic.yarnpkg.com/lang/en/docs/install), and then run `yarn` or `yarn install` from the repo root.
75+
We use [pnpm workspaces](https://pnpm.io/workspaces/) to manage installation of dependencies and running various scripts. To get everything installed, make sure you have [pnpm installed](https://pnpm.io/installation), and then run `pnpm install` from the repo root.
7676

7777
### Building
7878

79-
Calling `yarn build` from the root directory will run the build, which should take only a few seconds. It's important to build all the packages together because `react-router-dom` and `react-router-native` both use `react-router` as a dependency.
79+
Calling `pnpm build` from the root directory will run the build, which should take only a few seconds. It's important to build all the packages together because `react-router-dom` and `react-router-native` both use `react-router` as a dependency.
8080

8181
### Testing
8282

83-
Before running the tests, you need to run a build. After you build, running `yarn test` from the root directory will run **every** package's tests. If you want to run tests for a specific package, use `yarn test --projects packages/<package-name>`:
83+
Before running the tests, you need to run a build. After you build, running `pnpm test` from the root directory will run **every** package's tests. If you want to run tests for a specific package, use `pnpm test --projects packages/<package-name>`:
8484

8585
```bash
8686
# Test all packages
87-
yarn test
87+
pnpm test
8888

8989
# Test only react-router-dom
90-
yarn test --projects packages/react-router-dom
90+
pnpm test --projects packages/react-router-dom
9191
```
9292

9393
## Repository Branching
@@ -111,7 +111,7 @@ When it's time to cut a new release, we follow a process based on our branching
111111
We create experimental releases from the current state of the `dev` branch. They can be installed by using the `@next` tag:
112112

113113
```bash
114-
yarn add react-router-dom@next
114+
pnpm add react-router-dom@next
115115
# or
116116
npm install react-router-dom@next
117117
```
@@ -133,7 +133,7 @@ git checkout -b release/v6.1.0
133133

134134
# Create a new tag and update version references throughout the
135135
# codebase.
136-
yarn run version minor # | "patch" | "major"
136+
pnpm run version minor # | "patch" | "major"
137137

138138
# Push the release branch along with the new release tag.
139139
git push origin release/v6.1.0 --follow-tags
@@ -160,11 +160,11 @@ Sometimes we have a crucial bug that needs to be patched right away. If the bug
160160
```bash
161161
# From the main branch, make sure to run the build and all tests
162162
# before creating a new release.
163-
yarn && yarn build && yarn test
163+
pnpm install && pnpm build && pnpm test
164164

165165
# Assuming the tests pass, create the release tag and update
166166
# version references throughout the codebase.
167-
yarn run version patch
167+
pnpm run version patch
168168

169169
# Push changes along with the new release tag.
170170
git push origin main --follow-tags

package.json

+7-13
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,20 @@
11
{
22
"name": "@remix-run/react-router",
33
"private": true,
4-
"workspaces": {
5-
"packages": [
6-
"packages/react-router",
7-
"packages/react-router-dom",
8-
"packages/react-router-dom-v5-compat",
9-
"packages/react-router-native",
10-
"packages/router"
11-
]
12-
},
134
"scripts": {
145
"build": "rollup -c",
156
"clean": "git clean -fdX .",
167
"format": "prettier --ignore-path .eslintignore --write .",
178
"format:check": "prettier --ignore-path .eslintignore --check .",
18-
"postinstall": "patch-package",
199
"lint": "eslint --cache .",
20-
"prerelease": "yarn build",
10+
"prerelease": "pnpm build",
2111
"release": "changeset publish",
2212
"size": "filesize",
2313
"test": "jest",
2414
"test:inspect": "node --inspect-brk ./node_modules/.bin/jest",
2515
"changeset": "changeset",
2616
"version": "changeset version && node ./scripts/remove-prerelease-changelogs.mjs",
2717
"publish": "node scripts/publish.js",
28-
"postversion": "node scripts/postversion.mjs",
2918
"version:experimental": "node ./scripts/version experimental",
3019
"watch": "rollup -c -w"
3120
},
@@ -37,6 +26,7 @@
3726
"default"
3827
]
3928
},
29+
"packageManager": "[email protected]",
4030
"resolutions": {
4131
"@types/react": "^18.2.18",
4232
"@types/react-dom": "^18.2.7",
@@ -91,7 +81,6 @@
9181
"jest": "^29.6.2",
9282
"jest-environment-jsdom": "^29.6.2",
9383
"jsonfile": "^6.1.0",
94-
"patch-package": "^6.5.1",
9584
"prettier": "^2.8.8",
9685
"prompt-confirm": "^2.0.4",
9786
"react": "^18.2.0",
@@ -130,5 +119,10 @@
130119
"packages/react-router-dom/dist/umd/react-router-dom.production.min.js": {
131120
"none": "23.5 kB"
132121
}
122+
},
123+
"pnpm": {
124+
"patchedDependencies": {
125+
"@changesets/[email protected]": "patches/@[email protected]"
126+
}
133127
}
134128
}

packages/react-router-dom-v5-compat/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
"module": "./dist/index.js",
2424
"types": "./dist/index.d.ts",
2525
"dependencies": {
26+
"@remix-run/router": "workspace:*",
2627
"history": "^5.3.0",
27-
"react-router": "6.22.3"
28+
"react-router": "workspace:*"
2829
},
2930
"peerDependencies": {
3031
"react": ">=16.8",

0 commit comments

Comments
 (0)