Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: switch to pnpm and turborepo #1983

Merged
merged 3 commits into from
May 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,23 @@ To run SWR locally, you can start it with any example in `examples` folder. You
First of all, build SWR assets

```sh
yarn watch
pnpm watch
```

Install dependency of the target example, for instance `examples/basic`:


```sh
# by default it will run next dev for the example
yarn next dev examples/basic
pnpm next dev examples/basic
```

All examples are built with Next.js, so Next.js commands are all supported:

```sh
# if you want to build and start
yarn next build examples/basic
yarn next start examples/basic
pnpm next build examples/basic
pnpm next start examples/basic
```
## Update Documentation

Expand Down
40 changes: 30 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,38 @@ on:
jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Use Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 16

- uses: pnpm/action-setup@v2.0.1
name: Install pnpm
id: pnpm-install
with:
node-version: '14'
cache: 'yarn'
- run: yarn install
- run: yarn types:check
- run: yarn lint
- run: yarn build
- run: yarn test
version: 7
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"

- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible to get turbo cache here too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From turborepo discord

The problem with using action/cache is the fact that you most specify a restore key which means it will keep only one cache per build.
When you are using turborepo, this means that you have a mono-repo, which probably will produce multiple artifacts.
Think about a monorepo with A,B,C,D artifacts.
The first build will miss all, create a cache to all (the restore key will be somehow generated...) in one cache.
Then you changed only A, this build will miss, since, the previous cache contains A, and it should be missed. = no gain.

key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-

