Skip to content

Commit 1dbe400

Browse files
authored
Migrate to pnpm (#2548)
* wip: migrate to pnpm * no concurrently * fix build * chore remove yarn scripts * fix type package * wip: fix workflow files * wip: fix workflow files * revert install-script * add babel-loader * Revert "add babel-loader" This reverts commit b79e279. * install gatsby-plugin-pnpm * wip: gatsby * try simpler compressed-size-action.yml * Revert "try simpler compressed-size-action.yml" This reverts commit 822baae. * use the latest version? * remove setup-node? * revert * use pnpm * some more adjustments * add type field * tiny improvement
1 parent feb5ae3 commit 1dbe400

15 files changed

+18994
-17064
lines changed

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ Fixes #
88

99
## Check List
1010

11-
- [ ] `yarn run prettier` for formatting code and docs
11+
- [ ] `pnpm run prettier` for formatting code and docs

.github/workflows/compressed-size-action.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ jobs:
88
runs-on: ubuntu-latest
99

1010
steps:
11-
- uses: actions/checkout@v2
12-
- uses: preactjs/compressed-size-action@v2
11+
- uses: actions/checkout@v3
12+
- uses: pnpm/action-setup@v2
13+
with:
14+
version: 8.2.0
15+
- uses: actions/setup-node@v3
1316
with:
14-
repo-token: "${{ secrets.GITHUB_TOKEN }}"
17+
node-version: 18
18+
cache: 'pnpm'
19+
cache-dependency-path: '**/pnpm-lock.yaml'
20+
- uses: preactjs/compressed-size-action@v2

.github/workflows/lint-and-type.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ jobs:
1010
lint:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v2
14-
- uses: actions/setup-node@v2
13+
- uses: actions/checkout@v3
14+
- uses: pnpm/action-setup@v2
1515
with:
16-
node-version: '18'
17-
cache: yarn
18-
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
19-
- run: yarn install --frozen-lockfile --check-files
20-
- name: Prettier
21-
run: yarn prettier:ci
22-
- name: Lint
23-
run: yarn eslint:ci
24-
- name: Type
25-
run: yarn pretest
16+
version: 8.2.0
17+
- uses: actions/setup-node@v3
18+
with:
19+
node-version: 18
20+
cache: 'pnpm'
21+
cache-dependency-path: '**/pnpm-lock.yaml'
22+
- run: pnpm install --frozen-lockfile
23+
- run: pnpm test:format
24+
- run: pnpm test:types
25+
- run: pnpm test:lint

.github/workflows/livecodes-preview.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,16 @@ jobs:
77
runs-on: ubuntu-latest
88
steps:
99
- uses: actions/checkout@v3
10+
- uses: pnpm/action-setup@v2
11+
with:
12+
version: 8.2.0
13+
- uses: actions/setup-node@v3
14+
with:
15+
node-version: 18
16+
cache: 'pnpm'
17+
cache-dependency-path: '**/pnpm-lock.yaml'
1018
- uses: live-codes/preview-in-livecodes@v1
1119
with:
12-
install-command: "yarn install --frozen-lockfile --check-files"
13-
build-command: "yarn build"
20+
install-command: "pnpm install --frozen-lockfile"
21+
build-command: "pnpm build"
1422
base-url: "https://{{LC::REF}}.preview-in-livecodes-demo.pages.dev"

.github/workflows/test-multiple-builds.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,21 @@ jobs:
1515
build: [cjs, esm, umd]
1616
env: [development, production]
1717
steps:
18-
- uses: actions/checkout@v2
19-
- uses: actions/setup-node@v2
18+
- uses: actions/checkout@v3
19+
- uses: pnpm/action-setup@v2
2020
with:
21-
node-version: '18'
22-
cache: yarn
23-
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
24-
- run: yarn install --frozen-lockfile --check-files
25-
- run: yarn build
21+
version: 8.2.0
22+
- uses: actions/setup-node@v3
23+
with:
24+
node-version: 18
25+
cache: 'pnpm'
26+
cache-dependency-path: '**/pnpm-lock.yaml'
27+
- run: pnpm install --frozen-lockfile
28+
- run: pnpm build
2629
- name: Use React 17 for production test
2730
if: ${{ matrix.env == 'production' }}
2831
run: |
29-
32+
3033
- name: Patch for DEV-ONLY
3134
if: ${{ matrix.env == 'development' }}
3235
run: |
@@ -65,6 +68,6 @@ jobs:
6568
NODE_ENV: ${{ matrix.env }}
6669
- name: Test ${{ matrix.build }} ${{ matrix.env }}
6770
run: |
68-
yarn test:ci:build # test:ci
71+
pnpm test-build:spec # test:spec
6972
env:
7073
NODE_ENV: ${{ matrix.env }}

.github/workflows/test-multiple-versions.yml

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@ jobs:
1010
test:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v2
14-
- uses: actions/setup-node@v2
13+
- uses: actions/checkout@v3
14+
- uses: pnpm/action-setup@v2
1515
with:
16-
node-version: '18'
17-
cache: yarn
18-
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
19-
- run: yarn install --frozen-lockfile --check-files
20-
- name: Test Build # we don't have any other workflows to test build
21-
run: yarn build
22-
- name: Test Default
23-
run: yarn test:ci
16+
version: 8.2.0
17+
- uses: actions/setup-node@v3
18+
with:
19+
node-version: 18
20+
cache: 'pnpm'
21+
cache-dependency-path: '**/pnpm-lock.yaml'
22+
- run: pnpm install --frozen-lockfile
23+
- run: pnpm build # we don't have any other workflows to test build
24+
- run: pnpm test:spec
2425

2526
test_matrix:
2627
runs-on: ubuntu-latest
@@ -36,25 +37,28 @@ jobs:
3637
- 18.3.0-canary-4b84f1161-20240318
3738
- 0.0.0-experimental-4b84f1161-20240318
3839
steps:
39-
- uses: actions/checkout@v2
40-
- uses: actions/setup-node@v2
40+
- uses: actions/checkout@v3
41+
- uses: pnpm/action-setup@v2
42+
with:
43+
version: 8.2.0
44+
- uses: actions/setup-node@v3
4145
with:
42-
node-version: '18'
43-
cache: yarn
44-
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
45-
- run: yarn install --frozen-lockfile --check-files
46+
node-version: 18
47+
cache: 'pnpm'
48+
cache-dependency-path: '**/pnpm-lock.yaml'
49+
- run: pnpm install --frozen-lockfile
4650
- name: Install legacy testing-library
4751
if: ${{ startsWith(matrix.react, '16.') || startsWith(matrix.react, '17.') }}
48-
run: yarn add -D @testing-library/[email protected]
52+
run: pnpm add -D @testing-library/[email protected]
4953
- name: Patch for React 16
5054
if: ${{ startsWith(matrix.react, '16.') }}
5155
run: |
5256
sed -i~ '1s/^/import React from "react";/' tests/*/*.tsx tests/*/*/*.tsx
5357
sed -i~ 's/"jsx": "react-jsx"/"jsx": "react"/' tsconfig.json
5458
sed -i~ 's/import\.meta\.env[?]\.MODE/"DEVELOPMENT".toLowerCase()/' src/*.ts src/*/*.ts src/*/*/*.ts
5559
- name: Test Build # we need to build for babel tests
56-
run: yarn build
60+
run: pnpm build
5761
- name: Test ${{ matrix.react }}
5862
run: |
59-
yarn add -D react@${{ matrix.react }} react-dom@${{ matrix.react }}
60-
yarn test:ci
63+
pnpm add -D react@${{ matrix.react }} react-dom@${{ matrix.react }}
64+
pnpm test:spec

.github/workflows/test-old-typescript.yml

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,17 @@ jobs:
3131
- 3.9.7
3232
- 3.8.3
3333
steps:
34-
- uses: actions/checkout@v2
35-
- uses: actions/setup-node@v2
34+
- uses: actions/checkout@v3
35+
- uses: pnpm/action-setup@v2
3636
with:
37-
node-version: '18'
38-
cache: yarn
39-
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
40-
- run: yarn install --frozen-lockfile --check-files
41-
- run: yarn build
37+
version: 8.2.0
38+
- uses: actions/setup-node@v3
39+
with:
40+
node-version: 18
41+
cache: 'pnpm'
42+
cache-dependency-path: '**/pnpm-lock.yaml'
43+
- run: pnpm install --frozen-lockfile
44+
- run: pnpm build
4245
- name: Patch for Newer TS
4346
if: ${{ matrix.typescript == '4.9.5' || matrix.typescript == '4.8.4' }}
4447
run: |
@@ -66,34 +69,23 @@ jobs:
6669
sed -i~ 's/"jsx": "react-jsx",/"jsx": "react",/' tsconfig.json
6770
sed -i~ 's/"noUncheckedIndexedAccess": true,//' tsconfig.json
6871
sed -i~ 's/^import type /import /' tests/*/*.tsx tests/*/*/*.tsx
69-
yarn json -I -f package.json -e "this.resolutions={}; this.resolutions['@types/prettier']='2.4.2'; this.resolutions['@types/node']='18.11.18';"
70-
72+
pnpm json -I -f package.json -e "this.resolutions={}; this.resolutions['@types/prettier']='2.4.2'; this.resolutions['@types/node']='18.11.18';"
73+
7174
rm -r tests/react/vanilla-utils/atomWithObservable.*
7275
- name: Install old TypeScript
73-
run: yarn add -D typescript@${{ matrix.typescript }}
76+
run: pnpm add -D typescript@${{ matrix.typescript }}
7477
- name: Patch testing setup for Old TS
7578
if: ${{ matrix.typescript == '4.4.4' || matrix.typescript == '4.3.5' || matrix.typescript == '4.2.3' || matrix.typescript == '4.1.5' || matrix.typescript == '4.0.5' || startsWith(matrix.typescript, '3.') }}
7679
run: |
77-
rm node_modules/@vitest/expect/dist/*.d.ts
78-
echo "declare module '@vitest/expect'" >> ./src/types.d.ts
79-
rm node_modules/@vitest/runner/dist/*.d.ts
80-
echo "declare module '@vitest/runner'" >> ./src/types.d.ts
81-
rm node_modules/@vitest/spy/dist/*.d.ts
82-
echo "declare module '@vitest/spy'" >> ./src/types.d.ts
83-
rm node_modules/@vitest/utils/dist/*.d.ts
84-
echo "declare module '@vitest/utils'" >> ./src/types.d.ts
85-
rm node_modules/vite-node/dist/*.d.ts
86-
echo "declare module 'vite-node'" >> ./src/types.d.ts
87-
rm node_modules/vitest/dist/*.d.ts
88-
echo "declare module 'vitest'" >> ./src/types.d.ts
80+
8981
- name: Patch testing setup for older TS
9082
if: ${{ matrix.typescript == '4.0.5' || startsWith(matrix.typescript, '3.') }}
9183
run: |
92-
yarn add -D @testing-library/[email protected] @testing-library/[email protected]
84+
pnpm add -D @testing-library/[email protected] @testing-library/[email protected]
9385
rm node_modules/vitest/dist/*.d.ts
9486
echo "declare module 'vitest'" >> ./src/types.d.ts
9587
- name: Test ${{ matrix.typescript }}
9688
run: |
9789
rm -r node_modules/@types/babel__core/node_modules
9890
sed -i~ 's/">=4.2": {/">=4.1": {/' node_modules/rxjs/package.json
99-
yarn tsc --noEmit
91+
pnpm test:types

CONTRIBUTING.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,25 @@ If you would like to contribute by fixing an open issue or developing a new feat
1919
1. Fork this repository
2020
2. Create a new feature branch based off the `main` branch
2121
3. Follow the [Core lib](#core-lib) and/or the [docs](#docs) guide below and come back to this once done
22-
4. Run `yarn run prettier` to format the code
22+
4. Run `pnpm run prettier` to format the code
2323
5. Git stage your required changes and commit (review the commit guidelines below)
2424
6. Submit the PR for review
2525

2626
### Core lib
2727

28-
1. Install dependencies by running `yarn`. We use [version 1](https://classic.yarnpkg.com/lang/en/docs/install) of yarn
28+
1. Install dependencies by running `pnpm`.
2929
2. Create failing tests for your fix or new feature in the `tests` folder
3030
3. Implement your changes
31-
4. Build the library `yarn run build` _(Pro-tip: `yarn run build-watch` runs the build in watch mode)_
32-
5. Run the tests and ensure that they pass. _(Pro-tip: `yarn test:dev` runs the test in watch mode)_
33-
6. You can use `yarn link` or `yalc` to sym-link this package and test it locally on your own project. Alternatively, you may use CodeSandbox CI's canary releases to test the changes in your own project (requires a PR to be created first)
31+
4. Build the library `pnpm run build` _(Pro-tip: `pnpm run build-watch` runs the build in watch mode)_
32+
5. Run the tests and ensure that they pass.
33+
6. You can use `pnpm link` or `yalc` to sym-link this package and test it locally on your own project. Alternatively, you may use CodeSandbox CI's canary releases to test the changes in your own project (requires a PR to be created first)
3434
7. Follow step 4 and onwards from the [general](#general) guide above to bring it to the finish line
3535

3636
### Docs
3737

3838
1. Navigate to the `website` folder. Eg. `cd website`
39-
2. Install dependencies by running `yarn` in the `website` folder We use [version 1](https://classic.yarnpkg.com/lang/en/docs/install) of yarn
40-
3. Run `yarn dev` to start the dev server
39+
2. Install dependencies by running `pnpm` in the `website` folder
40+
3. Run `pnpm dev` to start the dev server
4141
4. Navigate to [`http://localhost:9000`](http://localhost:9000) to view the docs
4242
5. Navigate to the `docs` folder and make necessary changes to the docs
4343
6. Add your changes to the docs and see them live reloaded in the browser
@@ -49,7 +49,7 @@ We follow the [conventional commit spec](https://www.conventionalcommits.org/en/
4949

5050
Your commit type must be one of the following:
5151

52-
- **build**: Changes that affect the build system or external dependencies (example scopes: yarn, npm, rollup, etc.)
52+
- **build**: Changes that affect the build system or external dependencies (example scopes: pnpm, npm, rollup, etc.)
5353
- **ci**: Changes to our CI configuration files and scripts (example scopes: GitHub Actions)
5454
- **docs**: Documentation only changes
5555
- **feat**: A new feature

package.json

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"name": "jotai",
3+
"description": "👻 Primitive and flexible state management for React",
34
"private": true,
5+
"type": "commonjs",
46
"version": "2.8.0",
5-
"description": "👻 Primitive and flexible state management for React",
67
"main": "./index.js",
78
"types": "./index.d.ts",
89
"typesVersions": {
@@ -60,8 +61,8 @@
6061
"sideEffects": false,
6162
"scripts": {
6263
"prebuild": "shx rm -rf dist",
63-
"build": "concurrently -m 8 'yarn:build:*'",
64-
"build-watch": "concurrently -n watch: 'yarn:build:* --watch'",
64+
"build": "pnpm run prebuild && pnpm run '/^build:.*/' && pnpm run postbuild",
65+
"build-watch": "pnpm run '/^build:.*/' --watch",
6566
"build:base": "rollup -c",
6667
"build:utils": "rollup -c --config-utils",
6768
"build:babel:plugin-debug-label": "rollup -c --config-babel_plugin-debug-label",
@@ -72,15 +73,15 @@
7273
"build:react": "rollup -c --config-react --client-only",
7374
"build:react:utils": "rollup -c --config-react_utils --client-only",
7475
"build:experimental": "rollup -c --config-experimental",
75-
"postbuild": "yarn patch-d-ts && yarn copy && yarn patch-ts3.8 && yarn patch-old-ts && yarn patch-esm-ts && yarn patch-readme",
76+
"postbuild": "pnpm patch-d-ts && pnpm copy && pnpm patch-ts3.8 && pnpm patch-old-ts && pnpm patch-esm-ts && pnpm patch-readme",
7677
"prettier": "prettier '*.{js,json,md}' '{src,tests,benchmarks,docs}/**/*.{ts,tsx,md,mdx}' --write",
77-
"prettier:ci": "prettier '*.{js,json,md}' '{src,tests,benchmarks,docs}/**/*.{ts,tsx,md,mdx}' --list-different",
7878
"eslint": "eslint --fix --no-eslintrc --c .eslintrc.json '*.{js,json,ts}' '{src,tests,benchmarks}/**/*.{ts,tsx}'",
79-
"eslint:ci": "eslint --no-eslintrc --c .eslintrc.json '*.{js,json,ts}' '{src,tests,benchmarks}/**/*.{ts,tsx}'",
80-
"pretest": "tsc",
81-
"test": "vitest --ui --coverage",
82-
"test:ci": "vitest && USE_STORE2=true vitest",
83-
"test:ci:build": "vitest",
79+
"test": "pnpm run '/^test:.*/'",
80+
"test:format": "prettier '*.{js,json,md}' '{src,tests,benchmarks,docs}/**/*.{ts,tsx,md,mdx}' --list-different",
81+
"test:types": "tsc --noEmit",
82+
"test:lint": "eslint --no-eslintrc --c .eslintrc.json '*.{js,json,ts}' '{src,tests,benchmarks}/**/*.{ts,tsx}'",
83+
"test:spec": "vitest && USE_STORE2=true vitest",
84+
"test-build:spec": "vitest",
8485
"patch-d-ts": "node -e \"var {entries}=require('./rollup.config.js');require('shelljs').find('dist/**/*.d.ts').forEach(f=>{entries.forEach(({find,replacement})=>require('shelljs').sed('-i',new RegExp(' from \\''+find.source.slice(0,-1)+'\\';$'),' from \\''+replacement+'\\';',f));require('shelljs').sed('-i',/ from '(\\.[^']+)\\.ts';$/,' from \\'\\$1\\';',f)})\"",
8586
"copy": "shx cp -r dist/src/* dist/esm && shx cp -r dist/src/* dist && shx rm -rf dist/src && shx rm -rf dist/{src,tests} && downlevel-dts dist dist/ts3.8 --to=3.8 && shx cp package.json readme.md LICENSE dist && json -I -f dist/package.json -e \"this.private=false; this.devDependencies=undefined; this.optionalDependencies=undefined; this.scripts=undefined; this.prettier=undefined;\"",
8687
"patch-ts3.8": "node -e \"require('shelljs').find('dist/ts3.8/**/*.d.ts').forEach(f=>require('fs').appendFileSync(f,'declare type Awaited<T> = T extends Promise<infer V> ? V : T;'))\"",
@@ -114,6 +115,7 @@
114115
"url": "https://github.com/pmndrs/jotai/issues"
115116
},
116117
"homepage": "https://github.com/pmndrs/jotai",
118+
"packageManager": "[email protected]",
117119
"devDependencies": {
118120
"@babel/core": "^7.24.4",
119121
"@babel/plugin-transform-react-jsx": "^7.23.4",
@@ -132,6 +134,7 @@
132134
"@testing-library/react": "^14.2.2",
133135
"@testing-library/user-event": "14.4.3",
134136
"@types/babel__core": "^7.20.5",
137+
"@types/babel__template": "^7.4.4",
135138
"@types/node": "^20.12.4",
136139
"@types/react": "18.2.56",
137140
"@types/react-dom": "^18.2.24",
@@ -140,7 +143,6 @@
140143
"@vitest/coverage-v8": "^1.4.0",
141144
"@vitest/ui": "^1.4.0",
142145
"benny": "^3.7.1",
143-
"concurrently": "^8.2.2",
144146
"downlevel-dts": "^0.11.0",
145147
"esbuild": "^0.20.2",
146148
"eslint": "^8.57.0",
@@ -162,6 +164,7 @@
162164
"rollup-plugin-banner2": "^1.2.3",
163165
"rollup-plugin-esbuild": "^6.1.1",
164166
"rxjs": "^7.8.1",
167+
"shelljs": "^0.8.5",
165168
"shx": "^0.3.4",
166169
"ts-expect": "^1.3.0",
167170
"ts-node": "^10.9.2",
@@ -185,6 +188,5 @@
185188
"react": {
186189
"optional": true
187190
}
188-
},
189-
"packageManager": "[email protected]"
191+
}
190192
}

0 commit comments

Comments
 (0)