Migrate to pnpm (#11358)

pull/11362/head
Mark Dalgleish 10 months ago committed by GitHub
parent c7dd3d3a8e
commit 12afb2efdc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -17,5 +17,6 @@
"access": "public",
"baseBranch": "dev",
"updateInternalDependencies": "patch",
"bumpVersionsWithWorkspaceProtocolOnly": true,
"ignore": []
}

@ -1,5 +1,6 @@
/fixtures/
node_modules/
pnpm-lock.yaml
/docs/api
examples/**/dist/
packages/**/dist/

@ -1,11 +1,11 @@
name: ⚙️ Deduplicate yarn.lock
name: ⚙️ Deduplicate lock file
on:
push:
branches:
- dev
paths:
- ./yarn.lock
- ./pnpm-lock.yaml
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
@ -20,14 +20,17 @@ jobs:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
- name: 📦 Setup pnpm
uses: pnpm/action-setup@v3.0.0
- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "yarn"
cache: "pnpm"
- name: ⚙️ Dedupe yarn.lock
run: npx yarn-deduplicate && rm -rf ./node_modules && yarn
- name: ⚙️ Dedupe lock file
run: pnpm dedupe && rm -rf ./node_modules && pnpm install
- name: 💪 Commit
run: |
@ -38,6 +41,6 @@ jobs:
echo "💿 no deduplication needed"
exit 0
fi
git commit -m "chore: deduplicate `yarn.lock`"
git commit -m "chore: deduplicate `pnpm-lock.yaml`"
git push
echo "💿 https://github.com/$GITHUB_REPOSITORY/commit/$(git rev-parse HEAD)"

@ -21,20 +21,23 @@ jobs:
with:
token: ${{ secrets.FORMAT_PAT }}
- name: 📦 Setup pnpm
uses: pnpm/action-setup@v3.0.0
- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
cache: yarn
cache: pnpm
node-version-file: ".nvmrc"
- name: 📥 Install deps
run: yarn --frozen-lockfile
run: pnpm install --frozen-lockfile
- name: 🔃 Sort contributors.yml
run: sort --ignore-case --output contributors.yml contributors.yml
- name: 👔 Format
run: yarn format
run: pnpm format
- name: 💪 Commit
run: |

@ -22,17 +22,20 @@ jobs:
with:
fetch-depth: 0
- name: 📦 Setup pnpm
uses: pnpm/action-setup@v3.0.0
- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
cache: yarn
cache: pnpm
node-version-file: ".nvmrc"
- name: 📥 Install deps
run: yarn --frozen-lockfile
run: pnpm install --frozen-lockfile
- name: 🏗 Build
run: yarn build
run: pnpm build
- name: 🔐 Setup npm auth
run: |
@ -40,4 +43,4 @@ jobs:
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
- name: 🚀 Publish
run: npm run publish
run: pnpm run publish

@ -27,14 +27,17 @@ jobs:
with:
fetch-depth: 0
- name: 📦 Setup pnpm
uses: pnpm/action-setup@v3.0.0
- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: "yarn"
cache: "pnpm"
- name: 📥 Install deps
run: yarn --frozen-lockfile
run: pnpm install --frozen-lockfile
- name: 🔐 Setup npm auth
run: |
@ -50,10 +53,10 @@ jobs:
id: changesets
uses: changesets/action@v1
with:
version: yarn run version
version: pnpm run version
commit: "chore: Update version for release"
title: "chore: Update version for release"
publish: yarn run release
publish: pnpm run release
createGithubReleases: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@ -70,11 +73,14 @@ jobs:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
- name: 📦 Setup pnpm
uses: pnpm/action-setup@v3.0.0
- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
node-version: 16
cache: "npm"
cache: "pnpm"
- id: find_package_version
run: |

@ -35,10 +35,13 @@ jobs:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4
- name: 📦 Setup pnpm
uses: pnpm/action-setup@v3.0.0
- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
cache: yarn
cache: pnpm
check-latest: true
node-version: ${{ matrix.node }}
@ -49,16 +52,16 @@ jobs:
echo "::remove-matcher owner=eslint-stylish::"
- name: 📥 Install deps
run: yarn --frozen-lockfile
run: pnpm install --frozen-lockfile
- name: 🏗 Build
run: yarn build
run: pnpm build
- name: 🔬 Lint
run: yarn lint
run: pnpm lint
- name: 🧪 Run tests
run: yarn test
run: pnpm test
- name: Check bundle size
run: yarn size
run: pnpm size

1
.gitignore vendored

