Skip to content

Commit

Permalink
merge canary
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Sep 22, 2022
2 parents beaf868 + 4c90499 commit 0e873eb
Show file tree
Hide file tree
Showing 106 changed files with 6,910 additions and 7,619 deletions.
5 changes: 3 additions & 2 deletions .codesandbox/ci.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"buildCommand": "build",
"sandboxes": ["swr-basic-p7dg6", "swr-states-4une7", "swr-infinite-jb5bm", "swr-ssr-j9b2y"],
"node": "14"
"node": "16",
"installCommand": "csb:install",
"buildCommand": "csb:build"
}
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"@typescript-eslint/no-var-requires": 0,
"@typescript-eslint/no-explicit-any": 0,
"@typescript-eslint/explicit-module-boundary-types": 0,
"@typescript-eslint/consistent-type-imports": [2, {"prefer": "type-imports"}],
"@typescript-eslint/ban-types": 0,
"react-hooks/rules-of-hooks": 2,
"react-hooks/exhaustive-deps": 1,
Expand Down
6 changes: 3 additions & 3 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
contributors and maintainers pledge to make participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
Expand All @@ -26,7 +26,7 @@ Examples of unacceptable behavior by participants include:
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
* Publishing others' private information, such as physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
Expand Down Expand Up @@ -58,7 +58,7 @@ Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at coc@vercel.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
obligated to maintain confidentiality concerning the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
Expand Down
18 changes: 9 additions & 9 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,46 @@ Thank you for reading this guide and we appreciate any contribution.

## Ask a Question

You can use the repository's [Discussions](https://github.com/vercel/swr/discussions) page to ask any questions, post feedback or share your experience on how you use this library.
You can use the repository's [Discussions](https://github.com/vercel/swr/discussions) page to ask any questions, post feedback, or share your experience on how you use this library.

## Report a Bug

Whenever you find something which is not working properly, please first search the repository's [Issues](https://github.com/vercel/swr/issues) page and make sure it's not reported by someone else already.

If not, feel free to open an issue with the detailed description of the problem and the expected behavior. And reproduction (for example a [CodeSandbox](https://codesandbox.io) link) will be extremely helpful.
If not, feel free to open an issue with a detailed description of the problem and the expected behavior. And reproduction (for example a [CodeSandbox](https://codesandbox.io) link) will be extremely helpful.

## Request for a New Feature

For new features, it would be great to have some discussions from the community before starting working on it. You can either create an issue (if there isn't one) or post a thread in the [Discussions](https://github.com/vercel/swr/discussions) page to describe the feature that you want to have.
For new features, it would be great to have some discussions from the community before starting working on it. You can either create an issue (if there isn't one) or post a thread on the [Discussions](https://github.com/vercel/swr/discussions) page to describe the feature that you want to have.

If possible, you can add other additional context like how this feature can be implemented technically, what other alternative solutions we can have, etc.
If possible, you can add another additional context like how this feature can be implemented technically, what other alternative solutions we can have, etc.

## Open a PR for Bugfix or Feature

### Local Development with Examples

To run SWR locally, you can start it with any example in `examples` folder. You need to setup the example and run command in the root directory for overriding SWR and its dependencies to local assets.
To run SWR locally, you can start it with any example in the `examples` folder. You need to set up the example and run the command in the root directory for overriding SWR and its dependencies to local assets.

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
27 changes: 16 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,23 @@ on:
jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
- uses: actions/checkout@v3

- name: Setup pnpm
uses: pnpm/action-setup@v2.2.2
with:
node-version: '14'
cache: 'yarn'
- run: yarn install
- run: yarn types:check
- run: yarn lint
- run: yarn build
- run: yarn test
version: 7

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

- run: pnpm install
- run: pnpm run-all-checks
- run: pnpm clean
- run: pnpm build
env:
CI: true
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ dist
.eslintcache
examples/**/yarn.lock
package-lock.json
tsconfig.tsbuildinfo
coverage
*.tsbuildinfo
coverage
.rollup.cache
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm lint-staged && pnpm types:check
4 changes: 4 additions & 0 deletions _internal/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export { SWRConfig, revalidateEvents }

export { initCache } from './utils/cache'
export { defaultConfig, cache, mutate, compare } from './utils/config'
import { setupDevTools } from './utils/devtools'
export * from './utils/env'
export { SWRGlobalState } from './utils/global-state'
export { stableHash } from './utils/hash'
Expand All @@ -20,5 +21,8 @@ export { getTimestamp } from './utils/timestamp'
export { useSWRConfig } from './utils/use-swr-config'
export { preset, defaultConfigOptions } from './utils/web-preset'
export { withMiddleware } from './utils/with-middleware'
export { preload } from './utils/preload'

export * from './types'

setupDevTools()
11 changes: 8 additions & 3 deletions _internal/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
{
"name": "swr-internal",
"version": "0.0.1",
"main": "./dist/index.js",
"module": "./dist/index.esm.js",
"types": "./dist/_internal",
"types": "./dist/_internal/index.d.ts",
"exports": "./dist/index.mjs",
"private": true,
"scripts": {
"watch": "bunchee index.ts -w",
"build": "bunchee index.ts",
"types:check": "tsc --noEmit",
"clean": "rimraf dist"
},
"peerDependencies": {
"react": "*"
}
Expand Down
3 changes: 1 addition & 2 deletions _internal/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": "..",
"outDir": "./dist"
},
"include": ["./**/*.ts"]
"include": ["./*.ts"]
}

0 comments on commit 0e873eb

Please sign in to comment.