From 429fd54903ffff65187bf1af8ded7085e46e2646 Mon Sep 17 00:00:00 2001 From: Muhammad Date: Tue, 17 Sep 2024 22:34:58 +0700 Subject: [PATCH] refactor(vike-solid-query): use `tsc` only for development and build --- package.json | 3 ++- .../vike-solid-query/integration/+config.ts | 9 ------- .../vike-solid-query/integration/Wrapper.ts | 14 ++++++++++ .../vike-solid-query/integration/Wrapper.tsx | 10 ------- .../{global.d.ts => integration/types.d.ts} | 2 ++ packages/vike-solid-query/package.json | 27 +++++++++---------- packages/vike-solid-query/rollup.config.js | 18 ------------- packages/vike-solid-query/tsconfig.json | 26 ++++++++---------- pnpm-lock.yaml | 18 ++----------- 9 files changed, 43 insertions(+), 84 deletions(-) create mode 100644 packages/vike-solid-query/integration/Wrapper.ts delete mode 100644 packages/vike-solid-query/integration/Wrapper.tsx rename packages/vike-solid-query/{global.d.ts => integration/types.d.ts} (93%) delete mode 100644 packages/vike-solid-query/rollup.config.js diff --git a/package.json b/package.json index 5e5534a..01998a7 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..fb2a9d5 100644 --- a/packages/vike-solid-query/integration/+config.ts +++ b/packages/vike-solid-query/integration/+config.ts @@ -1,5 +1,4 @@ import type { Config } from "vike/types"; -import type { QueryClientConfig } from "@tanstack/solid-query"; import "vike-solid/config"; // Needed for declaration merging of Config export default { @@ -24,11 +23,3 @@ export default { }, }, } satisfies Config; - -declare global { - namespace Vike { - interface Config { - queryClientConfig?: QueryClientConfig; - } - } -} diff --git a/packages/vike-solid-query/integration/Wrapper.ts b/packages/vike-solid-query/integration/Wrapper.ts new file mode 100644 index 0000000..fc023ac --- /dev/null +++ b/packages/vike-solid-query/integration/Wrapper.ts @@ -0,0 +1,14 @@ +import { createComponent, type JSX } from "solid-js"; +import { QueryClient, QueryClientProvider } from "@tanstack/solid-query"; +import { usePageContext } from "vike-solid/usePageContext"; + +export default function Wrapper(props: { children?: JSX.Element }) { + const pageContext = usePageContext(); + + return createComponent(QueryClientProvider, { + client: new QueryClient(pageContext.config.queryClientConfig), + get children() { + return props.children; + }, + }); +} diff --git a/packages/vike-solid-query/integration/Wrapper.tsx b/packages/vike-solid-query/integration/Wrapper.tsx deleted file mode 100644 index 8b8f034..0000000 --- a/packages/vike-solid-query/integration/Wrapper.tsx +++ /dev/null @@ -1,10 +0,0 @@ -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 }) { - const pageContext = usePageContext(); - const queryClient = new QueryClient(pageContext.config.queryClientConfig); - - return {props.children}; -} diff --git a/packages/vike-solid-query/global.d.ts b/packages/vike-solid-query/integration/types.d.ts similarity index 93% rename from packages/vike-solid-query/global.d.ts rename to packages/vike-solid-query/integration/types.d.ts index 0957a49..29b06a6 100644 --- a/packages/vike-solid-query/global.d.ts +++ b/packages/vike-solid-query/integration/types.d.ts @@ -7,3 +7,5 @@ declare global { } } } + +export {}; diff --git a/packages/vike-solid-query/package.json b/packages/vike-solid-query/package.json index f1a0910..920899c 100644 --- a/packages/vike-solid-query/package.json +++ b/packages/vike-solid-query/package.json @@ -2,10 +2,17 @@ "name": "vike-solid-query", "version": "0.0.1", "type": "module", + "main": "dist/src/index.js", + "typings": "dist/src/index.js", + "exports": { + ".": "./dist/src/index.js", + "./config": "./dist/integration/+config.js", + "./__internal/integration/Wrapper": "./dist/integration/Wrapper.js" + }, "scripts": { - "dev": "rollup -c rollup.config.js --watch", + "dev": "tsc --watch", "dev:typecheck": "tsc --noEmit --watch", - "build": "rollup -c rollup.config.js && tsc", + "build": "rimraf dist/ && tsc", "release": "LANG=en_US release-me patch", "release:minor": "LANG=en_US release-me minor", "release:commit": "LANG=en_US release-me commit" @@ -13,26 +20,16 @@ "peerDependencies": { "@tanstack/solid-query": ">=5.0.0", "solid-js": "^1.8.7", - "vike-solid": "workspace:^" + "vike-solid": ">=0.7.4" }, "devDependencies": { "@brillout/release-me": "^0.4.1", - "@rollup/plugin-babel": "^6.0.4", - "@rollup/plugin-node-resolve": "^15.2.3", "@tanstack/solid-query": "^5.56.2", "rimraf": "^6.0.1", - "rollup": "^4.21.3", - "rollup-plugin-dts": "^6.1.1", "solid-js": "^1.8.22", "typescript": "^5.6.2", "vike": "^0.4.195", - "vike-solid": "workspace:*", - "vite": "^5.4.6" - }, - "exports": { - ".": "./dist/src/index.js", - "./config": "./dist/integration/+config.js", - "./__internal/integration/Wrapper": "./dist/integration/Wrapper.js" + "vike-solid": "^0.7.5" }, "typesVersions": { "*": { @@ -45,7 +42,7 @@ } }, "files": [ - "dist/" + "dist" ], "repository": "github:vikejs/vike-solid", "license": "MIT" diff --git a/packages/vike-solid-query/rollup.config.js b/packages/vike-solid-query/rollup.config.js deleted file mode 100644 index 2d3eb2e..0000000 --- a/packages/vike-solid-query/rollup.config.js +++ /dev/null @@ -1,18 +0,0 @@ -import withSolid from "../vike-solid/with-solid.js"; -import dts from "rollup-plugin-dts"; - -export default [ - withSolid({ - input: { - "integration/+config": "./integration/+config.ts", - "integration/Wrapper": "./integration/Wrapper.tsx", - }, - ssr: true, - external: ["vike-solid/usePageContext"], - }), - { - input: ["./integration/+config.ts", "./integration/Wrapper.tsx"], - output: [{ dir: "dist", format: "es", sanitizeFileName: false }], - plugins: [dts()], - }, -]; diff --git a/packages/vike-solid-query/tsconfig.json b/packages/vike-solid-query/tsconfig.json index 7dc266b..0cd7313 100644 --- a/packages/vike-solid-query/tsconfig.json +++ b/packages/vike-solid-query/tsconfig.json @@ -1,21 +1,17 @@ { "compilerOptions": { - "target": "ESNext", - "module": "ESNext", - "moduleResolution": "node", - "strict": true, - "noUncheckedIndexedAccess": true, - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, "jsx": "preserve", "jsxImportSource": "solid-js", - "allowJs": true, - "types": ["vite/client"], - "isolatedModules": true, - "outDir": "./dist", - "declaration": true, + "module": "ES2022", + "moduleResolution": "Bundler", + "target": "ES2020", + "lib": ["DOM", "DOM.Iterable", "ES2022"], + "esModuleInterop": true, "skipLibCheck": true, - "rootDir": "./" - }, - "include": ["src/*", "global.d.ts"] + "allowSyntheticDefaultImports": true, + "verbatimModuleSyntax": true, + "strict": true, + "declaration": true, + "outDir": "./dist/" + } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1108ee3..537224a 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: @@ -153,24 +154,12 @@ importers: '@brillout/release-me': specifier: ^0.4.1 version: 0.4.1 - '@rollup/plugin-babel': - specifier: ^6.0.4 - version: 6.0.4(@babel/core@7.25.2)(@types/babel__core@7.20.5)(rollup@4.21.3) - '@rollup/plugin-node-resolve': - specifier: ^15.2.3 - version: 15.2.3(rollup@4.21.3) '@tanstack/solid-query': specifier: ^5.56.2 version: 5.56.2(solid-js@1.8.22) rimraf: specifier: ^6.0.1 version: 6.0.1 - rollup: - specifier: ^4.21.3 - version: 4.21.3 - rollup-plugin-dts: - specifier: ^6.1.1 - version: 6.1.1(rollup@4.21.3)(typescript@5.6.2) solid-js: specifier: ^1.8.22 version: 1.8.22 @@ -183,9 +172,6 @@ importers: vike-solid: specifier: link:../vike-solid version: link:../vike-solid - vite: - specifier: ^5.4.6 - version: 5.4.6(@types/node@22.5.5)(terser@5.32.0) packages: