Skip to content

Commit

Permalink
Switch to pnpm
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
NiGhTTraX committed Jan 24, 2022
1 parent 06eece1 commit 663afc1
Show file tree
Hide file tree
Showing 14 changed files with 14,535 additions and 15,481 deletions.
24 changes: 11 additions & 13 deletions .github/workflows/npm.yml → .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
name: npm
name: tests

on:
push:
branches:
- npm
pull_request:
branches:
- npm
branches: [ $default-branch ]

jobs:
tests:
Expand All @@ -16,23 +13,24 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

- uses: pnpm/[email protected]
with:
version: latest

- name: Install Node
uses: actions/setup-node@v2
with:
node-version: 14
cache: 'npm'

- name: Install npm7
run: npm i -g npm@latest
cache: 'pnpm'

- name: Install dependencies
run: npm ci
run: pnpm i

- name: Lint
run: npm run lint
run: pnpm run lint

- name: Build
run: npm run build
run: pnpm run build

- name: Test
run: npm run test
run: pnpm run test
35 changes: 0 additions & 35 deletions .github/workflows/yarn.yml

This file was deleted.

18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

Template project for setting up a TypeScript monorepo

[![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)
[![tests](https://github.com/NiGhTTraX/ts-monorepo/actions/workflows/tests.yml/badge.svg)](https://github.com/NiGhTTraX/ts-monorepo/actions/workflows/tests.yml)

</div>

Expand Down Expand Up @@ -45,10 +45,20 @@ Template project for setting up a TypeScript monorepo
## Setup

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).
This repo uses [pnpm](https://pnpm.io/), but should work fine with any of the following:

```
yarn install
- [yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces/)
- [npm 7 workspaces](https://docs.npmjs.com/cli/v7/using-npm/workspaces)
- [npm < 7 and `lerna bootstrap`](https://github.com/lerna/lerna/blob/main/commands/bootstrap/README.md)

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).

```sh
# Install pnpm with your preferred method: https://pnpm.io/installation.
npm i -g pnpm

# Install all dependencies.
pnpm i
```

## Docs
Expand Down
6 changes: 3 additions & 3 deletions examples/cra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
},
"devDependencies": {
"@types/node": "~16.11.0",
"@types/jest": "~27.4.0",
"@types/react": "~17.0.0",
"@types/react-dom": "~17.0.0",
"@craco/craco": "~6.4.0",
"cross-env": "~7.0.2",
"react-scripts": "~5.0.0",
"jest-watch-typeahead": "~1.0.0",
"fork-ts-checker-webpack-plugin": "~6.5.0",
"tsconfig-paths-webpack-plugin": "~3.5.0"
"tsconfig-paths-webpack-plugin": "~3.5.0",
"ts-jest": "~27.1.3"
},
"scripts": {
"start": "cross-env SKIP_PREFLIGHT_CHECK=true craco start",
Expand Down
2 changes: 1 addition & 1 deletion examples/ts-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"version": "1.0.0",
"scripts": {
"start": "ts-node -r tsconfig-paths/register src/index.ts",
"test": "yarn run start"
"test": "pnpm run start"
},
"dependencies": {
"@nighttrax/foo": "*"
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
],
"version": "independent",
"useWorkspaces": true,
"npmClient": "yarn"
"npmClient": "pnpm"
}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"eslint": "~8.7.0",
"eslint-plugin-import": "~2.25.0",
"lerna": "~4.0.0",
"react": "~17.0.0",
"typescript": "~4.5.0"
}
}
4 changes: 2 additions & 2 deletions packages/bar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
"dist"
],
"scripts": {
"build": "yarn run clean && yarn run compile",
"build": "pnpm run clean && pnpm run compile",
"clean": "rimraf -rf ./dist",
"compile": "tsc -p tsconfig.build.json",
"prepublishOnly": "yarn run build"
"prepublishOnly": "pnpm run build"
},
"dependencies": {
"@nighttrax/foo": "^1.0.0"
Expand Down
7 changes: 4 additions & 3 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "@nighttrax/components",
"version": "1.0.0",
"scripts": {
"build": "yarn run clean && yarn run compile",
"build": "pnpm run clean && pnpm run compile",
"clean": "rimraf -rf ./dist",
"compile": "tsc -p tsconfig.build.json",
"prepublishOnly": "yarn run build"
"prepublishOnly": "pnpm run build"
},
"peerDependencies": {
"react": "~17.0.0"
Expand All @@ -16,6 +16,7 @@
"devDependencies": {
"@types/react": "~17.0.0",
"react": "~17.0.0",
"react-dom": "~17.0.0"
"react-dom": "~17.0.0",
"rimraf": "~3.0.2"
}
}
4 changes: 2 additions & 2 deletions packages/foo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
"dist"
],
"scripts": {
"build": "yarn run clean && yarn run compile",
"build": "pnpm run clean && pnpm run compile",
"clean": "rimraf -rf ./dist",
"compile": "tsc -p tsconfig.build.json",
"prepublishOnly": "yarn run build"
"prepublishOnly": "pnpm run build"
},
"devDependencies": {
"rimraf": "~3.0.2",
Expand Down
Loading

0 comments on commit 663afc1

Please sign in to comment.