Skip to content
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

refactor(tsup): update script options #1370

Merged
merged 8 commits into from
Nov 23, 2024
Merged

Conversation

gwansikk
Copy link
Collaborator

@gwansikk gwansikk commented Nov 22, 2024

Overview

details: #1338 (comment)

  • Standardized tsup script options.
  • Narrowed down the utils folder in react-query and codemods. (The react-query project structure has been updated accordingly.)
  • I verified that it works correctly locally using pnpm pack.

PR Checklist

  • I did below actions if need
  1. I read the Contributing Guide
  2. I added documents and tests.

@gwansikk gwansikk self-assigned this Nov 22, 2024
Copy link

changeset-bot bot commented Nov 22, 2024

🦋 Changeset detected

Latest commit: a743517

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

This PR includes changesets to release 6 packages
Name Type
@suspensive/codemods Patch
@suspensive/react-query Patch
@suspensive/react Patch
@suspensive/react-query-4 Patch
@suspensive/react-query-5 Patch
@suspensive/jotai 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

Copy link

vercel bot commented Nov 22, 2024

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 Nov 23, 2024 7:23am
v1.suspensive.org ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 23, 2024 7:23am
visualization.suspensive.org ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 23, 2024 7:23am

Copy link

coauthors bot commented Nov 22, 2024

People can be co-author:

Candidate Reasons Count Add this as commit message
@gwansikk #1370 (comment) #1370 (review) #1370 (comment) #1370 4 Co-authored-by: gwansikk <[email protected]>
@manudeli #1370 (comment) #1370 (review) #1370 (review) #1370 (comment) 4 Co-authored-by: manudeli <[email protected]>
@codecov-commenter #1370 (comment) 1 Co-authored-by: codecov-commenter <[email protected]>

Copy link

github-actions bot commented Nov 22, 2024

Size Change: 0 B

Total Size: 64.2 kB