@ -6,6 +6,7 @@ npm-debug.log
node_modules/
/examples/*/yarn.lock
/examples/*/pnpm-lock.yaml
/examples/*/dist
/tutorial/dist

@ -0,0 +1,2 @@
ignore-workspace-cycles=true
enable-pre-post-scripts=true

@ -16,7 +16,7 @@ Changesets will do most of the heavy lifting for our releases. When changes are
### Starting a new pre-release
- Ensure you are on the new `release-*` branch.
- Enter Changesets pre-release mode using the `pre` tag: `yarn changeset pre enter pre`.
- Enter Changesets pre-release mode using the `pre` tag: `pnpm changeset pre enter pre`.
- Commit the change and push the `release-*` branch to GitHub.
- 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.
- 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
You may need to make changes to a pre-release prior to publishing a final stable release. To do so:
- Make whatever changes you need.
- Create a new changeset: `yarn changeset`.
- Create a new changeset: `pnpm changeset`.
- **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.
- Commit the changesets and push the `release-*` branch to GitHub.
- 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
### Publishing the stable release
- Exit Changesets pre-release mode: `yarn changeset pre exit`.
- Exit Changesets pre-release mode: `pnpm changeset pre exit`.
- Commit the edited pre-release file along with any unpublished changesets, and push the `release-*` branch to GitHub.
- 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.
- 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
- Create a new branch for the release: `git checkout -b release-experimental`
- Make whatever changes you need and commit them: `git add . && git commit "experimental changes!"`
- Update version numbers and create a release tag: `yarn run version:experimental`
- Update version numbers and create a release tag: `pnpm run version:experimental`
- Push to GitHub: `git push origin --follow-tags`
- The CI workflow should automatically trigger from the experimental tag to publish the release to npm

@ -30,7 +30,7 @@ cd react-router
git checkout dev
```
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.
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.
## Think You Found a Bug?
@ -72,22 +72,22 @@ All commits that change or add to the API must be done in a pull request that al
React Router uses a monorepo to host code for multiple packages. These packages live in the `packages` directory.
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.
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.
### Building
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.
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.
### Testing
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>`:
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>`:
```bash
# Test all packages
yarn test
pnpm test
# Test only react-router-dom
yarn test --projects packages/react-router-dom
pnpm test --projects packages/react-router-dom
```
## Repository Branching
@ -111,7 +111,7 @@ When it's time to cut a new release, we follow a process based on our branching
We create experimental releases from the current state of the `dev` branch. They can be installed by using the `@next` tag:
```bash
yarn add react-router-dom@next
pnpm add react-router-dom@next
# or
npm install react-router-dom@next
```
@ -133,7 +133,7 @@ git checkout -b release/v6.1.0
# Create a new tag and update version references throughout the
# codebase.
yarn run version minor # | "patch" | "major"
pnpm run version minor # | "patch" | "major"
# Push the release branch along with the new release tag.
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
```bash
# From the main branch, make sure to run the build and all tests
# before creating a new release.
yarn && yarn build && yarn test
pnpm install && pnpm build && pnpm test
# Assuming the tests pass, create the release tag and update
# version references throughout the codebase.
yarn run version patch
pnpm run version patch
# Push changes along with the new release tag.
git push origin main --follow-tags

@ -1,23 +1,13 @@
{
"name": "@remix-run/react-router",
"private": true,
"workspaces": {
"packages": [
"packages/react-router",
"packages/react-router-dom",
"packages/react-router-dom-v5-compat",
"packages/react-router-native",
"packages/router"
]
},
"scripts": {
"build": "rollup -c",
"clean": "git clean -fdX .",
"format": "prettier --ignore-path .eslintignore --write .",
"format:check": "prettier --ignore-path .eslintignore --check .",
"postinstall": "patch-package",
"lint": "eslint --cache .",
"prerelease": "yarn build",
"prerelease": "pnpm build",
"release": "changeset publish",
"size": "filesize",
"test": "jest",
@ -25,7 +15,6 @@
"changeset": "changeset",
"version": "changeset version && node ./scripts/remove-prerelease-changelogs.mjs",
"publish": "node scripts/publish.js",
"postversion": "node scripts/postversion.mjs",
"version:experimental": "node ./scripts/version experimental",
"watch": "rollup -c -w"
},
@ -37,6 +26,7 @@
"default"
]
},
"packageManager": "pnpm@8.10.5",
"resolutions": {
"@types/react": "^18.2.18",
"@types/react-dom": "^18.2.7",
@ -91,7 +81,6 @@
"jest": "^29.6.2",
"jest-environment-jsdom": "^29.6.2",
"jsonfile": "^6.1.0",
"patch-package": "^6.5.1",
"prettier": "^2.8.8",
"prompt-confirm": "^2.0.4",
"react": "^18.2.0",
@ -130,5 +119,10 @@
"packages/react-router-dom/dist/umd/react-router-dom.production.min.js": {
"none": "23.5 kB"
}
},
"pnpm": {
"patchedDependencies": {
"@changesets/get-dependents-graph@1.3.6": "patches/@changesets__get-dependents-graph@1.3.6.patch"
}
}
}

@ -23,8 +23,9 @@
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"dependencies": {
"@remix-run/router": "workspace:*",
"history": "^5.3.0",
"react-router": "6.22.3"
"react-router": "workspace:*"
},
"peerDependencies": {
"react": ">=16.8",

@ -1,37 +0,0 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@babel/runtime@^7.7.6":
version "7.17.7"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.17.7.tgz#a5f3328dc41ff39d803f311cfe17703418cf9825"
integrity sha512-L6rvG9GDxaLgFjg41K+5Yv9OMrU98sWe+Ykmc6FDJW/+vYZMhdOMKkISgzptMaERHvS2Y2lw9MDRm2gHhlQQoA==
dependencies:
regenerator-runtime "^0.13.4"
history@^5.2.0:
version "5.3.0"
resolved "https://registry.yarnpkg.com/history/-/history-5.3.0.tgz#1548abaa245ba47992f063a0783db91ef201c73b"
integrity sha512-ZqaKwjjrAYUYfLG+htGaIIZ4nioX2L70ZUMIFysS3xvBsSG4x/n1V6TXV3N8ZYNuFGlDirFg32T7B6WOUPDYcQ==
dependencies:
"@babel/runtime" "^7.7.6"
react-router-dom@^6.2.2:
version "6.2.2"
resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-6.2.2.tgz#f1a2c88365593c76b9612ae80154a13fcb72e442"
integrity sha512-AtYEsAST7bDD4dLSQHDnk/qxWLJdad5t1HFa1qJyUrCeGgEuCSw0VB/27ARbF9Fi/W5598ujvJOm3ujUCVzuYQ==
dependencies:
history "^5.2.0"
react-router "6.2.2"
react-router@6.2.2:
version "6.2.2"
resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.2.2.tgz#495e683a0c04461eeb3d705fe445d6cf42f0c249"
integrity sha512-/MbxyLzd7Q7amp4gDOGaYvXwhEojkJD5BtExkuKmj39VEE0m3l/zipf6h2WIB2jyAO0lI6NGETh4RDcktRm4AQ==
dependencies:
history "^5.2.0"
regenerator-runtime@^0.13.4:
version "0.13.9"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.9.tgz#8925742a98ffd90814988d7566ad30ca3b263b52"
integrity sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==

@ -23,8 +23,8 @@
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"dependencies": {
"@remix-run/router": "1.15.3",
"react-router": "6.22.3"
"@remix-run/router": "workspace:*",
"react-router": "workspace:*"
},
"devDependencies": {
"react": "^18.2.0",

@ -29,7 +29,7 @@ import type {
Location,
RouteObject,
To,
} from "react-router-dom";
} from "./index";
import {
createPath,
parsePath,
@ -38,7 +38,7 @@ import {
UNSAFE_DataRouterStateContext as DataRouterStateContext,
UNSAFE_FetchersContext as FetchersContext,
UNSAFE_ViewTransitionContext as ViewTransitionContext,
} from "react-router-dom";
} from "./index";
export interface StaticRouterProps {
basename?: string;

@ -8,9 +8,7 @@ module.exports = {
globals: {
__DEV__: true,
},
modulePaths: [
"<rootDir>/node_modules", // for react-native
],
transformIgnorePatterns: [],
setupFiles: ["<rootDir>/__tests__/setup.ts"],
moduleNameMapper: {
"^@remix-run/router$": "<rootDir>/../router/index.ts",

@ -22,11 +22,14 @@
"types": "./dist/index.d.ts",
"dependencies": {
"@ungap/url-search-params": "^0.2.2",
"react-router": "6.22.3"
"react-router": "workspace:*"
},
"devDependencies": {
"@types/react-test-renderer": "^18.0.0",
"react": "^18.2.0",
"react-native": "^0.69.5"
"react-native": "^0.69.5",
"react-router-native": "workspace:*",
"react-test-renderer": "^18.2.0"
},
"peerDependencies": {
"react": ">=16.8",

@ -23,10 +23,11 @@
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"dependencies": {
"@remix-run/router": "1.15.3"
"@remix-run/router": "workspace:*"
},
"devDependencies": {
"react": "^18.2.0"
"react": "^18.2.0",
"react-router-dom": "workspace:*"
},
"peerDependencies": {
"react": ">=16.8"

@ -1,7 +1,7 @@
diff --git a/node_modules/@changesets/get-dependents-graph/dist/get-dependents-graph.cjs.dev.js b/node_modules/@changesets/get-dependents-graph/dist/get-dependents-graph.cjs.dev.js
index 94dde7b..70407b0 100644
--- a/node_modules/@changesets/get-dependents-graph/dist/get-dependents-graph.cjs.dev.js
+++ b/node_modules/@changesets/get-dependents-graph/dist/get-dependents-graph.cjs.dev.js
diff --git a/dist/get-dependents-graph.cjs.dev.js b/dist/get-dependents-graph.cjs.dev.js
index 94dde7b0aa903cf4aa099acfd2fc62f6243264d9..70407b017dd86b0363af989663ff83e1ba34a925 100644
--- a/dist/get-dependents-graph.cjs.dev.js
+++ b/dist/get-dependents-graph.cjs.dev.js
@@ -10,8 +10,14 @@ function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e };
var Range__default = /*#__PURE__*/_interopDefault(Range);
var chalk__default = /*#__PURE__*/_interopDefault(chalk);
@ -19,10 +19,10 @@ index 94dde7b..70407b0 100644
const getAllDependencies = config => {
const allDependencies = new Map();
diff --git a/node_modules/@changesets/get-dependents-graph/dist/get-dependents-graph.cjs.prod.js b/node_modules/@changesets/get-dependents-graph/dist/get-dependents-graph.cjs.prod.js
index 39b2dfe..dc0fed7 100644
--- a/node_modules/@changesets/get-dependents-graph/dist/get-dependents-graph.cjs.prod.js
+++ b/node_modules/@changesets/get-dependents-graph/dist/get-dependents-graph.cjs.prod.js
diff --git a/dist/get-dependents-graph.cjs.prod.js b/dist/get-dependents-graph.cjs.prod.js
index 39b2dfe0c15d052f4e342a81626c4012a695867b..dc0fed7320dd1157b3f020c06d46530547070cda 100644
--- a/dist/get-dependents-graph.cjs.prod.js
+++ b/dist/get-dependents-graph.cjs.prod.js
@@ -14,7 +14,7 @@ function _interopDefault(e) {
var Range__default = _interopDefault(Range), chalk__default = _interopDefault(chalk);
@ -32,10 +32,10 @@ index 39b2dfe..dc0fed7 100644
const allDependencies = new Map;
for (const type of DEPENDENCY_TYPES) {
const deps = config[type];
diff --git a/node_modules/@changesets/get-dependents-graph/dist/get-dependents-graph.esm.js b/node_modules/@changesets/get-dependents-graph/dist/get-dependents-graph.esm.js
index 5f29582..1e4b750 100644
--- a/node_modules/@changesets/get-dependents-graph/dist/get-dependents-graph.esm.js
+++ b/node_modules/@changesets/get-dependents-graph/dist/get-dependents-graph.esm.js
diff --git a/dist/get-dependents-graph.esm.js b/dist/get-dependents-graph.esm.js
index 5f29582339d3a6a45ff882caf843ecf8a9d6c99d..1e4b7509e48cff7a2c702922ee5a6987e33959e0 100644
--- a/dist/get-dependents-graph.esm.js
+++ b/dist/get-dependents-graph.esm.js
@@ -2,7 +2,7 @@ import Range from 'semver/classes/range';
import chalk from 'chalk';

File diff suppressed because it is too large Load Diff

@ -0,0 +1,6 @@
packages:
- "packages/react-router"
- "packages/react-router-dom"
- "packages/react-router-dom-v5-compat"
- "packages/react-router-native"
- "packages/router"

@ -1,23 +0,0 @@
import * as path from "path";
import { createRequire } from "node:module";
// Changesets assumes that an internal peer dependency's version range should
// include the version of that package in our repo. This normally makes sense,
// but the compat package has a peer dependency on react-router-dom v4 or v5, so
// we need to:
// - Avoid validity checks for peer dependencies (done via patch package)
// - Reset the automatic version updates resulting from yarn changeset version
// (done via a simple node script)
const require = createRequire(import.meta.url);
const jsonfile = require("jsonfile");
let file = path.join(
process.cwd(),
"packages/react-router-dom-v5-compat/package.json"
);
let json = await jsonfile.readFile(file);
json.peerDependencies["react-router-dom"] = "4 || 5";
await jsonfile.writeFile(file, json, { spaces: 2 });
console.log("Patched peerDependencies for react-router-dom-v5-compat");

@ -43,9 +43,9 @@ async function ensureBuildVersion(packageName, version) {
function publishBuild(packageName, tag) {
let buildDir = path.join(rootDir, "packages", packageName);
console.log();
console.log(` npm publish ${buildDir} --tag ${tag} --access public`);
console.log(` pnpm publish ${buildDir} --tag ${tag} --access public`);
console.log();
execSync(`npm publish ${buildDir} --tag ${tag} --access public`, {
execSync(`pnpm publish ${buildDir} --tag ${tag} --access public`, {
stdio: "inherit",
});
}

10390
yarn.lock

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save