-
Notifications
You must be signed in to change notification settings - Fork 52
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
feat(react-query): support @tanstack/react-query@4,5 at once automatically (pre exit beta) #950
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
CodSpeed Performance ReportMerging #950 will create unknown performance changesComparing Summary
|
…anstack/react-query@4,5 at once automatically (#946) related #944, #36 # Overview <!-- A clear and concise description of what this pr is about. --> ## PR Checklist - [x] I did below actions if need 1. I read the [Contributing Guide](https://github.com/toss/suspensive/blob/main/CONTRIBUTING.md) 2. I added documents and tests. --------- Co-authored-by: GwanSik Kim <39869096+gwansikk@users.noreply.github.com>
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to beta, this PR will be updated.⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ `beta` is currently in **pre mode** so this branch has prereleases rather than normal releases. If you want to exit prereleases, run `changeset pre exit` on `beta`.⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ # Releases ## @suspensive/react-query@2.1.2-beta.0 ### Patch Changes - [#946](#946) [`2fd8108`](2fd8108) Thanks [@manudeli](https://github.com/manudeli)! - feat(react-query) depend on @suspensive/react-query-4,5 to support @tanstack/react-query@4,5 at once automatically - Updated dependencies \[[`2fd8108`](2fd8108)]: - @suspensive/react-query-4@0.0.1-beta.0 - @suspensive/react-query-5@0.0.1-beta.0 - @suspensive/react@2.1.2-beta.0 ## @suspensive/react-query-4@0.0.1-beta.0 ### Patch Changes - [#946](#946) [`2fd8108`](2fd8108) Thanks [@manudeli](https://github.com/manudeli)! - feat(react-query) depend on @suspensive/react-query-4,5 to support @tanstack/react-query@4,5 at once automatically - Updated dependencies \[]: - @suspensive/react@2.1.2-beta.0 ## @suspensive/react-query-5@0.0.1-beta.0 ### Patch Changes - [#946](#946) [`2fd8108`](2fd8108) Thanks [@manudeli](https://github.com/manudeli)! - feat(react-query) depend on @suspensive/react-query-4,5 to support @tanstack/react-query@4,5 at once automatically - Updated dependencies \[]: - @suspensive/react@2.1.2-beta.0 ## @suspensive/react@2.1.2-beta.0 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
# Summary `@suspensive/react-query` now automatically identifies the installed version of `@tanstack/react-query` and uses either `@suspensive/react-query-4` or `@suspensive/react-query-5` accordingly. # Roadmaps > This is the list of remaining tasks. It may be added to or revised. - [x] Core - [x] Field Test - [ ] CLI⚠️ - [ ] Dependency Log ([comment](#953 (comment))) # How it works The mechanism for identifying the version of `@tanstack/react-query` and selecting the appropriate `@suspensive/react-query-x` to use is similar to `vue-demi`. - https://github.com/vueuse/vue-demi When `@suspsensive/react-query` is added as a dependency, the `postinstall` script fetches the version of `@tanstack/react-query` and overlays the build files of `@suspensive/react-query-x` at the entry point (build root) to ensure the appropriate version is used. ```json // package.json // ... "exports": { ".": { "import": { "types": "./dist/index.d.ts", "default": "./dist/index.js" }, "require": { "types": "./dist/index.d.cts", "default": "./dist/index.cjs" } }, "./package.json": "./package.json" }, // ... "postinstall": "node -e \"import('./scripts/postinstall.js').catch(e => console.error(e))\"" // ... ``` The `postinstall.js` script is executed during the `postinstall` process. ```jsx // script/postinstall.js import { loadModule, switchVersion } from './utils.js' const reactQueryPackageJson = loadModule('@tanstack/react-query/package.json') const version = reactQueryPackageJson?.version if (!version || typeof version !== 'string') { console.warn('@tanstack/react-query is not found.') } else if (version.startsWith('4.')) { switchVersion(4) } else if (version.startsWith('5.')) { switchVersion(5) } else { console.warn('[@suspensive/react-query]', `version v${version} is not supported.`) } ``` This script fetches the installed `@tanstack/react-query/package.json`, checks the version, and copies the corresponding `@suspensive/react-query-x` files to the library's root. ```bash suspensive/packages/react-query/dist # --- Library entry point ├── index.cjs ├── index.cjs.map ├── index.d.cts ├── index.d.ts ├── index.js ├── index.js.map # --- ├── v4 # --- Copy files from this folder to the entry point if @tanstack/react-query@4 is detected | ├── index.cjs | ├── index.cjs.map | ├── index.d.cts | ├── index.d.ts | ├── index.js | └── index.js.map # --- └── v5 # --- Copy files from this folder to the entry point if @tanstack/react-query@5 is detected ├── index.cjs ├── index.cjs.map ├── index.d.cts ├── index.d.ts ├── index.js └── index.js.map ``` By following this process, `@suspensive/react-query` automatically uses the appropriate version upon installation. When added as a dependency, the version switching happens automatically as shown in the logs below: ```bash # case1: @tanstack/react-query@4 packages/react-query postinstall$ node -e "import('./scripts/postinstall.js').catch(e => console.error(e))" │ [@suspensive/react-query] set version to v4 └─ Done in 56ms # case2: @tanstack/react-query@5 packages/react-query postinstall$ node -e "import('./scripts/postinstall.js').catch(e => console.error(e))" │ [@suspensive/react-query] set version to v5 └─ Done in 56ms ``` # Field Test > These tests were conducted in isolated environments using `~.tgz`. In all environments, `@suspensive/react": "^2.1.2-beta.0` was used consistently, and versions 4 and 5 of `@tanstack/react-query` were tested. > - pnpm@9.4.0 ✅ - yarn@v1.22.22 ✅ - yarn berry@4.3.0 (pnp) ✅ - pnpm@9.4.9 (monorepo) ✅ # CLI In typical environments (single repo), the version switches automatically. However, for special cases, we have created the `suspensive-react-query-switch` script, which forces the switching of `@suspensive/react-query-x`. ```bash npx suspensive-react-query-switch [@suspensive/react-query], expecting version "4" or "5"" npx suspensive-react-query-switch 4 [@suspensive/react-query] set version to v4 ``` Although it works in most environments, it does not work in the following case: - The CLI does not work properly in a monorepo environment.⚠️ - The CLI does not work properly in a yarn-berry (pnp) environment.⚠️ --------- Co-authored-by: Jonghyeon Ko <jonghyeon@toss.im>
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to beta, this PR will be updated.⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ `beta` is currently in **pre mode** so this branch has prereleases rather than normal releases. If you want to exit prereleases, run `changeset pre exit` on `beta`.⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ # Releases ## @suspensive/react-query@2.1.2-beta.1 ### Patch Changes - [#953](#953) [`8d8a2d6`](8d8a2d6) Thanks [@gwansikk](https://github.com/gwansikk)! - feat(react-query): universal support for TanStack Query 4 and 5 - Updated dependencies \[]: - @suspensive/react@2.1.2-beta.1 - @suspensive/react-query-4@0.0.1-beta.0 - @suspensive/react-query-5@0.0.1-beta.0 ## @suspensive/react@2.1.2-beta.1 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #950 +/- ##
=======================================
Coverage ? 80.67%
=======================================
Files ? 36
Lines ? 445
Branches ? 98
=======================================
Hits ? 359
Misses ? 77
Partials ? 9
|
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to beta, this PR will be updated. # Releases ## @suspensive/react-query@2.2.0 ### Minor Changes - [#953](#953) [`8d8a2d6`](8d8a2d6) Thanks [@gwansikk](https://github.com/gwansikk)! - feat(react-query): universal support for TanStack Query 4 and 5 ### Patch Changes - [#946](#946) [`2fd8108`](2fd8108) Thanks [@manudeli](https://github.com/manudeli)! - feat(react-query) depend on @suspensive/react-query-4,5 to support @tanstack/react-query@4,5 at once automatically - Updated dependencies \[[`2fd8108`](2fd8108)]: - @suspensive/react-query-4@0.0.1 - @suspensive/react-query-5@0.0.1 - @suspensive/react@2.2.0 ## @suspensive/react-query-4@0.0.1 ### Patch Changes - [#946](#946) [`2fd8108`](2fd8108) Thanks [@manudeli](https://github.com/manudeli)! - feat(react-query) depend on @suspensive/react-query-4,5 to support @tanstack/react-query@4,5 at once automatically - Updated dependencies \[]: - @suspensive/react@2.2.0 ## @suspensive/react-query-5@0.0.1 ### Patch Changes - [#946](#946) [`2fd8108`](2fd8108) Thanks [@manudeli](https://github.com/manudeli)! - feat(react-query) depend on @suspensive/react-query-4,5 to support @tanstack/react-query@4,5 at once automatically - Updated dependencies \[]: - @suspensive/react@2.2.0 ## @suspensive/react@2.2.0 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
close #944 related with #36