Skip to content

Commit

Permalink
Monorepo, Rebrand to TanStack (#3708)
Browse files Browse the repository at this point in the history
* rebrand

* move to src

* chore: fix build by re-exporting types explicitly

* chore: run everything through prettier

* chore: bring back linting and compilation tasks

* chore: setup eslint-import-resolver-typescript

it still errors with import/no-unresolved, but I think that's because TS errors as well!

* chore: fix a ton of imports

* chore: down to zero ts errors

* chore: export types separately to make the build work

* chore: down to zero eslint issues 🎉

* chore: try to get tests to work

* chore: make tests work

* fix: use better match sorter primitives

* chore: update workflows

* Update ci.yml

* chore: remove match-sorter dependency

* chore: enable bundle size collection

* chore: update to latest react

* fix(devtools): fix typings of rankItems

not sure if that is correct now...

* chore: fix compilation

* tests: fix tests by removing weird comment that is no longer necessary after upgrading react

* tests: remove incrompehensible tests

I don't know what these tests are doing, but overwriting useEffect is not something that makes sense now that we useSyncExternalStore for data fetching anyways ...

* fix(devtools): fix sorting of queries

rankItem doesn't take keys, so we have to pass the queryHash in directly to rank it

* chore: setup ci pipeline and bundlewatch

* chore: build during pr pipelines

* chore: remove private:true

as requested by CI:
Error: Package undefined in /tmp/98d7e7a6 is set to private, remove package.json#private to publish it

* Revert "chore: remove private:true"

This reverts commit e1b237b.

* chore: turn off import/no-unresolved in tests

somehow, that fails in CI, and we have typescript protection against unresolved imports anyhow

* fix: turn of import/no-unresolved for all tanstack imports

* fix: regex

* chore: do not run legacy pipelines on PRs

* chore: fix ci check names

* chore: add react-17 dependencies

* chore: split up ci tasks

* fix: building is done via bundlesize reporting

so we don't need to build during testing

* chore: try to make codesandbox ci work

it requires package to be public, but for installing and yarn workspaces, we need it to be private

* fix: apply private: false to all workspaces

* fix: paths to sandboxes

* chore: fix code coverage collection

* chore: change imports from react-query to tanstack/react-query

* docs: update migration docs with the rebrand

* chore: revert codemod changes

prettier destroyed the assertions

* fix(useIsMutating): we need to subscribe to the right cache

this is likely a copy-paste error, and the tests only worked because we render top-down; now, the tests make sure that components are re-rendered because of the subscription itself

* Update README.md

* docs: devtools documentation for tanstack rebrand

* fix builds

* chore: cleanup

Co-authored-by: Dominik Dorfmeister <[email protected]>
  • Loading branch information
tannerlinsley and TkDodo authored Jul 8, 2022
1 parent e0aad73 commit c5c4417
Show file tree
Hide file tree
Showing 267 changed files with 112,796 additions and 7,422 deletions.
6 changes: 3 additions & 3 deletions .codesandbox/ci.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"packages": ["./"],
"sandboxes": ["/examples/basic", "/examples/basic-typescript"],
"node": "14"
"installCommand": "install:csb",
"sandboxes": ["/examples/react/basic", "/examples/react/basic-typescript"],
"node": "16"
}
32 changes: 17 additions & 15 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "import"],
"extends": [
Expand All @@ -12,9 +13,23 @@
"es6": true
},
"parserOptions": {
"project": "./tsconfig.json",
"project": "./tsconfig.base.json",
"sourceType": "module"
},
"settings": {
"import/parsers": {
"@typescript-eslint/parser": [".ts", ".tsx"]
},
"import/resolver": {
"node": true,
"typescript": {
"project": "packages/*/tsconfig.json"
}
},
"react": {
"version": "detect"
}
},
"rules": {
"react/jsx-key": ["error", { "checkFragmentShorthand": true }],
"@typescript-eslint/ban-types": "off",
Expand All @@ -32,21 +47,8 @@
],
"no-shadow": "error",
"import/no-cycle": "error",
"import/no-unresolved": ["error", { "ignore": ["react-query"] }],
"import/no-unresolved": ["error", { "ignore": ["^@tanstack\/"] }],
"import/no-unused-modules": ["off", { "unusedExports": true }],
"import/no-restricted-paths": [
"error",
{
"zones": [
{ "target": "src/core", "from": "src/broadcastQueryClient-experimental" },
{ "target": "src/core", "from": "src/createAsyncStoragePersister" },
{ "target": "src/core", "from": "src/createWebStoragePersister" },
{ "target": "src/core", "from": "src/devtools" },
{ "target": "src/core", "from": "src/persistQueryClient" },
{ "target": "src/core", "from": "src/reactjs" }
]
}
],
"no-redeclare": "off"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@ name: react-query tests
on:
push:
branches:
- 'master'
- 'next'
- 'alpha'
- 'beta'
- '1.x'
- '2.x'
pull_request:

