toss / suspensive

All in one for React Suspense
https://suspensive.org
MIT License
540 stars 52 forks source link

[Feature]: Codemods for React Query version migration #1322

Closed gwansikk closed 2 weeks ago

gwansikk commented 1 month ago

Package Scope

@suspensive/react-query

Description

A useful idea has come to mind. Currently, @suspensive/react-query differentiates the API usage based on the version of @tanstack/react-query present in the user’s environment. When upgrading from v4, which lacks the Suspense Hook, to v5, the migration instructions are displayed through JSDoc as shown below.

/**
 * This feature is officially supported in @tanstack/react-query@5. You can proceed with the migration.
 * @deprecated Use `useSuspenseQuery` from @tanstack/react-query@5
 * @example
 * ```diff
 * - import { useSuspenseQuery } from '@suspensive/react-query'
 * + import { useSuspenseQuery } from '@tanstack/react-query'
 * ```
 */
export const useSuspenseQuery = original_useSuspenseQuery;

What if we take this further and offer a CLI tool to automate the code migration, similar to @next/codemods? This way, users could easily upgrade the v4 API to the v5 API across their codebase. I believe this would provide a smoother transition. (This is an idea proposal.)

Possible Solution

etc.

No response

coauthors[bot] commented 1 month ago

People can be co-author:

Candidate Reasons Count Add this as commit message
@gwansikk https://github.com/toss/suspensive/issues/1322#issuecomment-2415726108 https://github.com/toss/suspensive/issues/1322#issuecomment-2427303941 https://github.com/toss/suspensive/issues/1322 3 Co-authored-by: gwansikk <39869096+gwansikk@users.noreply.github.com>
gwansikk commented 1 month ago

I understand that this task is not essential and could even interfere with library maintenance. However, I believe it could become a valuable productivity tool in environments with large codebases, which is why I’m proposing it. What are your thoughts?

gwansikk commented 1 month ago

I’m currently dealing with a busy schedule. 😥 I promise to complete the PoC for this idea within this month. If you have any good ideas related to this, please feel free to share!