- run: pnpm install
- run: pnpm types:check
- run: pnpm lint
- run: pnpm build
- run: pnpm test
env:
CI: true
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ dist
examples/**/yarn.lock
package-lock.json
tsconfig.tsbuildinfo
coverage
coverage
*/**/.turbo
.turbo
7 changes: 7 additions & 0 deletions _internal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
"module": "./dist/index.esm.js",
"types": "./dist/_internal",
"exports": "./dist/index.mjs",
"private": true,
"scripts": {
"watch": "bunchee index.ts --no-sourcemap -w",
"build": "bunchee index.ts --no-sourcemap",
"types:check": "tsc --noEmit",
"clean": "rimraf dist"
},
"peerDependencies": {
"react": "*"
}
Expand Down
7 changes: 7 additions & 0 deletions core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
"module": "./dist/index.esm.js",
"types": "./dist/index.d.ts",
"exports": "./dist/index.mjs",
"private": true,
"scripts": {
"watch": "bunchee index.ts --no-sourcemap -w",
"build": "bunchee index.ts --no-sourcemap",
"types:check": "tsc --noEmit",
"clean": "rimraf dist"
},
"peerDependencies": {
"swr": "*",
"react": "*",
Expand Down
4 changes: 2 additions & 2 deletions examples/api-hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"license": "MIT",
"dependencies": {
"next": "latest",
"react": "17.0.2",
"react-dom": "17.0.2",
"react": "18.1.0",
"react-dom": "18.1.0",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/autocomplete-suggestions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"dependencies": {
"@reach/combobox": "0.16.1",
"next": "latest",
"react": "17.0.2",
"react-dom": "17.0.2",
"react": "18.1.0",
"react-dom": "18.1.0",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/axios-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"dependencies": {
"axios": "0.23.0",
"next": "latest",
"react": "17.0.2",
"react-dom": "17.0.2",
"react": "18.1.0",
"react-dom": "18.1.0",
"swr": "latest"
},
"scripts": {
Expand Down
6 changes: 3 additions & 3 deletions examples/axios/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"main": "index.js",
"license": "MIT",
"dependencies": {
"axios": "0.21.1",
"axios": "0.27.2",
"next": "latest",
"react": "17.0.2",
"react-dom": "17.0.2",
"react": "18.1.0",
"react-dom": "18.1.0",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/basic-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"license": "MIT",
"dependencies": {
"next": "latest",
"react": "17.0.2",
"react-dom": "17.0.2",
"react": "18.1.0",
"react-dom": "18.1.0",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"license": "MIT",
"dependencies": {
"next": "latest",
"react": "17.0.2",
"react-dom": "17.0.2",
"react": "18.1.0",
"react-dom": "18.1.0",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/focus-revalidate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"license": "MIT",
"dependencies": {
"next": "latest",
"react": "17.0.2",
"react-dom": "17.0.2",
"react": "18.1.0",
"react-dom": "18.1.0",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/global-fetcher/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"license": "MIT",
"dependencies": {
"next": "latest",
"react": "17.0.2",
"react-dom": "17.0.2",
"react": "18.1.0",
"react-dom": "18.1.0",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/infinite-scroll/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"license": "MIT",
"dependencies": {
"next": "latest",
"react": "17.0.2",
"react-dom": "17.0.2",
"react": "18.1.0",
"react-dom": "18.1.0",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/infinite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"license": "MIT",
"dependencies": {
"next": "latest",
"react": "17.0.2",
"react-dom": "17.0.2",
"react": "18.1.0",
"react-dom": "18.1.0",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/local-state-sharing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"main": "index.js",
"license": "MIT",
"dependencies": {
"react": "17.0.2",
"react-dom": "17.0.2",
"react": "18.1.0",
"react-dom": "18.1.0",
"next": "latest",
"swr": "latest"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/optimistic-ui-immer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"dependencies": {
"immer": "9.0.5",
"next": "latest",
"react": "17.0.2",
"react-dom": "17.0.2",
"react": "18.1.0",
"react-dom": "18.1.0",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/optimistic-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"license": "MIT",
"dependencies": {
"next": "latest",
"react": "17.0.2",
"react-dom": "17.0.2",
"react": "18.1.0",
"react-dom": "18.1.0",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/prefetch-preload/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"license": "MIT",
"dependencies": {
"next": "latest",
"react": "17.0.2",
"react-dom": "17.0.2",
"react": "18.1.0",
"react-dom": "18.1.0",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/refetch-interval/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"license": "MIT",
"dependencies": {
"next": "latest",
"react": "17.0.2",
"react-dom": "17.0.2",
"react": "18.1.0",
"react-dom": "18.1.0",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/server-render/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"license": "MIT",
"dependencies": {
"next": "latest",
"react": "17.0.2",
"react-dom": "17.0.2",
"react": "18.1.0",
"react-dom": "18.1.0",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/storage-tab-sync/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"license": "MIT",
"dependencies": {
"next": "latest",
"react": "17.0.2",
"react-dom": "17.0.2",
"react": "18.1.0",
"react-dom": "18.1.0",
"swr": "latest"
},
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions examples/suspense/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"license": "MIT",
"dependencies": {
"next": "latest",
"react": "17.0.2",
"react-dom": "17.0.2",
"react": "18.1.0",
"react-dom": "18.1.0",
"swr": "latest"
},
"scripts": {
Expand Down
7 changes: 7 additions & 0 deletions immutable/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
"module": "./dist/index.esm.js",
"types": "./dist/immutable",
"exports": "./dist/index.mjs",
"private": true,
"scripts": {
"watch": "bunchee index.ts --no-sourcemap -w",
"build": "bunchee index.ts --no-sourcemap",
"types:check": "tsc --noEmit",
"clean": "rimraf dist"
},
"peerDependencies": {
"swr": "*",
"react": "*"
Expand Down
7 changes: 7 additions & 0 deletions infinite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
"module": "./dist/index.esm.js",
"types": "./dist/infinite",
"exports": "./dist/index.mjs",
"private": true,
"scripts": {
"watch": "bunchee index.ts --no-sourcemap -w",
"build": "bunchee index.ts --no-sourcemap",
"types:check": "tsc --noEmit",
"clean": "rimraf dist"
},
"peerDependencies": {
"swr": "*",
"react": "*",
Expand Down
7 changes: 7 additions & 0 deletions mutation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
"module": "./dist/index.esm.js",
"types": "./dist/mutation",
"exports": "./dist/index.mjs",
"private": true,
"scripts": {
"watch": "bunchee index.ts --no-sourcemap -w",
"build": "bunchee index.ts --no-sourcemap",
"types:check": "tsc --noEmit",
"clean": "rimraf dist"
},
"peerDependencies": {
"swr": "*",
"react": "*"
Expand Down