Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESM support #4092

Merged
merged 38 commits into from
Sep 10, 2022
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
2af9174
fix: restore missing `exports` declarations (#3892)
DamianOsipiuk Jul 28, 2022
9172eab
fix: subpackage dependencies (#4013)
DamianOsipiuk Aug 10, 2022
dc8aec7
fix: umd-build (#3924)
JohnDaly Aug 10, 2022
a3cdf51
Merge remote-tracking branch 'tannerlinsley/main' into beta
TkDodo Aug 10, 2022
4a4543c
release: v4.0.11-beta.0
tannerlinsley Aug 10, 2022
8025dbf
Merge remote-tracking branch 'tannerlinsley/main' into beta
TkDodo Aug 17, 2022
a047974
release: v4.0.11-beta.1
tannerlinsley Aug 17, 2022
d4cd620
fix(react-query-devtools): cjs devtools fallback (#4048)
DamianOsipiuk Aug 18, 2022
36aa41e
release: v4.0.11-beta.2
tannerlinsley Aug 18, 2022
58e3ae3
fix: remove browser entry, fix umd size (#4044)
DamianOsipiuk Aug 18, 2022
103e169
chore: remove 'browser' field from package validation
TkDodo Aug 18, 2022
eba6c93
release: v4.0.11-beta.3
tannerlinsley Aug 18, 2022
086a9e4
release: v4.0.11-beta.4
tannerlinsley Aug 18, 2022
64656c3
chore: react-query should be a peerDependency of the devtools
TkDodo Aug 18, 2022
704b1a7
Merge remote-tracking branch 'tannerlinsley/main' into beta
TkDodo Aug 18, 2022
ad0a378
release: v4.0.11-beta.5
tannerlinsley Aug 18, 2022
e9f7944
Merge remote-tracking branch 'tannerlinsley/main' into beta
TkDodo Aug 19, 2022
53964b6
release: v4.3.0-beta.0
tannerlinsley Aug 19, 2022
e8d6d11
fix: webpack 4 fallback to cjs (#4069)
DamianOsipiuk Aug 23, 2022
7753fd3
fix: publish script shouldn't check against module anymore
TkDodo Aug 23, 2022
272a37e
fix: publish script
TkDodo Aug 23, 2022
39fa4a4
release: v4.3.0-beta.2
tannerlinsley Aug 23, 2022
2452ec1
release: v4.3.0-beta.3
tannerlinsley Aug 23, 2022
b40b7c3
fix: umd build size, force prod devtools (#4074)
DamianOsipiuk Aug 24, 2022
6753551
release: v4.3.0-beta.4
tannerlinsley Aug 24, 2022
f6fd7d6
Merge remote-tracking branch 'tannerlinsley/main' into beta
TkDodo Aug 26, 2022
b648136
Merge remote-tracking branch 'tannerlinsley/main' into beta
TkDodo Aug 26, 2022
6725aaf
release: v4.3.0-beta.5
tannerlinsley Aug 26, 2022
897a397
fix: reintroduce production export (#4090)
DamianOsipiuk Aug 28, 2022
0b979fa
release: v4.3.0-beta.6
tannerlinsley Aug 28, 2022
aab8e1e
Merge remote-tracking branch 'tannerlinsley/main' into beta
TkDodo Aug 28, 2022
3e3a04e
fix(react-query-devtools): always useEffect for the mounted check
TkDodo Aug 28, 2022
1118fac
release: v4.3.0-beta.7
tannerlinsley Aug 28, 2022
294337a
docs: document devtools in production
TkDodo Aug 28, 2022
5e145fc
docs: document devtools in production
TkDodo Aug 28, 2022
40c3491
docs: document devtools in production
TkDodo Aug 28, 2022
0bb7605
fix: support react-native (#4125)
DamianOsipiuk Sep 10, 2022
712475b
Merge remote-tracking branch 'tannerlinsley/main' into beta
TkDodo Sep 10, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions docs/devtools.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,61 @@ Use these options to style the dev tools.
- The standard React style object used to style a component with inline styles
- `className: string`
- The standard React className property used to style a component with classes

## Devtools in production

Devtools are excluded in production builds. However, it might be desirable to lazy load the devtools in production:

```tsx
import * as React from 'react'
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
import { Example } from './Example'

const queryClient = new QueryClient()

const ReactQueryDevtoolsProduction = React.lazy(() =>
import('@tanstack/react-query-devtools/build/lib/index.prod.js').then(d => ({
default: d.ReactQueryDevtools
}))
)

function App() {
const [showDevtools, setShowDevtools] = React.useState(false)

React.useEffect(() => {
// @ts-ignore
window.toggleDevtools = () => setShowDevtools(old => !old)
}, [])

return (
<QueryClientProvider client={queryClient}>
<Example />
<ReactQueryDevtools initialIsOpen />
{ showDevtools && (
<React.Suspense fallback={null}>
<ReactQueryDevtoolsProduction />
</React.Suspense>
)}
</QueryClientProvider>
);
}

export default App
```

With this, calling `window.toggleDevtools()` will download the devtools bundle and show them.

### Modern bundlers

If your bundler supports package exports, you can use the following import path:

```tsx
const ReactQueryDevtoolsProduction = React.lazy(() =>
import('@tanstack/react-query-devtools/production').then(d => ({
default: d.ReactQueryDevtools
}))
)
```

For TypeScript, you would need to set `moduleResolution: 'nodenext'` in your tsconfig, which requires at least TypeScript v4.7.
4 changes: 2 additions & 2 deletions examples/react/auto-refetching/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"next": "12.2.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"@tanstack/react-query": "4.2.3",
"@tanstack/react-query-devtools": "4.2.3"
"@tanstack/react-query": "4.3.0-beta.4",
"@tanstack/react-query-devtools": "4.3.0-beta.7"
},
"scripts": {
"dev": "next",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/basic-graphql-request/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"graphql-request": "^3.1.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"@tanstack/react-query": "4.2.3",
"@tanstack/react-query-devtools": "4.2.3"
"@tanstack/react-query": "4.3.0-beta.4",
"@tanstack/react-query-devtools": "4.3.0-beta.7"
},
"devDependencies": {
"@vitejs/plugin-react": "^2.0.0",
Expand Down
8 changes: 4 additions & 4 deletions examples/react/basic-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
"broadcast-channel": "^3.4.1",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"@tanstack/react-query": "4.2.3",
"@tanstack/react-query-devtools": "4.2.3",
"@tanstack/react-query-persist-client": "4.2.1",
"@tanstack/query-sync-storage-persister": "4.2.3",
"@tanstack/react-query": "4.3.0-beta.4",
"@tanstack/react-query-devtools": "4.3.0-beta.7",
"@tanstack/react-query-persist-client": "4.3.0-beta.4",
"@tanstack/query-sync-storage-persister": "4.3.0-beta.4",
"react-scripts": "3.0.1",
"stop-runaway-react-effects": "^1.2.0",
"styled-components": "^4.3.2",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"axios": "^0.21.1",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"@tanstack/react-query": "4.2.3",
"@tanstack/react-query-devtools": "4.2.3"
"@tanstack/react-query": "4.3.0-beta.4",
"@tanstack/react-query-devtools": "4.3.0-beta.7"
},
"devDependencies": {
"@vitejs/plugin-react": "^2.0.0",
Expand Down
40 changes: 40 additions & 0 deletions examples/react/custom-hooks/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"name": "@tanstack/query-example-react-custom-hooks",
"private": true,
"version": "0.0.1",
"scripts": {
"start": "rescripts start",
"build": "rescripts build",
"test": "rescripts test",
"eject": "rescripts eject"
},
"dependencies": {
"axios": "^0.26.1",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"@tanstack/react-query": "4.3.0-beta.4",
"@tanstack/react-query-devtools": "4.3.0-beta.7",
"react-scripts": "3.0.1",
"stop-runaway-react-effects": "^1.2.0",
"styled-components": "^4.3.2"
},
"devDependencies": {
"@rescripts/cli": "^0.0.11",
"@rescripts/rescript-use-babel-config": "^0.0.8",
"@rescripts/rescript-use-eslint-config": "^0.0.9",
"babel-eslint": "10.0.1",
"eslint-config-prettier": "^6.12.0"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
4 changes: 2 additions & 2 deletions examples/react/default-query-function/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"axios": "^0.26.1",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"@tanstack/react-query": "4.2.3",
"@tanstack/react-query-devtools": "4.2.3"
"@tanstack/react-query": "4.3.0-beta.4",
"@tanstack/react-query-devtools": "4.3.0-beta.7"
},
"devDependencies": {
"@vitejs/plugin-react": "^2.0.0",
Expand Down
21 changes: 21 additions & 0 deletions examples/react/focus-refetching/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "@tanstack/query-example-react-focus-revalidate",
"private": true,
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"axios": "^0.21.1",
"isomorphic-unfetch": "3.0.0",
"next": "12.2.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"@tanstack/react-query": "4.3.0-beta.4",
"@tanstack/react-query-devtools": "4.3.0-beta.7"
},
"scripts": {
"dev": "next",
"start": "next start",
"build": "next build"
}
}
4 changes: 2 additions & 2 deletions examples/react/load-more-infinite-scroll/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-intersection-observer": "^8.33.1",
"@tanstack/react-query": "4.2.3",
"@tanstack/react-query-devtools": "4.2.3"
"@tanstack/react-query": "4.3.0-beta.4",
"@tanstack/react-query-devtools": "4.3.0-beta.7"
},
"scripts": {
"dev": "next",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"next": "12.2.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"@tanstack/react-query": "4.2.3",
"@tanstack/react-query-devtools": "4.2.3",
"@tanstack/react-query": "4.3.0-beta.4",
"@tanstack/react-query-devtools": "4.3.0-beta.7",
"resolve-from": "^5.0.0",
"web-streams-polyfill": "^3.0.3"
},
Expand Down
8 changes: 4 additions & 4 deletions examples/react/offline/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-hot-toast": "^2.2.0",
"@tanstack/react-query": "4.2.3",
"@tanstack/react-query-devtools": "4.2.3",
"@tanstack/react-query-persist-client": "4.2.1",
"@tanstack/query-sync-storage-persister": "4.2.3"
"@tanstack/react-query": "4.3.0-beta.4",
"@tanstack/react-query-devtools": "4.3.0-beta.7",
"@tanstack/react-query-persist-client": "4.3.0-beta.4",
"@tanstack/query-sync-storage-persister": "4.3.0-beta.4"
},
"devDependencies": {
"@vitejs/plugin-react": "^2.0.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/optimistic-updates-typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"next": "12.2.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"@tanstack/react-query": "4.2.3",
"@tanstack/react-query-devtools": "4.2.3",
"@tanstack/react-query": "4.3.0-beta.4",
"@tanstack/react-query-devtools": "4.3.0-beta.7",
"typescript": "^4.1.2"
},
"scripts": {
Expand Down
21 changes: 21 additions & 0 deletions examples/react/optimistic-updates/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "@tanstack/query-example-react-optimistic-updates",
"private": true,
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"axios": "^0.21.1",
"isomorphic-unfetch": "3.0.0",
"next": "12.2.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"@tanstack/react-query": "4.3.0-beta.4",
"@tanstack/react-query-devtools": "4.3.0-beta.7"
},
"scripts": {
"dev": "next",
"start": "next start",
"build": "next build"
}
}
4 changes: 2 additions & 2 deletions examples/react/pagination/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"next": "12.2.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"@tanstack/react-query": "4.2.3",
"@tanstack/react-query-devtools": "4.2.3"
"@tanstack/react-query": "4.3.0-beta.4",
"@tanstack/react-query-devtools": "4.3.0-beta.7"
},
"scripts": {
"dev": "next",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"dependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0",
"@tanstack/react-query": "4.2.3",
"@tanstack/react-query-devtools": "4.2.3"
"@tanstack/react-query": "4.3.0-beta.4",
"@tanstack/react-query-devtools": "4.3.0-beta.7"
},
"devDependencies": {
"@vitejs/plugin-react": "^2.0.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/prefetching/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"next": "12.2.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"@tanstack/react-query": "4.2.3",
"@tanstack/react-query-devtools": "4.2.3"
"@tanstack/react-query": "4.3.0-beta.4",
"@tanstack/react-query-devtools": "4.3.0-beta.7"
},
"scripts": {
"dev": "next",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/react-native/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"react-dom": "17.0.1",
"react-native": "0.64.3",
"react-native-web": "0.17.1",
"@tanstack/react-query": "4.2.3",
"@tanstack/react-query-devtools": "4.2.3",
"@tanstack/react-query": "4.3.0-beta.4",
"@tanstack/react-query-devtools": "4.3.0-beta.7",
"expo-constants": "~12.1.3",
"react-native-paper": "4.9.2",
"react-native-screens": "~3.8.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/rick-morty/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"@material-ui/core": "^4.9.7",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"@tanstack/react-query": "4.2.3",
"@tanstack/react-query-devtools": "4.2.3",
"@tanstack/react-query": "4.3.0-beta.4",
"@tanstack/react-query-devtools": "4.3.0-beta.7",
"react-router": "^5.1.2",
"react-router-dom": "^5.1.2"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/react/simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"axios": "^0.26.1",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"@tanstack/react-query": "4.2.3",
"@tanstack/react-query-devtools": "4.2.3"
"@tanstack/react-query": "4.3.0-beta.4",
"@tanstack/react-query-devtools": "4.3.0-beta.7"
},
"devDependencies": {
"@vitejs/plugin-react": "^2.0.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/react/star-wars/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"@material-ui/core": "^4.9.7",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"@tanstack/react-query": "4.2.3",
"@tanstack/react-query-devtools": "4.2.3",
"@tanstack/react-query": "4.3.0-beta.4",
"@tanstack/react-query-devtools": "4.3.0-beta.7",
"react-router": "^5.1.2",
"react-router-dom": "^5.1.2"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/react/suspense/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-error-boundary": "^2.2.3",
"@tanstack/react-query": "4.2.3",
"@tanstack/react-query-devtools": "4.2.3"
"@tanstack/react-query": "4.3.0-beta.4",
"@tanstack/react-query-devtools": "4.3.0-beta.7"
},
"devDependencies": {
"@vitejs/plugin-react": "^2.0.0",
Expand Down
Loading