From 958022dd563dc33882eaf978520d331e68b7a4ac Mon Sep 17 00:00:00 2001 From: Diego Diaz Date: Thu, 29 Oct 2026 22:58:19 -0500 Subject: [PATCH] =?UTF-8?q?fix(website):=20=F0=9F=90=9B=20render=20the=20c?= =?UTF-8?q?hangelog=20after=20a=20client-side=20navigation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reaching /docs/changelog/ through a , or using its filters, left the page empty: Rolldown put the release notes in a chunk that imports the changelog's chunk back, so the version list, built when the module loaded, read the notes before they were initialized ("Cannot read properties of undefined"). The page now reads the notes from its own module and builds the list when it renders. --- website/README.md | 2 +- website/src/lib/release-notes.ts | 8 ---- website/src/routes/docs/changelog/index.tsx | 50 ++++++++++++--------- 3 files changed, 31 insertions(+), 29 deletions(-) delete mode 100644 website/src/lib/release-notes.ts diff --git a/website/README.md b/website/README.md index dbe44cf..85af7f9 100644 --- a/website/README.md +++ b/website/README.md @@ -26,7 +26,7 @@ dist-tags and dates are read from the npm registry when the site builds (`vite.c unreleased; in CI (`CI` set) the build fails instead. The changelog's notes are the published GitHub releases, as GitHub renders them (`vite.config.ts` → -`src/lib/github.ts` → `src/lib/release-notes.ts`): to change what the site says about a version, edit +`src/lib/github.ts` → `src/routes/docs/changelog/`): to change what the site says about a version, edit its release on GitHub and redeploy. A release is a draft until its version is approved on npm, so the site never shows notes for a version that isn't out (see `CONTRIBUTING.md` → Releases). Set `GITHUB_TOKEN` to read them with a token. Offline or rate-limited, a local or preview build goes on diff --git a/website/src/lib/release-notes.ts b/website/src/lib/release-notes.ts deleted file mode 100644 index f40360b..0000000 --- a/website/src/lib/release-notes.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { Releases } from "./github"; - -// The notes of each GitHub release: vite.config.ts reads them when the site builds and defines `__RELEASES__` with -// them. A module of its own, so only the changelog carries them. - -declare const __RELEASES__: Releases; - -export const RELEASES: Releases = __RELEASES__; diff --git a/website/src/routes/docs/changelog/index.tsx b/website/src/routes/docs/changelog/index.tsx index 4012ac3..96e58e8 100644 --- a/website/src/routes/docs/changelog/index.tsx +++ b/website/src/routes/docs/changelog/index.tsx @@ -1,7 +1,7 @@ import { component$, useSignal } from "@qwik.dev/core"; import { Link, type DocumentHead } from "@qwik.dev/router"; +import type { Releases } from "~/lib/github"; import { majorOf, newestFirst, NPM, tagsOf } from "~/lib/release"; -import { RELEASES } from "~/lib/release-notes"; import { GITHUB_URL, NPM_URL } from "~/lib/versions"; import styles from "../pages.module.css"; @@ -14,24 +14,33 @@ const FILTERS = [ type Filter = (typeof FILTERS)[number]["id"]; +// The notes of each GitHub release: vite.config.ts reads them when the site +// builds and defines `__RELEASES__` with them, so only this page carries them. +declare const __RELEASES__: Releases; +const RELEASES: Releases = __RELEASES__; + // Every version on npm, newest first, with its notes from the GitHub release -// of its tag; versions, tags and days come from npm. -const VERSIONS = Object.keys(NPM.dates) - .sort(newestFirst) - .map((version, index, all) => { - const major = majorOf(version); - return { - version, - major, - date: NPM.dates[version], - tags: tagsOf(NPM, version), - notes: RELEASES[version] ?? null, - /** the version before it, for the commits between both */ - previous: all[index + 1] ?? null, - /** the newest version of its major carries the link to that major's docs */ - newestOfMajor: all.findIndex((other) => majorOf(other) === major) === index, - }; - }); +// of its tag; versions, tags and days come from npm. Built when the page +// renders, not when the module loads: in the client build Rolldown can put the +// modules this reads in a chunk that imports this one back, and a module-level +// read would run before they're initialized (an empty page after a ). +const versionsOf = () => + Object.keys(NPM.dates) + .sort(newestFirst) + .map((version, index, all) => { + const major = majorOf(version); + return { + version, + major, + date: NPM.dates[version], + tags: tagsOf(NPM, version), + notes: RELEASES[version] ?? null, + /** the version before it, for the commits between both */ + previous: all[index + 1] ?? null, + /** the newest version of its major carries the link to that major's docs */ + newestOfMajor: all.findIndex((other) => majorOf(other) === major) === index, + }; + }); const formatDate = (iso: string) => new Date(`${iso}T12:00:00Z`).toLocaleDateString("en-US", { @@ -44,7 +53,8 @@ const formatDate = (iso: string) => export default component$(() => { const filter = useSignal("all"); - const visible = VERSIONS.filter((v) => filter.value === "all" || v.major === filter.value); + const versions = versionsOf(); + const visible = versions.filter((v) => filter.value === "all" || v.major === filter.value); return ( <> @@ -76,7 +86,7 @@ export default component$(() => { ))} - {VERSIONS.length === 0 ? ( + {versions.length === 0 ? (

npm couldn't be read when this page was built, so there are no versions to show.