From a44652419663f4030e2cc41f51794736a4775240 Mon Sep 17 00:00:00 2001 From: Romuald Brillout Date: Fri, 17 Nov 2023 12:27:39 +0100 Subject: [PATCH] fix: use latest version of the Vike V1 design --- examples/basic/package.json | 2 +- examples/ssr-spa/package.json | 2 +- pnpm-lock.yaml | 22 +++++++++++----------- vike-solid/package.json | 4 ++-- vike-solid/renderer/+config.ts | 18 +++++++++--------- vike-solid/renderer/+onRenderHtml.tsx | 14 +++++++++++++- 6 files changed, 37 insertions(+), 25 deletions(-) diff --git a/examples/basic/package.json b/examples/basic/package.json index 49ea529..73d7984 100644 --- a/examples/basic/package.json +++ b/examples/basic/package.json @@ -11,7 +11,7 @@ "node-fetch": "^3.3.2", "solid-js": "^1.7.11", "vike-solid": "workspace:*", - "vike": "^0.4.144" + "vike": "^0.4.147" }, "devDependencies": { "typescript": "^5.1.6" diff --git a/examples/ssr-spa/package.json b/examples/ssr-spa/package.json index 4f8c4be..f703eb7 100644 --- a/examples/ssr-spa/package.json +++ b/examples/ssr-spa/package.json @@ -9,7 +9,7 @@ "dependencies": { "solid-js": "^1.7.11", "vike-solid": "workspace:*", - "vike": "^0.4.144" + "vike": "^0.4.147" }, "devDependencies": { "typescript": "^5.1.6" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c9d0b37..7dbe819 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,8 +20,8 @@ importers: specifier: ^1.7.11 version: 1.7.11 vike: - specifier: ^0.4.144 - version: 0.4.144(vite@4.5.0) + specifier: ^0.4.147 + version: 0.4.147(vite@4.5.0) vike-solid: specifier: workspace:* version: link:../../vike-solid @@ -36,8 +36,8 @@ importers: specifier: ^1.7.11 version: 1.7.11 vike: - specifier: ^0.4.144 - version: 0.4.144(vite@4.5.0) + specifier: ^0.4.147 + version: 0.4.147(vite@4.5.0) vike-solid: specifier: workspace:* version: link:../../vike-solid @@ -92,8 +92,8 @@ importers: specifier: ^5.2.2 version: 5.2.2 vike: - specifier: ^0.4.144 - version: 0.4.144(vite@4.5.0) + specifier: ^0.4.147 + version: 0.4.147(vite@4.5.0) vite: specifier: ^4.5.0 version: 4.5.0(@types/node@18.17.4) @@ -1324,8 +1324,8 @@ packages: /@brillout/import@0.2.3: resolution: {integrity: sha512-1T8WlD75eeFSMrptGy8jiLHmfHgMmSjWvLOIUvHmSVZt+6k0eQqYUoK4KbmE4T9pVLIfxvZSOm2D68VEqKRHRw==} - /@brillout/json-serializer@0.5.6: - resolution: {integrity: sha512-48u+Wthh0muDueyooi/Or59DDFCPitnuCN9OkMWoj7MQAbDn5pS/cVBB7ds6ENmtC1Qb0spI4PfKZxQSBEkubg==} + /@brillout/json-serializer@0.5.8: + resolution: {integrity: sha512-vEuXw30ok+mJfJutOxXKBb4lBJ0HymA7lev9PcYK6W/hzjhCTPk9Bdk85HrcNcKZWRQiwoWtw0F2Di4TRJ7ssQ==} /@brillout/picocolors@1.0.9: resolution: {integrity: sha512-Lt/W5JsA75hcDJ2cOAlE4TqSMl6c9K+rXGRo/cU2fApnmhbRcNdkR4UHQDAwtWfZyUKWaxdwSui+jp+74J1pZg==} @@ -2962,8 +2962,8 @@ packages: /validate-html-nesting@1.2.2: resolution: {integrity: sha512-hGdgQozCsQJMyfK5urgFcWEqsSSrK63Awe0t/IMR0bZ0QMtnuaiHzThW81guu3qx9abLi99NEuiaN6P9gVYsNg==} - /vike@0.4.144(vite@4.5.0): - resolution: {integrity: sha512-smvBXv33IhP5FHOvoBYZuir/Zip93AoBGqiIdmWHva1RYeQDFlXQMbs/YZ5HqFc7OrL8cL3K7iUsEC6t/pF+/Q==} + /vike@0.4.147(vite@4.5.0): + resolution: {integrity: sha512-TNkIJY+jydz3cL4UGT58annjIAH7a5Rv0hu5clMMuBnC39S5ArsCF0mAZrHKsMa5mV6HwlW6j3mmVWw2kKVcBw==} engines: {node: '>=16.0.0'} hasBin: true peerDependencies: @@ -2974,7 +2974,7 @@ packages: optional: true dependencies: '@brillout/import': 0.2.3 - '@brillout/json-serializer': 0.5.6 + '@brillout/json-serializer': 0.5.8 '@brillout/picocolors': 1.0.9 '@brillout/require-shim': 0.1.2 '@brillout/vite-plugin-import-build': 0.2.20 diff --git a/vike-solid/package.json b/vike-solid/package.json index 80b44d8..8c7794f 100644 --- a/vike-solid/package.json +++ b/vike-solid/package.json @@ -20,7 +20,7 @@ "peerDependencies": { "solid-js": "^1.8.5", "vite": "^4.5.0", - "vike": "^0.4.144" + "vike": "^0.4.147" }, "devDependencies": { "@babel/core": "^7.23.3", @@ -37,7 +37,7 @@ "tslib": "^2.6.2", "typescript": "^5.2.2", "vite": "^4.5.0", - "vike": "^0.4.144" + "vike": "^0.4.147" }, "typesVersions": { "*": { diff --git a/vike-solid/renderer/+config.ts b/vike-solid/renderer/+config.ts index e7e78d1..92f14c7 100644 --- a/vike-solid/renderer/+config.ts +++ b/vike-solid/renderer/+config.ts @@ -19,8 +19,8 @@ const toggleSsrRelatedConfig: ConfigEffect = ({ // accessible only in the client's renderer. Page: { env: configValue - ? "server-and-client" // default - : "client-only", + ? { server: true, client: true } // default + : { client: true }, }, }, }; @@ -42,25 +42,25 @@ export default { hydrationCanBeAborted: true, meta: { Head: { - env: "server-only", + env: { server: true }, }, Layout: { - env: "server-and-client", + env: { server: true, client: true }, }, title: { - env: "server-and-client", + env: { server: true, client: true }, }, description: { - env: "server-only", + env: { server: true }, }, favicon: { - env: "server-only", + env: { server: true }, }, lang: { - env: "server-only", + env: { server: true }, }, ssr: { - env: "config-only", + env: { config: true }, effect: toggleSsrRelatedConfig, }, }, diff --git a/vike-solid/renderer/+onRenderHtml.tsx b/vike-solid/renderer/+onRenderHtml.tsx index cd9e12c..8cc3195 100644 --- a/vike-solid/renderer/+onRenderHtml.tsx +++ b/vike-solid/renderer/+onRenderHtml.tsx @@ -6,12 +6,14 @@ import { renderToStream, renderToString, } from "solid-js/web"; -import { dangerouslySkipEscape, escapeInject, stampPipe } from "vike/server"; +import { dangerouslySkipEscape, escapeInject, stampPipe, version } from "vike/server"; import { getTitle } from "./getTitle"; import { getPageElement } from "./getPageElement"; import type { OnRenderHtmlAsync } from "vike/types"; import { PageContextProvider } from "./PageContextProvider"; +checkVikeVersion() + const onRenderHtml: OnRenderHtmlAsync = async ( pageContext ): ReturnType => { @@ -63,3 +65,13 @@ const onRenderHtml: OnRenderHtmlAsync = async ( return documentHtml; }; + +function checkVikeVersion() { + if (version) { + const versionParts = version.split('.').map((s) => parseInt(s, 10)) as [number, number, number] + if (versionParts[0] > 0) return + if (versionParts[1] > 4) return + if (versionParts[2] >= 147) return + } + throw new Error('Update Vike to its latest version (or vike@0.4.147 and any version above)') +}