From 21483dbcf884fe10dc24b21c29e059716ea6a7a9 Mon Sep 17 00:00:00 2001 From: Muhammad Date: Wed, 25 Sep 2024 12:40:25 +0700 Subject: [PATCH] fix(vike-solid-query): fix `No QueryClient set` & `` --- package.json | 3 ++- .../vike-solid-query/integration/+config.ts | 2 +- .../vike-solid-query/integration/Wrapper.tsx | 2 +- packages/vike-solid-query/package.json | 25 +++++++++++++------ packages/vike-solid-query/rollup.config.js | 16 ++++++++---- packages/vike-solid-query/src/index.ts | 1 + packages/vike-solid-query/tsconfig.json | 3 +-- .../{global.d.ts => types.d.ts} | 0 pnpm-lock.yaml | 6 ++--- 9 files changed, 37 insertions(+), 21 deletions(-) rename packages/vike-solid-query/{global.d.ts => types.d.ts} (100%) diff --git a/package.json b/package.json index 43800d3..dd4fd91 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,8 @@ }, "pnpm": { "overrides": { - "vike-solid": "link:./packages/vike-solid/" + "vike-solid": "link:./packages/vike-solid/", + "vike-solid-query": "link:./packages/vike-solid-query/" } }, "devDependencies": { diff --git a/packages/vike-solid-query/integration/+config.ts b/packages/vike-solid-query/integration/+config.ts index de68f70..9d20200 100644 --- a/packages/vike-solid-query/integration/+config.ts +++ b/packages/vike-solid-query/integration/+config.ts @@ -5,7 +5,7 @@ import "vike-solid/config"; // Needed for declaration merging of Config export default { name: "vike-solid-query", require: { - "vike-solid": ">=0.7.3", + "vike-solid": ">=0.7.4", }, Wrapper: "import:vike-solid-query/__internal/integration/Wrapper:default", queryClientConfig: { diff --git a/packages/vike-solid-query/integration/Wrapper.tsx b/packages/vike-solid-query/integration/Wrapper.tsx index 8b8f034..3685e46 100644 --- a/packages/vike-solid-query/integration/Wrapper.tsx +++ b/packages/vike-solid-query/integration/Wrapper.tsx @@ -2,7 +2,7 @@ import { QueryClient, QueryClientProvider } from "@tanstack/solid-query"; import type { JSX } from "solid-js"; import { usePageContext } from "vike-solid/usePageContext"; -export default function Wrapper(props: { children: JSX.Element }) { +export default function Wrapper(props: { children?: JSX.Element }) { const pageContext = usePageContext(); const queryClient = new QueryClient(pageContext.config.queryClientConfig); diff --git a/packages/vike-solid-query/package.json b/packages/vike-solid-query/package.json index 268fa78..ed93160 100644 --- a/packages/vike-solid-query/package.json +++ b/packages/vike-solid-query/package.json @@ -2,6 +2,23 @@ "name": "vike-solid-query", "version": "0.0.1", "type": "module", + "main": "./dist/src/server.js", + "typings": "dist/src/index.d.ts", + "module": "./dist/src/server.js", + "types": "./dist/src/index.d.ts", + "browser": { + "./dist/src/server.js": "./dist/src/index.js" + }, + "exports": { + ".": { + "browser": "./dist/src/index.js", + "node": "./dist/src/server.js", + "default": "./dist/src/index.js", + "types": "./dist/src/index.d.ts" + }, + "./config": "./dist/integration/+config.js", + "./__internal/integration/Wrapper": "./dist/integration/Wrapper.jsx" + }, "scripts": { "dev": "rollup -c rollup.config.js --watch", "dev:typecheck": "tsc --noEmit --watch", @@ -26,13 +43,7 @@ "solid-js": "^1.8.22", "typescript": "^5.6.2", "vike": "^0.4.196", - "vike-solid": "workspace:*", - "vite": "^5.4.7" - }, - "exports": { - ".": "./dist/src/index.js", - "./config": "./dist/integration/+config.js", - "./__internal/integration/Wrapper": "./dist/integration/Wrapper.js" + "vike-solid": "workspace:*" }, "typesVersions": { "*": { diff --git a/packages/vike-solid-query/rollup.config.js b/packages/vike-solid-query/rollup.config.js index 2d3eb2e..62c0b1e 100644 --- a/packages/vike-solid-query/rollup.config.js +++ b/packages/vike-solid-query/rollup.config.js @@ -4,15 +4,21 @@ import dts from "rollup-plugin-dts"; export default [ withSolid({ input: { - "integration/+config": "./integration/+config.ts", - "integration/Wrapper": "./integration/Wrapper.tsx", + "src/server": "./src/index.ts", }, ssr: true, - external: ["vike-solid/usePageContext"], + external: [], + }), + withSolid({ + input: { + "src/index": "./src/index.ts", + }, + ssr: false, + external: [], }), { - input: ["./integration/+config.ts", "./integration/Wrapper.tsx"], - output: [{ dir: "dist", format: "es", sanitizeFileName: false }], + input: ["./src/index.ts"], + output: [{ dir: "dist/src", format: "es", sanitizeFileName: false }], plugins: [dts()], }, ]; diff --git a/packages/vike-solid-query/src/index.ts b/packages/vike-solid-query/src/index.ts index 25eef5a..7e56213 100644 --- a/packages/vike-solid-query/src/index.ts +++ b/packages/vike-solid-query/src/index.ts @@ -1 +1,2 @@ export { QueryBoundary } from "./QueryBoundary"; +export type { QueryBoundaryProps } from "./QueryBoundary"; diff --git a/packages/vike-solid-query/tsconfig.json b/packages/vike-solid-query/tsconfig.json index 7dc266b..fa6918f 100644 --- a/packages/vike-solid-query/tsconfig.json +++ b/packages/vike-solid-query/tsconfig.json @@ -10,12 +10,11 @@ "jsx": "preserve", "jsxImportSource": "solid-js", "allowJs": true, - "types": ["vite/client"], "isolatedModules": true, "outDir": "./dist", "declaration": true, "skipLibCheck": true, "rootDir": "./" }, - "include": ["src/*", "global.d.ts"] + "include": ["integration/", "types.d.ts"] } diff --git a/packages/vike-solid-query/global.d.ts b/packages/vike-solid-query/types.d.ts similarity index 100% rename from packages/vike-solid-query/global.d.ts rename to packages/vike-solid-query/types.d.ts diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d26f557..ebc50e6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,6 +6,7 @@ settings: overrides: vike-solid: link:./packages/vike-solid/ + vike-solid-query: link:./packages/vike-solid-query/ importers: @@ -80,7 +81,7 @@ importers: specifier: link:../../packages/vike-solid version: link:../../packages/vike-solid vike-solid-query: - specifier: workspace:^ + specifier: link:../../packages/vike-solid-query version: link:../../packages/vike-solid-query devDependencies: typescript: @@ -183,9 +184,6 @@ importers: vike-solid: specifier: link:../vike-solid version: link:../vike-solid - vite: - specifier: ^5.4.7 - version: 5.4.7(@types/node@22.5.5)(terser@5.32.0) packages: