toss / suspensive

Manage asynchronous operations, timing, error handling, detecting intersection of elements, and caching easily (One of TanStack Query community resources)
https://suspensive.org
MIT License
440 stars 38 forks source link

refactor(react-query): only TypeScript & src, dist #970

Closed jungwoo3490 closed 3 weeks ago

jungwoo3490 commented 3 weeks ago

close #961 close #962

Overview

Hi @manudeli @gwansikk !!!

I converted all of @suspensive/react-querys JS scripts to TypeScript.

And I updated structure like this.

image



Please check it and leave feedback. I'll apply it. :)

PR Checklist

  1. I read the Contributing Guide
  2. I added documents and tests.
changeset-bot[bot] commented 3 weeks ago

πŸ¦‹ Changeset detected

Latest commit: b922f3165ab7641737c05f8e0640faadfce5f2b0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages | Name | Type | | ----------------------- | ----- | | @suspensive/react-query | Patch | | @suspensive/react | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

vercel[bot] commented 3 weeks ago

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated (UTC)
suspensive.org βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Jun 25, 2024 5:32am
v1.suspensive.org βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Jun 25, 2024 5:32am
visualization.suspensive.org βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Jun 25, 2024 5:32am
gwansikk commented 3 weeks ago

@jungwoo3490 you can understand the version switching mechanism in detail by checking the PR below:

jungwoo3490 commented 3 weeks ago

@jungwoo3490 you can understand the version switching mechanism in detail by checking the PR below:

I'll fix it with your reference. Thanks!!

codspeed-hq[bot] commented 3 weeks ago

CodSpeed Performance Report

Merging #970 will create unknown performance changes

Comparing jungwoo3490:ts-migration (b922f31) with main (42af7d0)

Summary

:warning: No benchmarks were detected in both the base of the PR and the PR.

codecov-commenter commented 3 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 80.88%. Comparing base (42af7d0) to head (b922f31).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/toss/suspensive/pull/970/graphs/tree.svg?width=650&height=150&src=pr&token=5PopssACmx&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=toss)](https://app.codecov.io/gh/toss/suspensive/pull/970?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=toss) ```diff @@ Coverage Diff @@ ## main #970 +/- ## ======================================= Coverage 80.88% 80.88% ======================================= Files 38 38 Lines 450 450 Branches 99 98 -1 ======================================= Hits 364 364 Misses 77 77 Partials 9 9 ``` | [Components](https://app.codecov.io/gh/toss/suspensive/pull/970/components?src=pr&el=components&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=toss) | Coverage Ξ” | | |---|---|---| | [@suspensive/react](https://app.codecov.io/gh/toss/suspensive/pull/970/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=toss) | `97.03% <ΓΈ> (ΓΈ)` | | | [@suspensive/react-query](https://app.codecov.io/gh/toss/suspensive/pull/970/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=toss) | `βˆ… <ΓΈ> (βˆ…)` | | | [@suspensive/react-query-4](https://app.codecov.io/gh/toss/suspensive/pull/970/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=toss) | `0.00% <ΓΈ> (ΓΈ)` | | | [@suspensive/react-query-5](https://app.codecov.io/gh/toss/suspensive/pull/970/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=toss) | `0.00% <ΓΈ> (ΓΈ)` | | | [@suspensive/react-await](https://app.codecov.io/gh/toss/suspensive/pull/970/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=toss) | `100.00% <ΓΈ> (ΓΈ)` | | | [@suspensive/react-image](https://app.codecov.io/gh/toss/suspensive/pull/970/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=toss) | `23.52% <ΓΈ> (ΓΈ)` | |
jungwoo3490 commented 3 weeks ago

When TypeScript compiles down to JavaScript, especially in certain environments or configurations, import.meta might not be preserved or recognized correctly.

Actually, this is compile result.

스크란샷 2024-06-25 α„‹α…©α„Œα…₯ᆫ 2 50 48

So I used process.cwd() to get current path instead of import.meta.

// const __filename = fileURLToPath(import.meta.url)
// const __dirname = dirname(__filename)

const __dirname = process.cwd()

Then it works well!!

image
jungwoo3490 commented 3 weeks ago

When TypeScript compiles down to JavaScript, especially in certain environments or configurations, import.meta might not be preserved or recognized correctly.

Actually, this is compile result. 스크란샷 2024-06-25 α„‹α…©α„Œα…₯ᆫ 2 50 48

So I used process.cwd() to get current path instead of import.meta.

// const __filename = fileURLToPath(import.meta.url)
// const __dirname = dirname(__filename)

const __dirname = process.cwd()

Then it works well!!

image

I found potential problem here.

process.cwd() value can be different depending on the environment in which the process is running.

So instead of process.cwd(), I used __filename to get current path. This ensures that a fixed file path is always obtained.

// const __dirname = process.cwd()

const currentFilePath = __filename
const __dirname = dirname(currentFilePath)
스크란샷 2024-06-25 α„‹α…©α„Œα…₯ᆫ 5 06 46
jungwoo3490 commented 3 weeks ago

Now, only cjs format bundle file generated, except index.ts, v4.ts, v5.ts.

image image
manudeli commented 3 weeks ago

https://www.npmjs.com/package/@suspensive/react-query?activeTab=code

@gwansikk @jungwoo3490 We can diff output files between as-is and to-be

gwansikk commented 3 weeks ago

@gwansikk Could you double-check again please?

LGTM πŸ‘πŸ‘ Everything is perfect. I tested it in both pnpm-monopre and pnpm environments.