Skip to content

Commit 10962d9

Browse files
authored
Merge branch 'main' into jsr-trial
2 parents a134ab4 + 1dbe400 commit 10962d9

52 files changed

Lines changed: 19810 additions & 17872 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.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: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,24 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
build: [cjs, umd] # [cjs, esm, umd, system]
15+
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-
yarn add -D react@17.0.2 react-dom@17.0.2 @testing-library/react@12.1.4
32+
pnpm add -D react@17.0.2 react-dom@17.0.2 @testing-library/react@12.1.4
3033
- name: Patch for DEV-ONLY
3134
if: ${{ matrix.env == 'development' }}
3235
run: |
@@ -40,28 +43,31 @@ jobs:
4043
- name: Patch for CJS
4144
if: ${{ matrix.build == 'cjs' }}
4245
run: |
43-
sed -i~ "s/<rootDir>\/src\(.*\)\.ts/<rootDir>\/dist\1.js/" package.json
46+
sed -i~ "s/resolve('\.\/src\(.*\)\.ts')/resolve('\.\/dist\1.js')/" vitest.config.ts
47+
sed -i~ "s/import { useResetAtom } from 'jotai\/react\/utils'/const { useResetAtom } = require('..\/..\/..\/dist\/react\/utils.js')/" tests/react/utils/useResetAtom.test.tsx
48+
sed -i~ "s/import { RESET, atomWithReducer, atomWithReset } from 'jotai\/vanilla\/utils'/const { RESET, atomWithReducer, atomWithReset } = require('..\/..\/..\/dist\/vanilla\/utils.js')/" tests/react/utils/useResetAtom.test.tsx
4449
- name: Patch for ESM
4550
if: ${{ matrix.build == 'esm' }}
4651
run: |
47-
sed -i~ "s/<rootDir>\/src\(.*\)\.ts/<rootDir>\/dist\/esm\1.js" package.json
52+
sed -i~ "s/resolve('\.\/src\(.*\)\.ts')/resolve('\.\/dist\/esm\1.mjs')/" vitest.config.ts
4853
sed -i~ "1s/^/import.meta.env=import.meta.env||{};import.meta.env.MODE='${NODE_ENV}';/" tests/*/*.tsx tests/*/*/*.tsx
4954
env:
5055
NODE_ENV: ${{ matrix.env }}
5156
- name: Patch for UMD
5257
if: ${{ matrix.build == 'umd' }}
5358
run: |
54-
sed -i~ "s/<rootDir>\/src\(.*\)\.ts/<rootDir>\/dist\/umd\1.${NODE_ENV}.js/" package.json
59+
sed -i~ "s/resolve('\.\/src\(.*\)\.ts')/resolve('\.\/dist\/umd\1.${NODE_ENV}.js')/" vitest.config.ts
60+
rm tests/react/utils/useResetAtom.test.tsx # FIXME we skip this for now. Actually I'm not sure if we really run tests with UMD build
5561
env:
5662
NODE_ENV: ${{ matrix.env }}
5763
- name: Patch for SystemJS
5864
if: ${{ matrix.build == 'system' }}
5965
run: |
60-
sed -i~ "s/<rootDir>\/src\(.*\)\.ts/<rootDir>\/dist\/system\1.${NODE_ENV}.js/" package.json
66+
sed -i~ "s/resolve('\.\/src\(.*\)\.ts')/resolve('\.\/dist\/system\1.${NODE_ENV}.js')/" vitest.config.ts
6167
env:
6268
NODE_ENV: ${{ matrix.env }}
6369
- name: Test ${{ matrix.build }} ${{ matrix.env }}
6470
run: |
65-
yarn test:ci
71+
pnpm test-build:spec # test:spec
6672
env:
6773
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/react@12.1.4
52+
run: pnpm add -D @testing-library/react@12.1.4
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: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
typescript:
16-
- 5.3.2
16+
- 5.4.4
17+
- 5.3.3
1718
- 5.2.2
1819
- 5.1.6
1920
- 5.0.4
@@ -30,14 +31,17 @@ jobs:
3031
- 3.9.7
3132
- 3.8.3
3233
steps:
33-
- uses: actions/checkout@v2
34-
- uses: actions/setup-node@v2
34+
- uses: actions/checkout@v3
35+
- uses: pnpm/action-setup@v2
3536
with:
36-
node-version: '18'
37-
cache: yarn
38-
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
39-
- run: yarn install --frozen-lockfile --check-files
40-
- 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
4145
- name: Patch for Newer TS
4246
if: ${{ matrix.typescript == '4.9.5' || matrix.typescript == '4.8.4' }}
4347
run: |
@@ -47,7 +51,7 @@ jobs:
4751
sed -i~ 's/"jotai\/\*": \["\.\/src\/\*\.ts"\]/"jotai\/*": [".\/dist\/*.d.ts"]/' tsconfig.json
4852
sed -i~ 's/"include": .*/"include": ["src\/types.d.ts", "dist\/**\/*", "tests\/**\/*"],/' tsconfig.json
4953
- name: Patch for Old TS
50-
if: ${{ matrix.typescript == '4.7.4' || matrix.typescript == '4.6.4' || matrix.typescript == '4.5.5' || 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.') }}
54+
if: ${{ matrix.typescript == '4.7.4' || matrix.typescript == '4.6.4' || matrix.typescript == '4.5.5' || 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.') }}
5155
run: |
5256
sed -i~ 's/\/\/ @ts-expect-error.*\[LATEST-TS-ONLY\]//' tests/*/*.tsx tests/*/*/*.tsx
5357
sed -i~ 's/"target":/"skipLibCheck":true,"target":/' tsconfig.json
@@ -65,19 +69,23 @@ jobs:
6569
sed -i~ 's/"jsx": "react-jsx",/"jsx": "react",/' tsconfig.json
6670
sed -i~ 's/"noUncheckedIndexedAccess": true,//' tsconfig.json
6771
sed -i~ 's/^import type /import /' tests/*/*.tsx tests/*/*/*.tsx
68-
yarn json -I -f package.json -e "this.resolutions={}; this.resolutions['@types/prettier']='2.4.2'; this.resolutions['@types/node']='18.11.18';"
69-
yarn add -D @types/prettier@2.4.2 @types/node@18.11.18 @types/yargs@17.0.13 @types/babel__traverse@7.18.2
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+
pnpm add -D @types/prettier@2.4.2 @types/node@18.11.18 @types/yargs@17.0.13 @types/babel__traverse@7.18.2
7074
rm -r tests/react/vanilla-utils/atomWithObservable.*
7175
- name: Install old TypeScript
72-
run: yarn add -D typescript@${{ matrix.typescript }}
76+
run: pnpm add -D typescript@${{ matrix.typescript }}
77+
- name: Patch testing setup for Old TS
78+
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.') }}
79+
run: |
80+
pnpm add -D vitest@0.33.0 @vitest/coverage-v8@0.33.0 @vitest/ui@0.33.0
7381
- name: Patch testing setup for older TS
7482
if: ${{ matrix.typescript == '4.0.5' || startsWith(matrix.typescript, '3.') }}
7583
run: |
76-
yarn add -D @testing-library/user-event@12.1.7 @testing-library/react@11.0.4
84+
pnpm add -D @testing-library/user-event@12.1.7 @testing-library/react@11.0.4
7785
rm node_modules/vitest/dist/*.d.ts
7886
echo "declare module 'vitest'" >> ./src/types.d.ts
7987
- name: Test ${{ matrix.typescript }}
8088
run: |
8189
rm -r node_modules/@types/babel__core/node_modules
8290
sed -i~ 's/">=4.2": {/">=4.1": {/' node_modules/rxjs/package.json
83-
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

docs/extensions/effect.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ function MyComponent() {
9797

9898
</details>
9999

100-
- **Resistent To Infinite Loops:**
100+
- **Resistant To Infinite Loops:**
101101
`atomEffect` does not rerun when it changes a value with `set` that it is watching.
102102

103103
<!-- prettier-ignore -->
@@ -370,7 +370,7 @@ This guarantees that a single effect will be used regardless of how many calls t
370370

371371
The same guarantee can be achieved with the useEffect hook if you ensure that the useEffect is idempotent.
372372

373-
atomEffects are distinguished from useEffect in a few other ways. They can directly react to atom state changes, are resistent to infinite loops, and can be mounted conditionally.
373+
atomEffects are distinguished from useEffect in a few other ways. They can directly react to atom state changes, are resistant to infinite loops, and can be mounted conditionally.
374374

375375
#### It's up to you
376376

docs/extensions/immer.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ npm i immer jotai-immer
1515

1616
## atomWithImmer
1717

18-
`atomWithImmer` creates a new atom similar to the regular [`atom`](../core/atom.mdx) [atom] with a different `writeFunction`. In this bundle, we don't have read-only atoms, because the point of these functions is the immer produce(mutability) function.
18+
`atomWithImmer` creates a new atom similar to the regular [`atom`](../core/atom.mdx) with a different `writeFunction`. In this bundle, we don't have read-only atoms, because the point of these functions is the immer produce(mutability) function.
1919
The signature of writeFunction is `(get, set, update: (draft: Draft<Value>) => void) => void`.
2020

2121
```jsx

0 commit comments

Comments
 (0)