diff --git a/examples/basic/package.json b/examples/basic/package.json index 1211f47..ae75329 100644 --- a/examples/basic/package.json +++ b/examples/basic/package.json @@ -10,8 +10,8 @@ "cross-fetch": "^3.1.8", "node-fetch": "^3.3.2", "solid-js": "^1.7.11", - "vite-plugin-ssr": "^0.4.136", - "vike-solid": "workspace:*" + "vike-solid": "workspace:*", + "vite-plugin-ssr": "^0.4.141" }, "devDependencies": { "typescript": "^5.1.6" diff --git a/examples/basic/pages/+config.h.ts b/examples/basic/pages/+config.h.ts index bdb9173..ddc1cf4 100644 --- a/examples/basic/pages/+config.h.ts +++ b/examples/basic/pages/+config.h.ts @@ -1,4 +1,4 @@ -import type { Config } from "vike-solid"; +import type { Config } from "vite-plugin-ssr/types"; import vikeSolid from "vike-solid"; import Layout from "../layouts/LayoutDefault"; import Head from "./Head"; diff --git a/examples/ssr-spa/package.json b/examples/ssr-spa/package.json index 95a4520..07d515f 100644 --- a/examples/ssr-spa/package.json +++ b/examples/ssr-spa/package.json @@ -8,7 +8,8 @@ }, "dependencies": { "solid-js": "^1.7.11", - "vike-solid": "workspace:*" + "vike-solid": "workspace:*", + "vite-plugin-ssr": "^0.4.141" }, "devDependencies": { "typescript": "^5.1.6" diff --git a/examples/ssr-spa/pages/+config.h.ts b/examples/ssr-spa/pages/+config.h.ts index 0b52235..1d99ea8 100644 --- a/examples/ssr-spa/pages/+config.h.ts +++ b/examples/ssr-spa/pages/+config.h.ts @@ -1,4 +1,4 @@ -import type { Config } from "vike-solid"; +import type { Config } from "vite-plugin-ssr/types"; import vikeSolid from "vike-solid"; import Layout from "../layouts/LayoutDefault"; import Head from "./Head"; diff --git a/examples/ssr-spa/pages/spa/+config.h.ts b/examples/ssr-spa/pages/spa/+config.h.ts index eebf5b4..c8e7287 100644 --- a/examples/ssr-spa/pages/spa/+config.h.ts +++ b/examples/ssr-spa/pages/spa/+config.h.ts @@ -1,4 +1,4 @@ -import type { Config } from "vike-solid"; +import type { Config } from "vite-plugin-ssr/types"; export default { ssr: false, // SPA diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 26f2771..1ea5bed 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -23,8 +23,8 @@ importers: specifier: workspace:* version: link:../../vike-solid vite-plugin-ssr: - specifier: ^0.4.136 - version: 0.4.136(vite@4.4.9) + specifier: ^0.4.141 + version: 0.4.141(vite@4.4.9) devDependencies: typescript: specifier: ^5.1.6 @@ -38,6 +38,9 @@ importers: vike-solid: specifier: workspace:* version: link:../../vike-solid + vite-plugin-ssr: + specifier: ^0.4.141 + version: 0.4.141(vite@4.4.9) devDependencies: typescript: specifier: ^5.1.6 @@ -92,8 +95,8 @@ importers: specifier: ^5.1.6 version: 5.1.6 vite-plugin-ssr: - specifier: ^0.4.136 - version: 0.4.136(vite@4.4.9) + specifier: ^0.4.141 + version: 0.4.141(vite@4.4.9) packages: @@ -1284,11 +1287,11 @@ packages: /@brillout/import@0.2.3: resolution: {integrity: sha512-1T8WlD75eeFSMrptGy8jiLHmfHgMmSjWvLOIUvHmSVZt+6k0eQqYUoK4KbmE4T9pVLIfxvZSOm2D68VEqKRHRw==} - /@brillout/json-serializer@0.5.4: - resolution: {integrity: sha512-Lz/gQXKSoykR4g0PmBHpa+ILNJU7K0mZpWfBpDg5NnmPyHiDVnipwoH90Zv613FAwgUaV5HMCgYns6Lh78M+Yw==} + /@brillout/json-serializer@0.5.6: + resolution: {integrity: sha512-48u+Wthh0muDueyooi/Or59DDFCPitnuCN9OkMWoj7MQAbDn5pS/cVBB7ds6ENmtC1Qb0spI4PfKZxQSBEkubg==} - /@brillout/picocolors@1.0.6: - resolution: {integrity: sha512-Ln5rMxhWyGaQxZu6LTbA7izEI7xytbvK9QFwuH3Rj61rAPArLeKYMUmNa3f8COHl3++iBs98gTu9Slmyvnst2Q==} + /@brillout/picocolors@1.0.9: + resolution: {integrity: sha512-Lt/W5JsA75hcDJ2cOAlE4TqSMl6c9K+rXGRo/cU2fApnmhbRcNdkR4UHQDAwtWfZyUKWaxdwSui+jp+74J1pZg==} /@brillout/require-shim@0.1.2: resolution: {integrity: sha512-3I4LRHnVZXoSAsEoni5mosq9l6eiJED58d9V954W4CIZ88AUfYBanWGBGbJG3NztaRTpFHEA6wB3Hn93BmmJdg==} @@ -2064,8 +2067,8 @@ packages: /electron-to-chromium@1.4.490: resolution: {integrity: sha512-6s7NVJz+sATdYnIwhdshx/N/9O6rvMxmhVoDSDFdj6iA45gHR8EQje70+RYsF4GeB+k0IeNSBnP7yG9ZXJFr7A==} - /es-module-lexer@0.10.5: - resolution: {integrity: sha512-+7IwY/kiGAacQfY+YBhKMvEmyAJnw5grTUgjG85Pe7vcUI/6b7pZjZG8nQ7+48YhzEAEqrEgD2dCz/JIK+AYvw==} + /es-module-lexer@1.3.1: + resolution: {integrity: sha512-JUFAyicQV9mXc3YRxPnDlrfBKpqt6hUYzz9/boprUJHs4e4KVr3XwOF70doO6gwXUor6EWZJAyWAfKki84t20Q==} /esbuild@0.17.19: resolution: {integrity: sha512-XQ0jAPFkK/u3LcVRcvVHQcTIqD6E2H1fvZMA5dQPSOWb3suUbWbfbRf94pjc0bNzRYLfIrDRQXr7X+LHIm5oHw==} @@ -2807,8 +2810,8 @@ packages: - supports-color dev: false - /vite-plugin-ssr@0.4.136(vite@4.4.9): - resolution: {integrity: sha512-2a9huIue8AkoE2SUccVpo+9uQoEYFGdnObtRgGMyOZWaBw8mQ7jxn0k4lE66ScsfasF4B4F3UWC37sLfEneP8w==} + /vite-plugin-ssr@0.4.141(vite@4.4.9): + resolution: {integrity: sha512-mRYP7CWauioeCFWFhzNjYK/4Gv+mtfClM4oj5NZrHS3kmd2vQ/uHENOSccFZniqRTZoMzQoufqpGTd+1uT9vEg==} engines: {node: '>=16.0.0'} hasBin: true peerDependencies: @@ -2819,13 +2822,13 @@ packages: optional: true dependencies: '@brillout/import': 0.2.3 - '@brillout/json-serializer': 0.5.4 - '@brillout/picocolors': 1.0.6 + '@brillout/json-serializer': 0.5.6 + '@brillout/picocolors': 1.0.9 '@brillout/require-shim': 0.1.2 '@brillout/vite-plugin-import-build': 0.2.18 acorn: 8.10.0 cac: 6.7.14 - es-module-lexer: 0.10.5 + es-module-lexer: 1.3.1 esbuild: 0.17.19 fast-glob: 3.3.1 sirv: 2.0.3 diff --git a/vike-solid/package.json b/vike-solid/package.json index fb7c292..d14e3b5 100644 --- a/vike-solid/package.json +++ b/vike-solid/package.json @@ -20,7 +20,7 @@ }, "peerDependencies": { "solid-js": "^1.7.11", - "vite-plugin-ssr": "^0.4.136" + "vite-plugin-ssr": "^0.4.141" }, "devDependencies": { "@babel/core": "^7.22.10", @@ -36,7 +36,7 @@ "solid-js": "^1.7.11", "tslib": "^2.6.1", "typescript": "^5.1.6", - "vite-plugin-ssr": "^0.4.136" + "vite-plugin-ssr": "^0.4.141" }, "typesVersions": { "*": { diff --git a/vike-solid/renderer/+config.ts b/vike-solid/renderer/+config.ts index f6e71ce..61d06b9 100644 --- a/vike-solid/renderer/+config.ts +++ b/vike-solid/renderer/+config.ts @@ -1,40 +1,12 @@ -import type { Config as ConfigCore } from "vite-plugin-ssr/types"; -import type { Component } from "./types.js"; - -import type { Effect } from "vite-plugin-ssr/types"; - -export type Config = ConfigCore & { - /** Solid element renderer and appended into */ - Head?: Component; - Layout?: Component; - title?: string; - description?: string; - /** - * @default 'en' - */ - lang?: string; - /** - * If true, render mode is SSR or pre-rendering (aka SSG). In other words, the - * page's HTML will be rendered at build-time or request-time. - * If false, render mode is SPA. In other words, the page will only be - * rendered in the browser. - * - * See https://vite-plugin-ssr.com/render-modes - * - * @default true - * - */ - ssr?: boolean; - Page?: Component; -}; - -// alias -export type UserConfig = Config; +import type { Config, ConfigEffect } from "vite-plugin-ssr/types"; // Depending on the value of `config.meta.ssr`, set other config options' `env` // accordingly. // See https://vite-plugin-ssr.com/meta#modify-existing-configurations -const toggleSsrRelatedConfig: Effect = ({ configDefinedAt, configValue }) => { +const toggleSsrRelatedConfig: ConfigEffect = ({ + configDefinedAt, + configValue, +}) => { if (typeof configValue !== "boolean") { throw new Error(`${configDefinedAt} should be a boolean`); } @@ -80,4 +52,35 @@ export default { effect: toggleSsrRelatedConfig, }, }, -} satisfies ConfigCore; +} satisfies Config; + +// We purposely define the ConfigVikeSolid interface in this file: that way we ensure it's always applied whenever the user `import vikeSolid from 'vike-solid'` +import type { Component } from "./types.js"; +declare global { + namespace VikePackages { + export interface ConfigVikeSolid { + /** Solid element renderer and appended into */ + Head?: Component; + Layout?: Component; + title?: string; + description?: string; + /** + * @default 'en' + */ + lang?: string; + /** + * If true, render mode is SSR or pre-rendering (aka SSG). In other words, the + * page's HTML will be rendered at build-time or request-time. + * If false, render mode is SPA. In other words, the page will only be + * rendered in the browser. + * + * See https://vite-plugin-ssr.com/render-modes + * + * @default true + * + */ + ssr?: boolean; + Page?: Component; + } + } +} diff --git a/vike-solid/renderer/types.ts b/vike-solid/renderer/types.ts index 53ee7f4..b6efc2b 100644 --- a/vike-solid/renderer/types.ts +++ b/vike-solid/renderer/types.ts @@ -5,10 +5,9 @@ export type { PageProps }; export type { Page }; import type { - PageContextBuiltIn, + PageContextBuiltInServer, PageContextBuiltInClientWithClientRouting as PageContextBuiltInClient, } from "vite-plugin-ssr/types"; -import type { Config } from "./+config"; import type { JSX } from "solid-js"; export type { Component } from "solid-js"; @@ -26,9 +25,6 @@ export type PageContextCommon = { }; }; -type PageContextServer = PageContextBuiltIn & - PageContextCommon & { - config: Partial; - }; +type PageContextServer = PageContextBuiltInServer & PageContextCommon; type PageContextClient = PageContextBuiltInClient & PageContextCommon; type PageContext = PageContextClient | PageContextServer;