ℹ️ View Unchanged
Filename Size
packages/jotai/dist/Atom.cjs 660 B
packages/jotai/dist/Atom.js 115 B
packages/jotai/dist/AtomValue.cjs 647 B
packages/jotai/dist/AtomValue.js 120 B
packages/jotai/dist/index.cjs 755 B
packages/jotai/dist/index.js 158 B
packages/jotai/dist/SetAtom.cjs 645 B
packages/jotai/dist/SetAtom.js 118 B
packages/react-dom/dist/index.cjs 2.11 kB
packages/react-dom/dist/index.js 139 B
packages/react-dom/dist/InView.cjs 2.1 kB
packages/react-dom/dist/InView.js 130 B
packages/react-dom/dist/useInView.cjs 1.87 kB
packages/react-dom/dist/useInView.js 120 B
packages/react-native/dist/index.cjs 619 B
packages/react-native/dist/index.js 122 B
packages/react-native/dist/TestText.cjs 612 B
packages/react-native/dist/TestText.js 119 B
packages/react-query-4/dist/index.cjs 1.86 kB
packages/react-query-4/dist/index.js 394 B
packages/react-query-4/dist/infiniteQueryOptions.cjs 548 B
packages/react-query-4/dist/infiniteQueryOptions.js 144 B
packages/react-query-4/dist/Mutation.cjs 821 B
packages/react-query-4/dist/Mutation.js 132 B
packages/react-query-4/dist/PrefetchInfiniteQuery.cjs 722 B
packages/react-query-4/dist/PrefetchInfiniteQuery.js 155 B
packages/react-query-4/dist/PrefetchQuery.cjs 712 B
packages/react-query-4/dist/PrefetchQuery.js 147 B
packages/react-query-4/dist/QueryClientConsumer.cjs 665 B
packages/react-query-4/dist/QueryClientConsumer.js 139 B
packages/react-query-4/dist/QueryErrorBoundary.cjs 1.12 kB
packages/react-query-4/dist/QueryErrorBoundary.js 142 B
packages/react-query-4/dist/queryOptions.cjs 540 B
packages/react-query-4/dist/queryOptions.js 135 B
packages/react-query-4/dist/SuspenseInfiniteQuery.cjs 1.05 kB
packages/react-query-4/dist/SuspenseInfiniteQuery.js 155 B
packages/react-query-4/dist/SuspenseQueries.cjs 923 B
packages/react-query-4/dist/SuspenseQueries.js 149 B
packages/react-query-4/dist/SuspenseQuery.cjs 1.04 kB
packages/react-query-4/dist/SuspenseQuery.js 147 B
packages/react-query-4/dist/usePrefetchInfiniteQuery.cjs 648 B
packages/react-query-4/dist/usePrefetchInfiniteQuery.js 148 B
packages/react-query-4/dist/usePrefetchQuery.cjs 639 B
packages/react-query-4/dist/usePrefetchQuery.js 140 B
packages/react-query-4/dist/useSuspenseInfiniteQuery.cjs 833 B
packages/react-query-4/dist/useSuspenseInfiniteQuery.js 148 B
packages/react-query-4/dist/useSuspenseQueries.cjs 833 B
packages/react-query-4/dist/useSuspenseQueries.js 142 B
packages/react-query-4/dist/useSuspenseQuery.cjs 824 B
packages/react-query-4/dist/useSuspenseQuery.js 140 B
packages/react-query-5/dist/index.cjs 1.76 kB
packages/react-query-5/dist/index.js 391 B
packages/react-query-5/dist/infiniteQueryOptions.cjs 573 B
packages/react-query-5/dist/infiniteQueryOptions.js 144 B
packages/react-query-5/dist/Mutation.cjs 821 B
packages/react-query-5/dist/Mutation.js 132 B
packages/react-query-5/dist/PrefetchInfiniteQuery.cjs 647 B
packages/react-query-5/dist/PrefetchInfiniteQuery.js 145 B
packages/react-query-5/dist/PrefetchQuery.cjs 639 B
packages/react-query-5/dist/PrefetchQuery.js 137 B
packages/react-query-5/dist/QueryClientConsumer.cjs 663 B
packages/react-query-5/dist/QueryClientConsumer.js 140 B
packages/react-query-5/dist/QueryErrorBoundary.cjs 1.12 kB
packages/react-query-5/dist/QueryErrorBoundary.js 142 B
packages/react-query-5/dist/queryOptions.cjs 563 B
packages/react-query-5/dist/queryOptions.js 136 B
packages/react-query-5/dist/SuspenseInfiniteQuery.cjs 833 B
packages/react-query-5/dist/SuspenseInfiniteQuery.js 145 B
packages/react-query-5/dist/SuspenseQueries.cjs 671 B
packages/react-query-5/dist/SuspenseQueries.js 139 B
packages/react-query-5/dist/SuspenseQuery.cjs 825 B
packages/react-query-5/dist/SuspenseQuery.js 137 B
packages/react-query-5/dist/usePrefetchInfiniteQuery.cjs 577 B
packages/react-query-5/dist/usePrefetchInfiniteQuery.js 148 B
packages/react-query-5/dist/usePrefetchQuery.cjs 569 B
packages/react-query-5/dist/usePrefetchQuery.js 140 B
packages/react-query-5/dist/useSuspenseInfiniteQuery.cjs 577 B
packages/react-query-5/dist/useSuspenseInfiniteQuery.js 148 B
packages/react-query-5/dist/useSuspenseQueries.cjs 571 B
packages/react-query-5/dist/useSuspenseQueries.js 142 B
packages/react-query-5/dist/useSuspenseQuery.cjs 569 B
packages/react-query-5/dist/useSuspenseQuery.js 140 B
packages/react-query/dist/index.cjs 551 B
packages/react-query/dist/index.js 121 B
packages/react-query/dist/v4.cjs 550 B
packages/react-query/dist/v4.js 116 B
packages/react-query/dist/v5.cjs 550 B
packages/react-query/dist/v5.js 116 B
packages/react/dist/ClientOnly.cjs 734 B
packages/react/dist/ClientOnly.js 141 B
packages/react/dist/DefaultProps.cjs 1.05 kB
packages/react/dist/DefaultProps.js 167 B
packages/react/dist/Delay.cjs 1.23 kB
packages/react/dist/Delay.js 159 B
packages/react/dist/DevMode.cjs 530 B
packages/react/dist/DevMode.js 131 B
packages/react/dist/ErrorBoundary.cjs 2.74 kB
packages/react/dist/ErrorBoundary.js 205 B
packages/react/dist/ErrorBoundaryGroup.cjs 1.38 kB
packages/react/dist/ErrorBoundaryGroup.js 195 B
packages/react/dist/index.cjs 4.32 kB
packages/react/dist/index.js 368 B
packages/react/dist/Suspense.cjs 1.29 kB
packages/react/dist/Suspense.js 171 B
packages/react/dist/Suspensive.cjs 1.26 kB
packages/react/dist/Suspensive.js 175 B
packages/react/dist/wrap.cjs 3.78 kB
packages/react/dist/wrap.js 209 B

compressed-size-action

Copy link

codspeed-hq bot commented Nov 22, 2024

CodSpeed Performance Report

Merging #1370 will create unknown performance changes

Comparing tsup/feature/script-options (a743517) with main (800ba8f)

Summary

⚠️ No benchmarks were detected in both the base of the PR and the PR.\

@codecov-commenter
Copy link

