diff --git a/.changeset/v6-browser-targets.md b/.changeset/v6-browser-targets.md new file mode 100644 index 00000000000..fd35c38065d --- /dev/null +++ b/.changeset/v6-browser-targets.md @@ -0,0 +1,22 @@ +--- +'@tanstack/lit-query': major +'@tanstack/preact-query': major +'@tanstack/preact-query-devtools': major +'@tanstack/preact-query-persist-client': major +'@tanstack/query-async-storage-persister': major +'@tanstack/query-broadcast-client-experimental': major +'@tanstack/query-core': major +'@tanstack/query-devtools': major +'@tanstack/query-persist-client-core': major +'@tanstack/react-query': major +'@tanstack/react-query-devtools': major +'@tanstack/react-query-next-experimental': major +'@tanstack/react-query-persist-client': major +'@tanstack/solid-query': major +'@tanstack/solid-query-devtools': major +'@tanstack/solid-query-persist-client': major +'@tanstack/vue-query': major +'@tanstack/vue-query-devtools': major +--- + +Update the minimum browser versions to Chrome 119, Edge 119, Firefox 121, Safari 17.4, Safari on iOS 17.4, and Opera 105. If you support older browsers, transpile the library and add any polyfills your environment needs. diff --git a/docs/framework/lit/installation.md b/docs/framework/lit/installation.md index 6ee6f647d6c..23a32fe71d4 100644 --- a/docs/framework/lit/installation.md +++ b/docs/framework/lit/installation.md @@ -43,17 +43,19 @@ The snippets in these docs declare reactive properties with `static properties` } ``` -TanStack Query is optimized for modern browsers: +TanStack Query supports these browser versions and later. ```txt -Chrome >= 91 -Firefox >= 90 -Edge >= 91 -Safari >= 15 -iOS >= 15 -Opera >= 77 +Chrome 119 +Firefox 121 +Edge 119 +Safari 17.4 +Safari on iOS 17.4 +Opera 105 ``` +> 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. + ## Provider Setup Create a `QueryClient`, provide it with `QueryClientProvider`, and register your custom element. The package exports the provider class but does not call `customElements.define` for you. diff --git a/docs/framework/react/installation.md b/docs/framework/react/installation.md index fb08dc0e81b..842676aa63f 100644 --- a/docs/framework/react/installation.md +++ b/docs/framework/react/installation.md @@ -67,15 +67,15 @@ If you're not using a module bundler or package manager, you can also use this l TanStack Query v6 ships ESM builds only. If your application uses webpack 4, upgrade to webpack 5 or another bundler that supports the modern build. -React Query is optimized for modern browsers. It is compatible with the following browsers config - -``` -Chrome >= 91 -Firefox >= 90 -Edge >= 91 -Safari >= 15 -iOS >= 15 -Opera >= 77 +TanStack Query supports these browser versions and later. + +```txt +Chrome 119 +Firefox 121 +Edge 119 +Safari 17.4 +Safari on iOS 17.4 +Opera 105 ``` > 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. diff --git a/docs/framework/solid/installation.md b/docs/framework/solid/installation.md index 22ad04f1218..8248d304339 100644 --- a/docs/framework/solid/installation.md +++ b/docs/framework/solid/installation.md @@ -47,15 +47,15 @@ If you're not using a module bundler or package manager, you can also use this l ### Requirements -Solid Query is optimized for modern browsers. It is compatible with the following browsers config - -``` -Chrome >= 91 -Firefox >= 90 -Edge >= 91 -Safari >= 15 -iOS >= 15 -Opera >= 77 +TanStack Query supports these browser versions and later. + +```txt +Chrome 119 +Firefox 121 +Edge 119 +Safari 17.4 +Safari on iOS 17.4 +Opera 105 ``` > 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. diff --git a/packages/eslint-plugin-query/tsdown.config.ts b/packages/eslint-plugin-query/tsdown.config.ts index 56a03002e92..7d34ad63a88 100644 --- a/packages/eslint-plugin-query/tsdown.config.ts +++ b/packages/eslint-plugin-query/tsdown.config.ts @@ -3,5 +3,6 @@ import { getTsdownConfig } from './root.tsdown.config.js' export default defineConfig({ ...getTsdownConfig({ entry: ['src/*.ts'] }), + target: 'es2022', deps: { neverBundle: ['typescript'] }, }) diff --git a/packages/lit-query/tsconfig.json b/packages/lit-query/tsconfig.json index 32963ebc7e8..8e6387ffcf9 100644 --- a/packages/lit-query/tsconfig.json +++ b/packages/lit-query/tsconfig.json @@ -3,7 +3,7 @@ "compilerOptions": { "outDir": "./dist-ts", "rootDir": ".", - "lib": ["ES2022", "DOM"] + "lib": ["ES2022", "ES2024.Promise", "DOM"] }, "include": [ "src", diff --git a/packages/query-core/src/infiniteQueryBehavior.ts b/packages/query-core/src/infiniteQueryBehavior.ts index 4d386612e2d..c7b679ffef4 100644 --- a/packages/query-core/src/infiniteQueryBehavior.ts +++ b/packages/query-core/src/infiniteQueryBehavior.ts @@ -133,12 +133,11 @@ function getNextPageParam( options: InfiniteQueryPageParamsOptions, { pages, pageParams }: InfiniteData, ): unknown | undefined { - const lastIndex = pages.length - 1 return pages.length > 0 ? options.getNextPageParam( - pages[lastIndex], + pages.at(-1), pages, - pageParams[lastIndex], + pageParams.at(-1), pageParams, ) : undefined diff --git a/packages/query-core/src/retryer.ts b/packages/query-core/src/retryer.ts index bb46eb2cb6b..3e7ad7bb771 100644 --- a/packages/query-core/src/retryer.ts +++ b/packages/query-core/src/retryer.ts @@ -146,13 +146,11 @@ export function createRetryer( let failureCount = 0 let continueFn: ((value?: unknown) => void) | undefined let status: RetryerStatus = 'pending' - let promiseResolve: (data: TData) => void - let promiseReject: (error: TError) => void - - const promise = new Promise((resolve, reject) => { - promiseResolve = resolve - promiseReject = reject - }) + const { + promise, + resolve: promiseResolve, + reject: promiseReject, + } = Promise.withResolvers() promise.catch(noop) const isResolved = () => status !== 'pending' diff --git a/packages/query-core/src/utils.ts b/packages/query-core/src/utils.ts index 2176a5ef99d..9ce1c01b635 100644 --- a/packages/query-core/src/utils.ts +++ b/packages/query-core/src/utils.ts @@ -403,8 +403,6 @@ export function partialMatchKey( return false } -const hasOwn = Object.prototype.hasOwnProperty - /** * This function returns `a` if `b` is deeply equal. * If not, it will replace any deeply equal children of `b` with those of `a`. @@ -468,7 +466,7 @@ function replaceEqualDeepInternal( if (equalityFn(aItem, bItem)) { copy[key] = aItem - if (array ? i < aSize : hasOwn.call(a, key)) equalItems++ + if (array ? i < aSize : Object.hasOwn(a, key)) equalItems++ continue } @@ -505,7 +503,7 @@ export function shallowEqualObjects>( } for (const key of Object.keys(a)) { - if (!hasOwn.call(b, key) || a[key] !== b[key]) { + if (!Object.hasOwn(b, key) || a[key] !== b[key]) { return false } } diff --git a/packages/query-devtools/root.tsdown.config.js b/packages/query-devtools/root.tsdown.config.js new file mode 120000 index 00000000000..a997d5d337c --- /dev/null +++ b/packages/query-devtools/root.tsdown.config.js @@ -0,0 +1 @@ +../../scripts/getTsdownConfig.js \ No newline at end of file diff --git a/packages/query-devtools/tsdown.config.ts b/packages/query-devtools/tsdown.config.ts index 12ed0fcc471..1ec7cf8764f 100644 --- a/packages/query-devtools/tsdown.config.ts +++ b/packages/query-devtools/tsdown.config.ts @@ -3,6 +3,7 @@ import { createRequire } from 'node:module' import { dirname, resolve } from 'node:path' import { defineConfig } from 'tsdown' import solid from 'unplugin-solid/rolldown' +import { browserTargets } from './root.tsdown.config.js' import type { UserConfig } from 'tsdown' const require = createRequire(import.meta.url) @@ -52,7 +53,7 @@ const inlineCss = () => ({ }) const baseConfig: UserConfig = { - target: 'esnext', + target: browserTargets, platform: 'neutral', alias: { 'solid-transition-group': 'solid-transition-group/dist/index.js', diff --git a/packages/solid-query-devtools/root.tsdown.config.js b/packages/solid-query-devtools/root.tsdown.config.js new file mode 120000 index 00000000000..a997d5d337c --- /dev/null +++ b/packages/solid-query-devtools/root.tsdown.config.js @@ -0,0 +1 @@ +../../scripts/getTsdownConfig.js \ No newline at end of file diff --git a/packages/solid-query-devtools/tsdown.config.ts b/packages/solid-query-devtools/tsdown.config.ts index 4d79fae4a29..6f5092d002d 100644 --- a/packages/solid-query-devtools/tsdown.config.ts +++ b/packages/solid-query-devtools/tsdown.config.ts @@ -1,9 +1,10 @@ import { defineConfig } from 'tsdown' import solid from 'unplugin-solid/rolldown' +import { browserTargets } from './root.tsdown.config.js' import type { UserConfig } from 'tsdown' const baseConfig: UserConfig = { - target: 'esnext', + target: browserTargets, platform: 'browser', format: 'esm', outDir: 'build', diff --git a/packages/solid-query-persist-client/root.tsdown.config.js b/packages/solid-query-persist-client/root.tsdown.config.js new file mode 120000 index 00000000000..a997d5d337c --- /dev/null +++ b/packages/solid-query-persist-client/root.tsdown.config.js @@ -0,0 +1 @@ +../../scripts/getTsdownConfig.js \ No newline at end of file diff --git a/packages/solid-query-persist-client/tsdown.config.ts b/packages/solid-query-persist-client/tsdown.config.ts index 79d787db146..8aa7907d5ad 100644 --- a/packages/solid-query-persist-client/tsdown.config.ts +++ b/packages/solid-query-persist-client/tsdown.config.ts @@ -1,9 +1,10 @@ import { defineConfig } from 'tsdown' import solid from 'unplugin-solid/rolldown' +import { browserTargets } from './root.tsdown.config.js' import type { UserConfig } from 'tsdown' const baseConfig: UserConfig = { - target: 'esnext', + target: browserTargets, platform: 'browser', format: 'esm', outDir: 'build', diff --git a/packages/solid-query/root.tsdown.config.js b/packages/solid-query/root.tsdown.config.js new file mode 120000 index 00000000000..a997d5d337c --- /dev/null +++ b/packages/solid-query/root.tsdown.config.js @@ -0,0 +1 @@ +../../scripts/getTsdownConfig.js \ No newline at end of file diff --git a/packages/solid-query/tsdown.config.ts b/packages/solid-query/tsdown.config.ts index 79d787db146..8aa7907d5ad 100644 --- a/packages/solid-query/tsdown.config.ts +++ b/packages/solid-query/tsdown.config.ts @@ -1,9 +1,10 @@ import { defineConfig } from 'tsdown' import solid from 'unplugin-solid/rolldown' +import { browserTargets } from './root.tsdown.config.js' import type { UserConfig } from 'tsdown' const baseConfig: UserConfig = { - target: 'esnext', + target: browserTargets, platform: 'browser', format: 'esm', outDir: 'build', diff --git a/packages/vue-query-devtools/tsdown.config.ts b/packages/vue-query-devtools/tsdown.config.ts index 3d1d9c0f707..1a7ecbedafe 100644 --- a/packages/vue-query-devtools/tsdown.config.ts +++ b/packages/vue-query-devtools/tsdown.config.ts @@ -1,14 +1,12 @@ import { defineConfig } from 'tsdown' import vue from 'unplugin-vue/vite' +import { browserTargets } from './root.tsdown.config.js' export default defineConfig({ plugins: [vue()], entry: ['src/**/*.ts', '!src/__tests__/**'], format: ['esm'], - target: ['chrome91', 'firefox90', 'edge91', 'safari15', 'ios15', 'opera77'], - // Rolldown lowers private fields for browser target arrays. Keep the - // transform target at ES2022 to match the syntax that tsup emitted. - inputOptions: { transform: { target: 'es2022' } }, + target: browserTargets, outDir: 'dist', unbundle: true, dts: true, diff --git a/scripts/getTsdownConfig.js b/scripts/getTsdownConfig.js index 28e45b08c6c..bc7a1ced00c 100644 --- a/scripts/getTsdownConfig.js +++ b/scripts/getTsdownConfig.js @@ -1,5 +1,15 @@ // @ts-check +// Query Core uses Promise.withResolvers(). +export const browserTargets = [ + 'chrome119', + 'firefox121', + 'edge119', + 'safari17.4', + 'ios17.4', + 'opera105', +] + /** * @param {Object} opts - Options for building configurations. * @param {string[]} opts.entry - The entry array. @@ -9,10 +19,7 @@ export function getTsdownConfig(opts) { return { entry: opts.entry, format: 'esm', - target: ['chrome91', 'firefox90', 'edge91', 'safari15', 'ios15', 'opera77'], - // Rolldown lowers private fields for browser target arrays. Keep the - // transform target at ES2022 to match the syntax that tsup emitted. - inputOptions: { transform: { target: 'es2022' } }, + target: browserTargets, outDir: 'build', dts: true, fixedExtension: false, diff --git a/tsconfig.json b/tsconfig.json index 0f8c35387f7..525270b22ec 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,7 +16,7 @@ "forceConsistentCasingInFileNames": true, "incremental": true, "isolatedModules": true, - "lib": ["DOM", "DOM.Iterable", "ES2022"], + "lib": ["DOM", "DOM.Iterable", "ES2022", "ES2024.Promise"], "module": "ESNext", "moduleResolution": "Bundler", "noEmit": false,