Skip to content

Commit 8ad81e4

Browse files
committed
feat: export all of types
1 parent 56e470f commit 8ad81e4

14 files changed

Lines changed: 111 additions & 132 deletions

.DS_Store

6 KB
Binary file not shown.

README-zh_CN.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<br />
55

66
<p align="center">
7-
<a aria-label="NPM version" href="https://quaere-site.vercel.app">
7+
<a aria-label="NPM version" href="./assets/logo.svg">
88
<img alt="" src="./assets/logo.svg" height="40">
99
</a>
1010
</p>
@@ -14,7 +14,7 @@
1414
<p align="center">
1515
<a href="https://github.com/liaoliao666/react-query-kit/actions/workflows/tests.yml"><img src="https://github.com/liaoliao666/react-query-kit/actions/workflows/tests.yml/badge.svg?branch=main" alt="Latest build" target="\_parent"></a>
1616
<a href="https://www.npmjs.com/package/react-query-kit"><img src="https://badgen.net/npm/v/react-query-kit" alt="Latest published version" target="\_parent"></a>
17-
<a href="https://unpkg.com/browse/react-query-kit@latest/build/umd/index.production.js" rel="nofollow"><img src="https://img.badgesize.io/https:/unpkg.com/react-query-kit@latest/build/umd/index.production.js?label=gzip%20size&compression=gzip" alt="gzip size"></a>
17+
<a href="https://unpkg.com/browse/react-query-kit@latest/build/zip/zip.esm.js" rel="nofollow"><img src="https://img.badgesize.io/https:/unpkg.com/react-query-kit@latest/build/zip/zip.esm.js?label=gzip%20size&compression=gzip" alt="gzip size"></a>
1818
<a href="https://github.com/liaoliao666/react-query-kit"><img src="https://badgen.net/npm/types/react-query-kit" alt="Types included" target="\_parent"></a>
1919
<a href="https://www.npmjs.com/package/react-query-kit"><img src="https://badgen.net/npm/license/react-query-kit" alt="License" target="\_parent"></a>
2020
<a href="https://www.npmjs.com/package/react-query-kit"><img src="https://badgen.net/npm/dt/react-query-kit" alt="Number of downloads" target="\_parent"></a>
@@ -90,7 +90,6 @@ const usePost = createQuery<Response, Variables, Error>({
9090
// primaryKey 相等于 '/posts'
9191
return fetch(`${primaryKey}/${variables.id}`).then(res => res.json())
9292
},
93-
suspense: true,
9493
// 你还可以通过中间件来定制这个 hook 的行为
9594
use: [myMiddleware]
9695
})
@@ -100,7 +99,7 @@ const variables = { id: 1 }
10099
// example
101100
export default function Page() {
102101
// queryKey 相等于 ['/posts', { id: 1 }]
103-
const { data } = usePost({ variables, suspense: true })
102+
const { data } = usePost({ variables })
104103

105104
return (
106105
<div>
@@ -158,9 +157,9 @@ Expose Methods
158157

159158
- `getPrimaryKey: () => primaryKey`
160159
- `getKey: (variables: TVariables) => [primaryKey, variables]`
161-
- `getFetchOptions: (variables: TVariables) => {queryKey, queryFn, queryKeyHashFn}`
162160
- `queryFn: QueryFunction<TFnData, [primaryKey, TVariables]>`
163161
- `queryKeyHashFn: (queryKey: [primaryKey, TVariables]) => string`
162+
- `getFetchOptions: (variables: TVariables) => ({ queryKey, queryFn, queryKeyHashFn })`
164163

165164
## createInfiniteQuery
166165

@@ -190,7 +189,7 @@ const variables = { active: true }
190189
export default function Page() {
191190
// queryKey equals to ['projects', { active: true }]
192191
const { data, fetchNextPage, hasNextPage, isFetching, isFetchingNextPage } =
193-
useProjects({ variables, suspense: true })
192+
useProjects({ variables })
194193

195194
return (
196195
<div>
@@ -254,9 +253,9 @@ Expose Methods
254253

255254
- `getPrimaryKey: () => primaryKey`
256255
- `getKey: (variables: TVariables) => [primaryKey, variables]`
257-
- `getFetchOptions: (variables: TVariables) => {queryKey, queryFn, queryKeyHashFn, getNextPageParam, getPreviousPageParam, initialPageParam}`
258256
- `queryFn: QueryFunction<TFnData, [primaryKey, TVariables]>`
259257
- `queryKeyHashFn: (queryKey: [primaryKey, TVariables]) => string`
258+
- `getFetchOptions: (variables: TVariables) => ({ queryKey, queryFn, queryKeyHashFn, getNextPageParam, getPreviousPageParam, initialPageParam })`
260259

261260
## createSuspenseQuery
262261

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<br />
55

66
<p align="center">
7-
<a aria-label="NPM version" href="https://quaere-site.vercel.app">
7+
<a aria-label="NPM version" href="./assets/logo.svg">
88
<img alt="" src="./assets/logo.svg" height="40">
99
</a>
1010
</p>
@@ -14,7 +14,7 @@
1414
<p align="center">
1515
<a href="https://github.com/liaoliao666/react-query-kit/actions/workflows/tests.yml"><img src="https://github.com/liaoliao666/react-query-kit/actions/workflows/tests.yml/badge.svg?branch=main" alt="Latest build" target="\_parent"></a>
1616
<a href="https://www.npmjs.com/package/react-query-kit"><img src="https://badgen.net/npm/v/react-query-kit" alt="Latest published version" target="\_parent"></a>
17-
<a href="https://unpkg.com/browse/react-query-kit@latest/build/umd/index.production.js" rel="nofollow"><img src="https://img.badgesize.io/https:/unpkg.com/react-query-kit@latest/build/umd/index.production.js?label=gzip%20size&compression=gzip" alt="gzip size"></a>
17+
<a href="https://unpkg.com/browse/react-query-kit@latest/build/zip/zip.esm.js" rel="nofollow"><img src="https://img.badgesize.io/https:/unpkg.com/react-query-kit@latest/build/zip/zip.esm.js?label=gzip%20size&compression=gzip" alt="gzip size"></a>
1818
<a href="https://github.com/liaoliao666/react-query-kit"><img src="https://badgen.net/npm/types/react-query-kit" alt="Types included" target="\_parent"></a>
1919
<a href="https://github.com/liaoliao666/react-query-kit/blob/main/LICENSE"><img src="https://badgen.net/npm/license/react-query-kit" alt="License" target="\_parent"></a>
2020
<a href="https://www.npmjs.com/package/react-query-kit"><img src="https://badgen.net/npm/dt/react-query-kit" alt="Number of downloads" target="\_parent"></a>
@@ -93,7 +93,6 @@ const usePost = createQuery<Response, Variables, Error>({
9393
// primaryKey equals to '/posts'
9494
return fetch(`${primaryKey}/${variables.id}`).then(res => res.json())
9595
},
96-
suspense: true,
9796
// u can also pass middleware to cutomize this hook's behavior
9897
use: [myMiddleware]
9998
})
@@ -104,7 +103,7 @@ const variables = { id: 1 }
104103
// example
105104
export default function Page() {
106105
// queryKey equals to ['/posts', { id: 1 }]
107-
const { data } = usePost({ variables, suspense: true })
106+
const { data } = usePost({ variables })
108107

109108
return (
110109
<div>
@@ -160,9 +159,9 @@ Expose Methods
160159

161160
- `getPrimaryKey: () => primaryKey`
162161
- `getKey: (variables: TVariables) => [primaryKey, variables]`
163-
- `getFetchOptions: (variables: TVariables) => {queryKey, queryFn, queryKeyHashFn}`
164162
- `queryFn: QueryFunction<TFnData, [primaryKey, TVariables]>`
165163
- `queryKeyHashFn: (queryKey: [primaryKey, TVariables]) => string`
164+
- `getFetchOptions: (variables: TVariables) => ({ queryKey, queryFn, queryKeyHashFn })`
166165

167166
## createInfiniteQuery
168167

@@ -192,7 +191,7 @@ const variables = { active: true }
192191
export default function Page() {
193192
// queryKey equals to ['projects', { active: true }]
194193
const { data, fetchNextPage, hasNextPage, isFetching, isFetchingNextPage } =
195-
useProjects({ variables, suspense: true })
194+
useProjects({ variables })
196195

197196
return (
198197
<div>
@@ -256,9 +255,9 @@ Expose Methods
256255

257256
- `getPrimaryKey: () => primaryKey`
258257
- `getKey: (variables: TVariables) => [primaryKey, variables]`
259-
- `getFetchOptions: (variables: TVariables) => {queryKey, queryFn, queryKeyHashFn, getNextPageParam, getPreviousPageParam, initialPageParam}`
260258
- `queryFn: QueryFunction<TFnData, [primaryKey, TVariables]>`
261259
- `queryKeyHashFn: (queryKey: [primaryKey, TVariables]) => string`
260+
- `getFetchOptions: (variables: TVariables) => ({ queryKey, queryFn, queryKeyHashFn, getNextPageParam, getPreviousPageParam, initialPageParam })`
262261

263262
## createSuspenseQuery
264263

assets/logo.svg

Lines changed: 2 additions & 2 deletions
Loading

rollup.config.js

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import size from 'rollup-plugin-size'
66
import { terser } from 'rollup-plugin-terser'
77
import visualizer from 'rollup-plugin-visualizer'
88

9-
const umdDevPlugin = type =>
9+
const replaceDevPlugin = type =>
1010
replace({
1111
'process.env.NODE_ENV': `"${type}"`,
1212
delimiters: ['', ''],
@@ -35,6 +35,7 @@ export default function rollup() {
3535
cjs(options),
3636
umdDev(options),
3737
umdProd(options),
38+
esmZip(options),
3839
]
3940
}
4041

@@ -103,7 +104,7 @@ function umdDev({ input, external, globals, jsName }) {
103104
babelPlugin,
104105
commonJS(),
105106
nodeResolve({ extensions }),
106-
umdDevPlugin('development'),
107+
replaceDevPlugin('development'),
107108
],
108109
}
109110
}
@@ -124,7 +125,30 @@ function umdProd({ input, external, globals, jsName }) {
124125
babelPlugin,
125126
commonJS(),
126127
nodeResolve({ extensions }),
127-
umdDevPlugin('production'),
128+
replaceDevPlugin('production'),
129+
terser({
130+
mangle: true,
131+
compress: true,
132+
}),
133+
],
134+
}
135+
}
136+
137+
function esmZip({ input, external, globals, jsName }) {
138+
return {
139+
external,
140+
input,
141+
output: {
142+
format: 'esm',
143+
file: `build/zip/zip.esm.js`,
144+
name: jsName,
145+
globals,
146+
},
147+
plugins: [
148+
babelPlugin,
149+
commonJS(),
150+
nodeResolve({ extensions }),
151+
replaceDevPlugin('production'),
128152
terser({
129153
mangle: true,
130154
compress: true,

0 commit comments

Comments
 (0)