codecov-commenter commented Nov 22, 2024

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 72.11%. Comparing base (800ba8f) to head (a743517).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1370      +/-   ##
==========================================
+ Coverage   71.86%   72.11%   +0.24%     
==========================================
  Files          67       67              
  Lines         583      581       -2     
  Branches      129      129              
==========================================
  Hits          419      419              
+ Misses        151      149       -2     
  Partials       13       13              
Components Coverage Δ
@suspensive/react 100.00% <ø> (ø)
@suspensive/react-dom 100.00% <ø> (ø)
@suspensive/react-native 100.00% <ø> (ø)
@suspensive/react-query 74.01% <0.00%> (+1.14%) ⬆️
@suspensive/react-query-4 0.00% <ø> (ø)
@suspensive/react-query-5 0.00% <ø> (ø)
@suspensive/jotai 0.00% <ø> (ø)
@suspensive/codemods 41.97% <ø> (ø)
---- 🚨 Try these New Features:

@gwansikk gwansikk marked this pull request as ready for review November 22, 2024 10:31
@gwansikk gwansikk requested a review from manudeli as a code owner November 22, 2024 10:31
Comment on lines 4 to 22
try {
const { version } = getTanStackReactQueryPackageJson()

if (!version) {
throw new Error()
}

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.`)
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
console.error('[@suspensive/react-query]', 'not fond @tanstack/react-query')
process.exit(1)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original code

import { getTanStackReactQueryPackageJson } from './utils/package'
import { switchVersion } from './utils/switchVersion'

const { version } = getTanStackReactQueryPackageJson()

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.`)
}

I suggest below code.

Suggested change
try {
const { version } = getTanStackReactQueryPackageJson()
if (!version) {
throw new Error()
}
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.`)
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
console.error('[@suspensive/react-query]', 'not fond @tanstack/react-query')
process.exit(1)
}
const { version } = getTanStackReactQueryPackageJson()
if (!version) {
throw new Error('[@suspensive/react-query]', 'not found version of @tanstack/react-query')
}
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.`)
}

if you want use try catch, you could make specific error constructor to specify that caught error is for not found version

Suggested change
try {
const { version } = getTanStackReactQueryPackageJson()
if (!version) {
throw new Error()
}
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.`)
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
console.error('[@suspensive/react-query]', 'not fond @tanstack/react-query')
process.exit(1)
}
class NotFoundVersionError extends Error {
message: string = 'Not found version'
}
try {
const { version } = getTanStackReactQueryPackageJson()
if (!version) {
throw new NotFoundVersionError()
}
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.`)
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
// but in my opinion, this is not good idea
if(error instanceof NotFoundVersionError){ // specify error
console.error('[@suspensive/react-query]', error.message)
}
process.exit(1)
}

Copy link
Collaborator Author

@gwansikk gwansikk Nov 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My intention was to simplify the postinstall script. Ultimately, I designed it so that if an error occurs at runtime (e.g., node ./dist/bin/postinstall.cjs || echo 'please reinstall @suspensive/react-query'), the error would propagate as intended. The goal was to consistently inform the user of an appropriate solution through a clear message.

Therefore, I believe this file does not cause any inconvenience to the user due to node(runtime) errors, and I will revert it to its previous state (this was my mistake😢).

Copy link
Member

@manudeli manudeli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple than before 👍

@manudeli
Copy link
Member

@gwansikk Test after new version release please 🙏 I'll release this now

@manudeli manudeli merged commit 390e82d into main Nov 23, 2024
18 checks passed
@manudeli manudeli deleted the tsup/feature/script-options branch November 23, 2024 07:30
@gwansikk
Copy link
Collaborator Author

@gwansikk Test after new version release please 🙏 I'll release this now

I'm ready!

manudeli added a commit that referenced this pull request Nov 23, 2024
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 main, this PR will
be updated.


# Releases
## @suspensive/[email protected]

### Patch Changes

- [#1370](#1370)
[`390e82d`](390e82d)
Thanks [@gwansikk](https://github.com/gwansikk)! - refactor(tsup):
update script options

## @suspensive/[email protected]

### Patch Changes

- [#1370](#1370)
[`390e82d`](390e82d)
Thanks [@gwansikk](https://github.com/gwansikk)! - refactor(tsup):
update script options

-   Updated dependencies \[]:
    -   @suspensive/[email protected]
    -   @suspensive/[email protected]
    -   @suspensive/[email protected]

## @suspensive/[email protected]

### Patch Changes

-   Updated dependencies \[]:
    -   @suspensive/[email protected]

## @suspensive/[email protected]

### Patch Changes

-   Updated dependencies \[]:
    -   @suspensive/[email protected]

## @suspensive/[email protected]



## @suspensive/[email protected]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants