-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: breat trpc-react-query into its own package
Signed-off-by: Marc MacLeod <[email protected]>
- Loading branch information
Showing
18 changed files
with
131 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = { | ||
root: true, | ||
extends: ['../../.eslintrc.cjs'], | ||
parserOptions: { | ||
tsconfigRootDir: __dirname, | ||
project: './tsconfig.json', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# @ssrx/trpc-react |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# @ssrx/trpc-react | ||
|
||
Similar https://github.com/trpc/trpc/tree/main/packages/react-query, with the following major changes: | ||
|
||
- Does not rely on global/react context - supports instanced use (for example in SSR where a fresh client per request is | ||
required). | ||
- Scoped + typesafe `.$invalidate()` function on queries, e.g. `trpc.articles.$invalidate({ id })`. | ||
|
||
**Example instantiation from a react-query client:** | ||
|
||
```ts | ||
import type { QueryClient } from '@tanstack/react-query'; | ||
import { createTRPCUntypedClient } from '@trpc/client'; | ||
import { type CreateTRPCQueryOptions, createTRPCReact } from '@ssrx/trpc-react-query'; | ||
|
||
export const createTrpc = ({ | ||
queryClient, | ||
createTRPCQueryOptions, | ||
}: { | ||
queryClient: QueryClient; | ||
options?: CreateTRPCQueryOptions; | ||
}) => { | ||
const trpcClient = createTRPCUntypedClient(); | ||
|
||
const trpc = createTRPCReact<TRouter>({ | ||
client: trpcClient, | ||
queryClient, | ||
...createTRPCQueryOptions, | ||
}); | ||
|
||
return trpc; | ||
}; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"name": "@ssrx/trpc-react-query", | ||
"version": "0.0.1", | ||
"sideEffects": false, | ||
"type": "module", | ||
"license": "MIT", | ||
"keywords": [ | ||
"trpc", | ||
"react", | ||
"react-query" | ||
], | ||
"author": "marbemac (https://github.com/marbemac)", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/marbemac/ssrx", | ||
"directory": "packages/trpc-react-query" | ||
}, | ||
"files": [ | ||
"dist", | ||
"src" | ||
], | ||
"exports": { | ||
".": { | ||
"bun": "./src/index.ts", | ||
"default": "./dist/index.js" | ||
} | ||
}, | ||
"scripts": { | ||
"build": "tsup", | ||
"typecheck": "tsc", | ||
"lint": "eslint ." | ||
}, | ||
"peerDependencies": { | ||
"@tanstack/react-query": "^5", | ||
"react": "*" | ||
}, | ||
"devDependencies": { | ||
"@tanstack/react-query": "^5.15.0", | ||
"@trpc/client": "10.45.0", | ||
"@trpc/server": "10.45.0" | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions
1
...plugin-trpc-react/src/trpc-react/index.ts → packages/trpc-react-query/src/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export { type CreateTRPCReact, createTRPCReact } from './createTRPCReact.ts'; | ||
export { createTRPCProvider } from './provider.ts'; | ||
export type { CreateTRPCQueryOptions } from './types.ts'; |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"include": ["**/*.ts", "**/*.tsx"], | ||
"compilerOptions": { | ||
"jsx": "react-jsx", | ||
"paths": { | ||
"~/*": ["./src/*"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { defineConfig } from 'tsup'; | ||
|
||
export default defineConfig({ | ||
dts: true, | ||
format: 'esm', | ||
sourcemap: true, | ||
clean: true, | ||
external: ['react'], | ||
noExternal: ['@trpc/server', '@trpc/client'], | ||
entry: ['src/index.ts'], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters