Skip to content

Commit 663afc1

Browse files
committed
Switch to pnpm
This reverts the workarounds for #159, #74 and #60, as they are no longer needed. There are a few peer dependency warnings, though the examples work just fine: - The one for NextJS is tracked in vercel/next.js#31887. - CRACO support for CRA@5 is tracked in dilanx/craco#378. - The warnings for CRA are tracked in facebook/create-react-app#11982, except for the `ts-jest` one which is expected, since we're using CRA's `jest`.
1 parent 06eece1 commit 663afc1

File tree

14 files changed

+14535
-15481
lines changed

14 files changed

+14535
-15481
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
name: npm
1+
name: tests
22

33
on:
44
push:
5-
branches:
6-
- npm
75
pull_request:
8-
branches:
9-
- npm
6+
branches: [ $default-branch ]
107

118
jobs:
129
tests:
@@ -16,23 +13,24 @@ jobs:
1613
- name: Checkout
1714
uses: actions/checkout@v2
1815

16+
- uses: pnpm/[email protected]
17+
with:
18+
version: latest
19+
1920
- name: Install Node
2021
uses: actions/setup-node@v2
2122
with:
2223
node-version: 14
23-
cache: 'npm'
24-
25-
- name: Install npm7
26-
run: npm i -g npm@latest
24+
cache: 'pnpm'
2725

2826
- name: Install dependencies
29-
run: npm ci
27+
run: pnpm i
3028

3129
- name: Lint
32-
run: npm run lint
30+
run: pnpm run lint
3331

3432
- name: Build
35-
run: npm run build
33+
run: pnpm run build
3634

3735
- name: Test
38-
run: npm run test
36+
run: pnpm run test

.github/workflows/yarn.yml

-35
This file was deleted.

README.md

+14-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
Template project for setting up a TypeScript monorepo
77

8-
[![yarn](https://github.com/NiGhTTraX/ts-monorepo/actions/workflows/yarn.yml/badge.svg)](https://github.com/NiGhTTraX/ts-monorepo/actions/workflows/yarn.yml) [![npm](https://github.com/NiGhTTraX/ts-monorepo/actions/workflows/npm.yml/badge.svg)](https://github.com/NiGhTTraX/ts-monorepo/actions/workflows/npm.yml)
8+
[![tests](https://github.com/NiGhTTraX/ts-monorepo/actions/workflows/tests.yml/badge.svg)](https://github.com/NiGhTTraX/ts-monorepo/actions/workflows/tests.yml)
99

1010
</div>
1111

@@ -45,10 +45,20 @@ Template project for setting up a TypeScript monorepo
4545
4646
## Setup
4747

48-
This main branch of this repo uses [yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces/), while the [`npm` branch](https://github.com/NiGhTTraX/ts-monorepo/tree/npm) uses [npm 7 workspaces](https://docs.npmjs.com/cli/v7/using-npm/workspaces).
48+
This repo uses [pnpm](https://pnpm.io/), but should work fine with any of the following:
4949

50-
```
51-
yarn install
50+
- [yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces/)
51+
- [npm 7 workspaces](https://docs.npmjs.com/cli/v7/using-npm/workspaces)
52+
- [npm < 7 and `lerna bootstrap`](https://github.com/lerna/lerna/blob/main/commands/bootstrap/README.md)
53+
54+
I strongly recommend `pnpm` over the other solutions, not only because it's usually faster, but because it avoids dependency problems caused by hoisting (see https://github.com/NiGhTTraX/ts-monorepo/commit/d93139166b25fab15e9538df58a7d06270b846c9 as an example).
55+
56+
```sh
57+
# Install pnpm with your preferred method: https://pnpm.io/installation.
58+
npm i -g pnpm
59+
60+
# Install all dependencies.
61+
pnpm i
5262
```
5363

5464
## Docs

examples/cra/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
},
1212
"devDependencies": {
1313
"@types/node": "~16.11.0",
14+
"@types/jest": "~27.4.0",
1415
"@types/react": "~17.0.0",
1516
"@types/react-dom": "~17.0.0",
1617
"@craco/craco": "~6.4.0",
1718
"cross-env": "~7.0.2",
1819
"react-scripts": "~5.0.0",
19-
"jest-watch-typeahead": "~1.0.0",
20-
"fork-ts-checker-webpack-plugin": "~6.5.0",
21-
"tsconfig-paths-webpack-plugin": "~3.5.0"
20+
"tsconfig-paths-webpack-plugin": "~3.5.0",
21+
"ts-jest": "~27.1.3"
2222
},
2323
"scripts": {
2424
"start": "cross-env SKIP_PREFLIGHT_CHECK=true craco start",

examples/ts-node/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"version": "1.0.0",
66
"scripts": {
77
"start": "ts-node -r tsconfig-paths/register src/index.ts",
8-
"test": "yarn run start"
8+
"test": "pnpm run start"
99
},
1010
"dependencies": {
1111
"@nighttrax/foo": "*"

lerna.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
],
66
"version": "independent",
77
"useWorkspaces": true,
8-
"npmClient": "yarn"
8+
"npmClient": "pnpm"
99
}

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"eslint": "~8.7.0",
2121
"eslint-plugin-import": "~2.25.0",
2222
"lerna": "~4.0.0",
23-
"react": "~17.0.0",
2423
"typescript": "~4.5.0"
2524
}
2625
}

packages/bar/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
"dist"
88
],
99
"scripts": {
10-
"build": "yarn run clean && yarn run compile",
10+
"build": "pnpm run clean && pnpm run compile",
1111
"clean": "rimraf -rf ./dist",
1212
"compile": "tsc -p tsconfig.build.json",
13-
"prepublishOnly": "yarn run build"
13+
"prepublishOnly": "pnpm run build"
1414
},
1515
"dependencies": {
1616
"@nighttrax/foo": "^1.0.0"

packages/components/package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
"name": "@nighttrax/components",
33
"version": "1.0.0",
44
"scripts": {
5-
"build": "yarn run clean && yarn run compile",
5+
"build": "pnpm run clean && pnpm run compile",
66
"clean": "rimraf -rf ./dist",
77
"compile": "tsc -p tsconfig.build.json",
8-
"prepublishOnly": "yarn run build"
8+
"prepublishOnly": "pnpm run build"
99
},
1010
"peerDependencies": {
1111
"react": "~17.0.0"
@@ -16,6 +16,7 @@
1616
"devDependencies": {
1717
"@types/react": "~17.0.0",
1818
"react": "~17.0.0",
19-
"react-dom": "~17.0.0"
19+
"react-dom": "~17.0.0",
20+
"rimraf": "~3.0.2"
2021
}
2122
}

packages/foo/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
"dist"
88
],
99
"scripts": {
10-
"build": "yarn run clean && yarn run compile",
10+
"build": "pnpm run clean && pnpm run compile",
1111
"clean": "rimraf -rf ./dist",
1212
"compile": "tsc -p tsconfig.build.json",
13-
"prepublishOnly": "yarn run build"
13+
"prepublishOnly": "pnpm run build"
1414
},
1515
"devDependencies": {
1616
"rimraf": "~3.0.2",

0 commit comments

Comments
 (0)