- '3.x'
jobs:
test:
name: 'Node ${{ matrix.node }}, React ${{ matrix.react }}'
Expand Down Expand Up @@ -40,7 +35,7 @@ jobs:
name: 'Publish Module to NPM'
needs: test
# publish only when merged in master on original repo, not on PR
if: github.repository == 'tannerlinsley/react-query' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/next' || github.ref == 'refs/heads/alpha' || github.ref == 'refs/heads/beta' || github.ref == 'refs/heads/1.x' || github.ref == 'refs/heads/2.x')
if: github.repository == 'tannerlinsley/react-query' && (github.ref == 'refs/heads/1.x' || github.ref == 'refs/heads/2.x' || github.ref == 'refs/heads/3.x')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: ci
concurrency:
group: publish-${{ github.github.base_ref }}
cancel-in-progress: true
on: [push]
jobs:
test-and-publish:
if: github.event_name != 'pull_request'
name: 'Test & Publish'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: '0'
- uses: actions/setup-node@v2
with:
node-version: 16
registry-url: https://registry.npmjs.org/
cache: 'npm'
- run: |
npm i
git config --global user.name 'Tanner Linsley'
git config --global user.email '[email protected]'
npm run cipublish
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GH_TOKEN: ${{ secrets.GH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
26 changes: 26 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: pr
on: [pull_request]
jobs:
test:
name: 'Node ${{ matrix.node }}, React ${{ matrix.react }}'
runs-on: ubuntu-latest
strategy:
matrix:
node: [14, 16]
react: [17, 18]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- name: Install dependencies
uses: bahmutov/npm-install@v1
- run: npm run test:ci
env:
REACTJS_VERSION: ${{ matrix.react }}
- run: npm run test:size
if: matrix.node == '16' && matrix.react == '18'
env:
BUNDLEWATCH_GITHUB_TOKEN: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
11 changes: 9 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ node_modules
# builds
types
build
*/build
dist
lib
es
Expand All @@ -30,7 +31,13 @@ yarn-error.log*
.history
size-plugin.json
stats-hydration.json
stats-react.json
stats.json
stats.html
.vscode/settings.json
.idea/

*.log
.DS_Store
node_modules
.cache
dist
.idea
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v16
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"semi": false,
"singleQuote": true,
"trailingComma": "all"
}
112 changes: 0 additions & 112 deletions CONTRIBUTING.md

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 Tanner Linsley
Copyright (c) 2021 Tanner Linsley

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Enjoy this library? Try the entire [TanStack](https://tanstack.com)! [React Tabl

Still on **React Query v2**? No problem! Check out the v2 docs here: https://react-query-v2.tanstack.com/. <br />
Would you like to try **React Query v4beta**? Check out the v4 beta docs here: https://react-query-beta.tanstack.com/.

## Quick Features

- Transport/protocol/backend agnostic data fetching (REST, GraphQL, promises, whatever!)
Expand Down Expand Up @@ -94,4 +95,4 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

<!-- Force 4 -->
<!-- Use the force, Luke -->
File renamed without changes.
1 change: 0 additions & 1 deletion broadcastQueryClient-experimental/index.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion broadcastQueryClient-experimental/index.js

This file was deleted.

6 changes: 0 additions & 6 deletions broadcastQueryClient-experimental/package.json

This file was deleted.

1 change: 0 additions & 1 deletion core/index.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion core/index.js

This file was deleted.

1 change: 0 additions & 1 deletion createAsyncStoragePersister/index.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion createAsyncStoragePersister/index.js

This file was deleted.

1 change: 0 additions & 1 deletion createWebStoragePersister/index.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion createWebStoragePersister/index.js

This file was deleted.

1 change: 0 additions & 1 deletion devtools/development/index.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion devtools/development/index.js

This file was deleted.

1 change: 0 additions & 1 deletion devtools/index.d.ts

This file was deleted.

5 changes: 0 additions & 5 deletions devtools/index.js

This file was deleted.

2 changes: 1 addition & 1 deletion docs/adapters/react-query.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The `react-query` package offers a 1st-class API for using TanStack Query via Re
## Example

```tsx
import { QueryClient, useQuery } from 'react-query'
import { QueryClient, useQuery } from '@tanstack/react-query'

const queryClient = new QueryClient()

Expand Down
16 changes: 11 additions & 5 deletions docs/devtools.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@ When you begin your React Query journey, you'll want these devtools by your side

> Please note that for now, the devtools **do not support React Native**. If you would like to help us make the devtools platform agnostic, please let us know!
## Import the Devtools
## Install and Import the Devtools

The devtools are bundle split into the `react-query/devtools` package. No need to install anything extra, just:
The devtools are a separate package that you need to install:

```bash
$ npm i @tanstack/react-query-devtools
```

You can import the devtools like this:

```js
import { ReactQueryDevtools } from 'react-query/devtools'
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
```

By default, React Query Devtools are only included in bundles when `process.env.NODE_ENV === 'development'`, so you don't need to worry about excluding them during a production build.
Expand All @@ -26,7 +32,7 @@ Floating Mode will mount the devtools as a fixed, floating element in your app a
Place the following code as high in your React app as you can. The closer it is to the root of the page, the better it will work!

```js
import { ReactQueryDevtools } from 'react-query/devtools'
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'

function App() {
return (
Expand Down Expand Up @@ -59,7 +65,7 @@ function App() {
Embedded Mode will embed the devtools as a regular component in your application. You can style it however you'd like after that!

```js
import { ReactQueryDevtoolsPanel } from 'react-query/devtools'
import { ReactQueryDevtoolsPanel } from '@tanstack/react-query-devtools'

function App() {
return (
Expand Down
Loading

0 comments on commit c5c4417

Please sign in to comment.