Skip to content

Commit ead3d69

Browse files
authored
chore(bundling): bundle for modern browsers (#3342)
* chore(bundling): update babel dependencies * chore(bundling): remove babel-plugin-transform-async-to-promises we don't use async functions, and we also want to target envs that support async functions * chore(bundling): update supported browsers for a more modern output * chore(bundling): tweak browserslist and exclude transform-parameters plugin, which comes in because of any safari version, even though it should not be needed according to caniuse. This plugin transforms ES2015 parameters to ES5, this includes: Destructuring parameters, Default parameters and Rest parameters, all of which are supported by Safari * chore(bundling): update terser * chore(bundling): fix tests ReferenceError: Cannot access 'promiseResolve' before initialization * chore(bundling): docs about supported browsers * chore(bundling): small docs fixes
1 parent 61fd539 commit ead3d69

File tree

7 files changed

+840
-1056
lines changed

7 files changed

+840
-1056
lines changed

.babelrc.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,20 @@ const loose = true
55
module.exports = {
66
presets: [
77
[
8-
'@babel/env',
8+
'@babel/preset-env',
99
{
1010
loose,
1111
modules: false,
12-
exclude: ['@babel/plugin-transform-regenerator'],
12+
exclude: [
13+
'@babel/plugin-transform-regenerator',
14+
'@babel/plugin-transform-parameters',
15+
],
1316
},
1417
],
1518
'@babel/preset-typescript',
1619
'@babel/react',
1720
],
1821
plugins: [
19-
'babel-plugin-transform-async-to-promises',
2022
cjs && ['@babel/transform-modules-commonjs', { loose }],
2123
[
2224
'@babel/transform-runtime',

.browserslistrc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Browsers we support
2-
> 0.5%
32
Chrome >= 73
4-
ChromeAndroid >= 75
5-
Firefox >= 67
6-
Edge >= 17
7-
Safari >= 12.1
8-
iOS >= 11.3
3+
Firefox >= 78
4+
Edge >= 79
5+
Safari >= 12.0
6+
iOS >= 12.0
7+
opera >= 53

docs/src/pages/guides/migrating-to-react-query-4.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,10 @@ useQuery(
293293

294294
This is now disallowed on type level; at runtime, `undefined` will be transformed to a _failed Promise_, which means you will get an `error`, which will also be logged to the console in development mode.
295295

296+
### Supported Browsers
297+
298+
As of v4, React Query is optimized for modern browsers. We have updated our browserslist to produce a more modern, performant and smaller bundle. You can read about the requirements [here](../installation#requirements).
299+
296300
## New Features 🚀
297301

298302
### Proper offline support

docs/src/pages/installation.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,18 @@ If you're not using a module bundler or package manager we also have a global ("
3030
Once you've added this you will have access to the `window.ReactQuery` object and its exports.
3131

3232
> This installation/usage requires the [React CDN script bundles](https://reactjs.org/docs/cdn-links.html) to be on the page as well.
33+
34+
### Requirements
35+
36+
React Query is optimized for modern browsers. It is compatible with the following browsers config
37+
38+
```
39+
Chrome >= 73
40+
Firefox >= 78
41+
Edge >= 79
42+
Safari >= 12.0
43+
iOS >= 12.0
44+
opera >= 53
45+
```
46+
47+
> Depending on your environment, you might need to add polyfills. If you want to support older browsers, you need to transpile the library from `node_modules` yourselves.

package.json

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@
8484
}
8585
},
8686
"devDependencies": {
87-
"@babel/cli": "^7.11.6",
88-
"@babel/core": "^7.11.6",
89-
"@babel/plugin-transform-runtime": "^7.11.5",
90-
"@babel/preset-env": "^7.11.5",
91-
"@babel/preset-react": "^7.10.4",
92-
"@babel/preset-typescript": "^7.10.4",
87+
"@babel/cli": "^7.17.6",
88+
"@babel/core": "^7.17.5",
89+
"@babel/plugin-transform-runtime": "^7.17.0",
90+
"@babel/preset-env": "^7.16.11",
91+
"@babel/preset-react": "^7.16.7",
92+
"@babel/preset-typescript": "^7.16.7",
9393
"@rollup/plugin-replace": "^3.0.0",
9494
"@svgr/rollup": "^6.1.1",
9595
"@testing-library/jest-dom": "^5.14.1",
@@ -102,7 +102,6 @@
102102
"@typescript-eslint/parser": "^5.6.0",
103103
"babel-eslint": "^10.1.0",
104104
"babel-jest": "^26.0.1",
105-
"babel-plugin-transform-async-to-promises": "^0.8.15",
106105
"bundlewatch": "^0.3.2",
107106
"cross-env": "^7.0.2",
108107
"eslint": "7.x",
@@ -128,16 +127,16 @@
128127
"react-error-boundary": "^2.2.2",
129128
"replace": "^1.2.0",
130129
"rimraf": "^3.0.2",
131-
"rollup": "^2.61.1",
130+
"rollup": "^2.68.0",
132131
"rollup-plugin-babel": "^4.4.0",
133132
"rollup-plugin-commonjs": "^10.1.0",
134133
"rollup-plugin-jscc": "^2.0.0",
135134
"rollup-plugin-node-resolve": "^5.2.0",
136135
"rollup-plugin-peer-deps-external": "^2.2.4",
137-
"rollup-plugin-prettier": "^2.2.0",
136+
"rollup-plugin-prettier": "^2.2.2",
138137
"rollup-plugin-size": "^0.2.2",
139138
"rollup-plugin-terser": "^7.0.2",
140-
"rollup-plugin-visualizer": "^5.5.2",
139+
"rollup-plugin-visualizer": "^5.6.0",
141140
"type-fest": "^0.21.0",
142141
"typescript": "4.5.3"
143142
},

src/core/retryer.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,14 @@ export function createRetryer<TData = unknown, TError = unknown>(
6969
let isRetryCancelled = false
7070
let failureCount = 0
7171
let isResolved = false
72+
let continueFn: ((value?: unknown) => void) | undefined
73+
let promiseResolve: (data: TData) => void
74+
let promiseReject: (error: TError) => void
75+
7276
const promise = new Promise<TData>((outerResolve, outerReject) => {
7377
promiseResolve = outerResolve
7478
promiseReject = outerReject
7579
})
76-
let continueFn: ((value?: unknown) => void) | undefined
77-
let promiseResolve: (data: TData) => void
78-
let promiseReject: (error: TError) => void
7980

8081
const cancel = (cancelOptions?: CancelOptions): void => {
8182
if (!isResolved) {

0 commit comments

Comments
 (0)