feat: support TanStack Query v5 - #1
Merged
Merged
Conversation
The detector was already v5-aware: `getPendingQueries()` matches both the
v5 `pending` and the v4 `loading` status, and every core API it uses
(`matchQuery`, `notifyManager.batchCalls`, `QueryCache.subscribe`,
`queryCache.findAll({ predicate })`) is unchanged in v5. Only the
peerDependency range `~4` blocked v5 apps from installing the package.
Widen it to `>=4 <6` and note both supported majors in the README.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add vitest (natural fit with the existing tsup/esbuild stack, no extra transform config) and run the same behavioural suite against both majors via two vitest projects: `query-core-v5` uses the installed v5, and `query-core-v4` aliases `@tanstack/query-core` to a `npm:@tanstack/query-core@^4` dev dependency. The tests drive an actual QueryClient (no mocks of the query cache) and assert on the warning payload: sequential queries, parallel queries, whitelisting, a three-query chain, and the unsubscribe handle. Add a GitHub Actions workflow running typecheck, build and the suite, matrixed over query-core 4 and 5. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A small Expo Go app (react-query v5) consuming the library through `file:..`. It taps `console.warn`, keeps the lines the detector really emits, and renders them, so the detection is visible on a device: one button fires two sequential dependent queries, the other two parallel ones. Run on an iPhone 17 Pro simulator (iOS 26.4): the sequential button adds `["user",1] --> ["posts-of-user",1]` to the list, the parallel button adds nothing. Exclude the example from the root tsconfig, it is its own project. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
package.json:peerDependencies["@tanstack/query-core"]from"~4"to">=4 <6"vitest), run against both majors, plus atestscript.github/workflows/ci.yml: typecheck + build + tests, matrixed over query-core 4 and 5example/: a small Expo app that makes the detection visible on a deviceREADME.md: one sentence stating both supported majorsNo source change was needed.
WaterfallQueryDetector.getPendingQueries()already matches both"pending"(v5) and"loading"(v4). The peer range was the only thing stopping v5 apps from installing the package.Proof
1. Automated tests, both majors
yarn testruns the same suite twice through two vitest projects.query-core-v5uses the installed v5;query-core-v4resolves@tanstack/query-coreto anpm:@tanstack/query-core@^4alias dev dependency, so the library source under test really imports v4.The tests drive an actual
QueryClient(the query cache is not mocked) and assert on the payload the detector hands toconsole.warn, not merely that it did not throw:["first"] --> ["second"]The suite is a real gate, not a smoke test: temporarily reducing the status predicate to
["pending"](dropping v4'sloading) turns 4 of the 7 v4 tests red while v5 stays green.2. CI
.github/workflows/ci.ymlrunsyarn install --immutable,yarn typecheck,yarn buildand the suite, with one job per major. Both jobs are green on this branch.3. On-device E2E with @tanstack/react-query v5
example/is an Expo Go app on@tanstack/react-query@5.103.2, consuming this repo's builtdist/throughfile:..(metro is configured so the library resolves the app'squery-core, not its own). It tapsconsole.warn, keeps the lines the detector actually emits and renders them on screen.Run on an iPhone 17 Pro simulator, iOS 26.4, driven end to end:
Detected waterfalls: 0, "No waterfall detected yet"["user",1], then["posts-of-user",1]once the first resolves): the list shows["user",1] --> ["posts-of-user",1], count 1["profile",2]and["settings",2]at once): count stays 1, nothing addedThe Metro log for the whole session contains exactly one
Detected query waterfallswarning.Still not proven
>=4 <6range.dist/index.mjsemitsimport ... from "lodash/differenceBy"with no extension, which plain Node ESM refuses to resolve (ERR_MODULE_NOT_FOUND). Bundlers (Metro, webpack, vite) resolve it fine and the CJS build is unaffected, so normal usage is not impacted. Worth a separate fix if you want the ESM build to be Node-loadable.Release
No version bump here, the release is left to you.
🤖 Generated with Claude Code