Skip to content

Commit

Permalink
Merge branch 'main' into check-fallback-undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
promer94 committed May 2, 2024
2 parents 42f35b7 + cc9fc25 commit e20c6e9
Show file tree
Hide file tree
Showing 20 changed files with 323 additions and 339 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ runs:
using: composite
steps:
- name: Setup pnpm
uses: pnpm/action-setup@v2.2.4
uses: pnpm/action-setup@v3

- name: Use Node.js 18
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18
cache: pnpm
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/test-canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install
uses: ./.github/workflows/install
Expand All @@ -19,8 +19,6 @@ jobs:
run: corepack pnpm upgrade react@canary react-dom@canary use-sync-external-store@canary

- name: Lint and test
env:
TEST_REACT_LEGACY: 1
run: |
pnpm clean
pnpm build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-legacy-react.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install
uses: ./.github/workflows/install
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/test-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install
uses: ./.github/workflows/install
Expand All @@ -23,6 +23,7 @@ jobs:
pnpm clean
pnpm build
pnpm run-all-checks
npm pack
pnpm attw
pnpm test
pnpm test:build
Expand All @@ -32,7 +33,7 @@ jobs:
image: mcr.microsoft.com/playwright:v1.34.3-focal
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install
uses: ./.github/workflows/install
Expand All @@ -45,7 +46,7 @@ jobs:
pnpm test:e2e
- name: Upload test results
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: playwright-report
Expand All @@ -57,7 +58,7 @@ jobs:
id-token: write
steps:
- name: Check out
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install
uses: ./.github/workflows/install
Expand Down
33 changes: 3 additions & 30 deletions .github/workflows/trigger-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ on:
- minor
- major

secrets:
RELEASE_BOT_GITHUB_TOKEN:
required: true

name: Trigger Release

env:
Expand All @@ -34,36 +30,13 @@ jobs:

environment: release-${{ github.event.inputs.releaseType }}-${{ github.event.inputs.semverType }}
steps:
- name: Setup node
uses: actions/setup-node@v3
if: ${{ steps.docs-change.outputs.docsChange == 'nope' }}
with:
node-version: 18
check-latest: true

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 10
token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}

- run: npm i -g pnpm@${PNPM_VERSION}

- id: get-store-path
run: echo STORE_PATH=$(pnpm store path) >> $GITHUB_OUTPUT

- uses: actions/cache@v3
timeout-minutes: 5
id: cache-pnpm-store
with:
path: ${{ steps.get-store-path.outputs.STORE_PATH }}
key: pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
pnpm-store-
pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
- run: pnpm install

- name: Install
uses: ./.github/workflows/install
- run: |
pnpm clean
pnpm build
Expand Down
17 changes: 17 additions & 0 deletions e2e/site/app/suspense-fallback/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { SWRConfig } from 'swr'

function createPromiseData(data: any, timeout: number) {
return new Promise(resolve => {
setTimeout(() => {
resolve(data)
}, timeout)
})
}

export default function Layout({ children }: { children: React.ReactNode }) {
const fallback = {
'/api/promise': createPromiseData({ value: 'async promise' }, 2000)
}

return <SWRConfig value={{ fallback }}>{children}</SWRConfig>
}
9 changes: 9 additions & 0 deletions e2e/site/app/suspense-fallback/promise/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use client'

import useSWR from 'swr'

export default function Page() {
const { data, isLoading } = useSWR('/api/promise')

return <div>{isLoading ? 'loading...' : data?.value}</div>
}
6 changes: 1 addition & 5 deletions e2e/site/next.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
serverActions: true,
},
}
const nextConfig = {}

module.exports = nextConfig
2 changes: 1 addition & 1 deletion e2e/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@types/node": "^20.2.5",
"@types/react": "^18.2.8",
"@types/react-dom": "18.2.4",
"next": "^13.4.4",
"next": "^14.1.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"typescript": "5.1.3",
Expand Down
11 changes: 11 additions & 0 deletions e2e/test/suspense-fallback.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable testing-library/prefer-screen-queries */
import { test, expect } from '@playwright/test'

test.describe('suspense fallback', () => {
test('should wait for promise fallback value to be resolved', async ({
page
}) => {
await page.goto('./suspense-fallback/promise', { waitUntil: 'commit' })
await expect(page.getByText('async promise')).toBeVisible()
})
})
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swr",
"version": "2.2.6-beta.0",
"version": "2.2.6-beta.2",
"description": "React Hooks library for remote data fetching",
"keywords": [
"swr",
Expand Down Expand Up @@ -97,10 +97,10 @@
"csb:install": "corepack enable && corepack pnpm i",
"csb:build": "pnpm build",
"clean": "rimraf ./dist && rimraf playwright-report test-result",
"watch": "pnpm -r run watch",
"watch": "bunchee -w",
"build": "bunchee",
"build:e2e": "pnpm next build e2e/site",
"attw": "attw --pack",
"attw": "attw --pack .",
"types:check": "tsc --noEmit",
"prepublishOnly": "pnpm clean && pnpm build",
"publish-beta": "pnpm publish --tag beta",
Expand All @@ -121,7 +121,7 @@
]
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.7.0",
"@arethetypeswrong/cli": "^0.15.3",
"@playwright/test": "^1.34.3",
"@swc/core": "^1.3.62",
"@swc/jest": "0.2.26",
Expand All @@ -134,7 +134,7 @@
"@types/use-sync-external-store": "^0.0.3",
"@typescript-eslint/eslint-plugin": "5.59.8",
"@typescript-eslint/parser": "5.59.8",
"bunchee": "^4.4.8",
"bunchee": "^5.1.1",
"eslint": "8.42.0",
"eslint-config-prettier": "8.8.0",
"eslint-plugin-jest-dom": "5.1.0",
Expand All @@ -145,7 +145,7 @@
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"lint-staged": "13.2.2",
"next": "14.1.0",
"next": "14.1.4",
"prettier": "2.8.8",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
Loading

0 comments on commit e20c6e9

Please sign in to comment.