Skip to content

Commit

Permalink
chore: remove unnecessary build
Browse files Browse the repository at this point in the history
  • Loading branch information
manudeli committed Oct 24, 2023
1 parent 3e88d45 commit 63765da
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 79 deletions.
24 changes: 1 addition & 23 deletions configs/test-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,12 @@
},
"sideEffects": false,
"type": "module",
"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"
},
"main": "dist/index.cjs",
"types": "dist/index.d.ts",
"main": "src/index.ts",
"scripts": {
"build": "tsup",
"build:watch": "tsup --watch",
"clean": "rimraf ./dist",
"lint": "eslint \"**/*.ts*\"",
"lint:attw": "attw --pack",
"lint:pub": "publint --strict",
"prepack": "pnpm build",
"type:check": "tsc --noEmit"
},
"devDependencies": {
"@suspensive/tsup": "workspace:*",
"@types/node": "^18.16.2",
"@types/react": "^18.2.0",
"react": "^18.2.0"
},
Expand Down
18 changes: 18 additions & 0 deletions configs/test-utils/src/Suspend.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { ReactNode } from 'react'

const suspendIsNeed = { current: true }
type SuspendProps = { during: number; toShow?: ReactNode }
export const Suspend = ({ during, toShow }: SuspendProps) => {
if (suspendIsNeed.current) {
throw new Promise((resolve) =>
setTimeout(() => {
suspendIsNeed.current = false
resolve('resolved')
}, during)
)
}
return <>{toShow}</>
}
Suspend.reset = () => {
suspendIsNeed.current = true
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { PropsWithChildren, ReactNode } from 'react'
import type { PropsWithChildren } from 'react'
import { useEffect, useState } from 'react'

const useSetTimeout = (fn: (...args: []) => void, delay: number) =>
Expand All @@ -7,23 +7,6 @@ const useSetTimeout = (fn: (...args: []) => void, delay: number) =>
return () => clearTimeout(timeout)
}, [fn, delay])

const suspendIsNeed = { current: true }
type SuspendProps = { during: number; toShow?: ReactNode }
export const Suspend = ({ during, toShow }: SuspendProps) => {
if (suspendIsNeed.current) {
throw new Promise((resolve) =>
setTimeout(() => {
suspendIsNeed.current = false
resolve('resolved')
}, during)
)
}
return <>{toShow}</>
}
Suspend.reset = () => {
suspendIsNeed.current = true
}

const throwErrorIsNeed = { current: false }
type ThrowErrorProps = PropsWithChildren<{ message: string; after?: number }>
export const ThrowError = ({ message, after = 0, children }: ThrowErrorProps) => {
Expand All @@ -48,10 +31,3 @@ export const ThrowNull = ({ after, children }: ThrowNullProps) => {
ThrowError.reset = () => {
throwErrorIsNeed.current = false
}

export const delay = (ms: number) => new Promise((resolve) => setTimeout(() => resolve('done'), ms))

export const TEXT = 'TEXT' as const
export const ERROR_MESSAGE = 'ERROR_MESSAGE' as const
export const FALLBACK = 'FALLBACK' as const
export const MS_100 = 100 as const
1 change: 1 addition & 0 deletions configs/test-utils/src/delay.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const delay = (ms: number) => new Promise((resolve) => setTimeout(() => resolve('done'), ms))
7 changes: 7 additions & 0 deletions configs/test-utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export { Suspend } from './Suspend'
export { ThrowError, ThrowNull } from './ThrowError'
export { delay } from './delay'
export const TEXT = 'TEXT' as const
export const ERROR_MESSAGE = 'ERROR_MESSAGE' as const
export const FALLBACK = 'FALLBACK' as const
export const MS_100 = 100 as const
4 changes: 0 additions & 4 deletions configs/test-utils/tsup.config.ts

This file was deleted.

48 changes: 21 additions & 27 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 63765da

Please sign in to comment.