Skip to content

Commit

Permalink
Merge branch 'main' into fix/compiler-friendly-provider
Browse files Browse the repository at this point in the history
  • Loading branch information
dai-shi committed Dec 16, 2024
2 parents 735b510 + 78295df commit 3185b51
Show file tree
Hide file tree
Showing 53 changed files with 7,690 additions and 70,365 deletions.
20 changes: 4 additions & 16 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,13 @@
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
"plugin:prettier/recommended",
"plugin:react/jsx-runtime",
"plugin:react-hooks/recommended",
"plugin:import/errors",
"plugin:import/warnings"
],
"plugins": [
"@typescript-eslint",
"react",
"prettier",
"react-hooks",
"import",
"@vitest",
"eslint-plugin-react-compiler",
"jest-dom",
"testing-library"
"plugin:import/warnings",
"plugin:prettier/recommended"
],
"plugins": ["react-compiler"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2018,
Expand Down Expand Up @@ -78,8 +68,6 @@
"pathGroupsExcludedImportTypes": ["builtin"]
}
],
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off",
"sort-imports": [
"error",
{
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/compressed-size-action.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
name: Compressed Size

on: [ pull_request ]
on: [pull_request]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
cache: 'pnpm'
cache-dependency-path: '**/pnpm-lock.yaml'
- uses: preactjs/compressed-size-action@v2
with:
pattern: "./dist/**/*.{js,mjs}"
pattern: './dist/**/*.{js,mjs}'
17 changes: 17 additions & 0 deletions .github/workflows/cr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Publish Any Commit

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
- run: pnpm install
- run: pnpm build
- run: pnpm dlx pkg-pr-new publish './dist' --compact --template './examples/*'
22 changes: 17 additions & 5 deletions .github/workflows/ecosystem-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,33 @@ jobs:
with:
repository: 'jotaijs/jotai-ecosystem-ci'
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 22
cache: 'pnpm'
cache-dependency-path: '**/pnpm-lock.yaml'
- run: pnpm install --frozen-lockfile
- run: pnpm run ecosystem-ci
- name: Get Short SHA
id: short_sha
run: |
api="https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.issue.number }}"
sha=$(curl -s -H "Authorization: token $GITHUB_TOKEN" $api | jq -r '.head.sha' | cut -c1-8)
echo "x=$sha" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run Ecosystem CI
id: run_command
run: |
echo "x<<EOF" >> $GITHUB_OUTPUT
pnpm run ecosystem-ci | grep -A999 -- '---- Jotai Ecosystem CI Results ----' >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
env:
JOTAI_PKG: https://pkg.csb.dev/pmndrs/jotai/commit/${{ github.event.pull_request.head.sha.substring(0, 8) }}/jotai
JOTAI_PKG: https://pkg.csb.dev/pmndrs/jotai/commit/${{ steps.short_sha.outputs.x }}/jotai
- uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
issue-number: ${{ github.event.issue.number }}
body: |
## Ecosystem CI Output
```
${{ steps.run_command.outputs.command_output }}
${{ steps.run_command.outputs.x }}
```
2 changes: 1 addition & 1 deletion .github/workflows/lint-and-type.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
cache: 'pnpm'
cache-dependency-path: '**/pnpm-lock.yaml'
- run: pnpm install --frozen-lockfile
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/livecodes-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
cache: 'pnpm'
cache-dependency-path: '**/pnpm-lock.yaml'
- uses: live-codes/preview-in-livecodes@v1
with:
install-command: "pnpm install --frozen-lockfile"
build-command: "pnpm build"
base-url: "https://{{LC::REF}}.preview-in-livecodes-demo.pages.dev"
install-command: pnpm install --frozen-lockfile
build-command: pnpm build
base-url: 'https://{{LC::REF}}.preview-in-livecodes-demo.pages.dev'
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
registry-url: 'https://registry.npmjs.org'
cache: 'pnpm'
cache-dependency-path: '**/pnpm-lock.yaml'
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test-multiple-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
cache: 'pnpm'
cache-dependency-path: '**/pnpm-lock.yaml'
- run: pnpm install --frozen-lockfile
Expand All @@ -42,27 +42,27 @@ jobs:
- name: Patch for CJS
if: ${{ matrix.build == 'cjs' }}
run: |
sed -i~ "s/resolve('\.\/src\(.*\)\.ts')/resolve('\.\/dist\1.js')/" vitest.config.ts
sed -i~ "s/resolve('\.\/src\(.*\)\.ts')/resolve('\.\/dist\1.js')/" vitest.config.mts
sed -i~ "s/import { useResetAtom } from 'jotai\/react\/utils'/const { useResetAtom } = require('..\/..\/..\/dist\/react\/utils.js')/" tests/react/utils/useResetAtom.test.tsx
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
- name: Patch for ESM
if: ${{ matrix.build == 'esm' }}
run: |
sed -i~ "s/resolve('\.\/src\(.*\)\.ts')/resolve('\.\/dist\/esm\1.mjs')/" vitest.config.ts
sed -i~ "s/resolve('\.\/src\(.*\)\.ts')/resolve('\.\/dist\/esm\1.mjs')/" vitest.config.mts
sed -i~ "1s/^/import.meta.env=import.meta.env||{};import.meta.env.MODE='${NODE_ENV}';/" tests/*/*.tsx tests/*/*/*.tsx
env:
NODE_ENV: ${{ matrix.env }}
- name: Patch for UMD
if: ${{ matrix.build == 'umd' }}
run: |
sed -i~ "s/resolve('\.\/src\(.*\)\.ts')/resolve('\.\/dist\/umd\1.${NODE_ENV}.js')/" vitest.config.ts
sed -i~ "s/resolve('\.\/src\(.*\)\.ts')/resolve('\.\/dist\/umd\1.${NODE_ENV}.js')/" vitest.config.mts
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
env:
NODE_ENV: ${{ matrix.env }}
- name: Patch for SystemJS
if: ${{ matrix.build == 'system' }}
run: |
sed -i~ "s/resolve('\.\/src\(.*\)\.ts')/resolve('\.\/dist\/system\1.${NODE_ENV}.js')/" vitest.config.ts
sed -i~ "s/resolve('\.\/src\(.*\)\.ts')/resolve('\.\/dist\/system\1.${NODE_ENV}.js')/" vitest.config.mts
env:
NODE_ENV: ${{ matrix.env }}
- name: Test ${{ matrix.build }} ${{ matrix.env }}
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test-multiple-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
cache: 'pnpm'
cache-dependency-path: '**/pnpm-lock.yaml'
- run: pnpm install --frozen-lockfile
Expand All @@ -33,15 +33,15 @@ jobs:
- 18.1.0
- 18.2.0
- 18.3.1
- 19.0.0-rc.1
- 19.0.0-rc-e1ef8c95-20241115
- 0.0.0-experimental-e1ef8c95-20241115
- 19.0.0
- 19.1.0-canary-4dff0e62-20241213
- 0.0.0-experimental-4dff0e62-20241213
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
cache: 'pnpm'
cache-dependency-path: '**/pnpm-lock.yaml'
- run: pnpm install --frozen-lockfile
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-old-typescript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
cache: 'pnpm'
cache-dependency-path: '**/pnpm-lock.yaml'
- run: pnpm install --frozen-lockfile
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
if: ${{ matrix.typescript == '4.0.5' || startsWith(matrix.typescript, '3.') }}
run: |
pnpm json -I -f package.json -e "this.pnpm.patchedDependencies={};"
pnpm add -D @testing-library/user-event@12.1.7 @testing-library/react@11.0.4
pnpm add -D @testing-library/user-event@12.1.7 @testing-library/react@11.0.4 @types/react-dom@18.3.1
rm node_modules/vitest/dist/*.d.ts
echo "declare module 'vitest'" >> ./src/types.d.ts
- name: Test ${{ matrix.typescript }}
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ If you would like to contribute by fixing an open issue or developing a new feat

### Core lib

1. Install dependencies by running `pnpm`.
1. Install dependencies by running `pnpm install`.
2. Create failing tests for your fix or new feature in the `tests` folder
3. Implement your changes
4. Build the library `pnpm run build` _(Pro-tip: `pnpm run build-watch` runs the build in watch mode)_
Expand Down
13 changes: 13 additions & 0 deletions examples/hacker_news/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="theme-color" content="#000000" />
<title>Jotai Examples | Hacker News</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
41 changes: 14 additions & 27 deletions examples/hacker_news/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,24 @@
"name": "hacker_news",
"version": "2.0.0",
"description": "Demonstrate a news articles with jotai, hit next to see more articles.",
"keywords": [],
"main": "src/index.tsx",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"serve": "vite preview"
},
"dependencies": {
"@react-spring/web": "^9.2.3",
"html-react-parser": "^1.2.6",
"jotai": "^2.0.4",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "^4.0.3"
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@types/react": "^17.0.11",
"@types/react-dom": "^17.0.7",
"typescript": "^4.3.2"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"scripts": {
"start": "SKIP_PREFLIGHT_CHECK=true react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
"@types/react": "^18.2.0",
"@types/react-dom": "^18.2.0",
"@vitejs/plugin-react": "^4.0.0",
"typescript": "^5.0.0",
"vite": "^4.0.0"
}
}
Loading

0 comments on commit 3185b51

Please sign in to comment.