commit df3f565283a607a6b2c16db196b8c2011d1c2b60
parent c987982bb2a6ffcfe719aaff7f7b8d167c0fc43b
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 22 Jun 2026 18:48:09 -0400
Fix editor build: keep node:fs out of the homepage client bundle
PageEditor.tsx ("use client") imported the value HOMEPAGE_INDEX_SLUG
from lib/homepage.ts, which pulls in node:fs (config IO) — Turbopack's
client chunking context rejects external modules, failing the editor
build. Split the pure constants/types/validators into a new fs-free
lib/homepageConstants.ts; homepage.ts re-exports them for server
callers, and the client PageEditor imports from the pure module.
Verified: editor `next build` passes; common typechecks.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat:
3 files changed, 37 insertions(+), 20 deletions(-)
diff --git a/common/lib/homepage.ts b/common/lib/homepage.ts
@@ -7,7 +7,19 @@ import {
type SiteSettings,
type SocialLink,
} from "./settings";
-import { SITE_ID_RE } from "./site";
+import {
+ isValidHomepageSlug,
+ type HomepageNavItem,
+} from "./homepageConstants";
+
+// Re-export the pure constants/types so server callers can keep importing them
+// from "lib/homepage"; client components must import from "lib/homepageConstants"
+// directly to stay fs-free.
+export {
+ HOMEPAGE_INDEX_SLUG,
+ isValidHomepageSlug,
+ type HomepageNavItem,
+} from "./homepageConstants";
// The Archilyzer hub/homepage is a SINGLE, instance-level marketing + docs site
// (the `homepage` SSG package) that sits above the per-content sites. Unlike a
@@ -18,15 +30,6 @@ import { SITE_ID_RE } from "./site";
// homepageConfigFile (sites/_homepage/homepage.json); operational config stays
// global in settings.json.
-// One nav/page entry. `slug` is the page id (and URL segment); the Markdown body
-// is stored separately at homepagePagesDir/<slug>.md (see homepagePages.ts). The
-// nav array is the single source of truth for page ORDER and link LABEL.
-export type HomepageNavItem = {
- slug: string;
- label: string;
- order?: number;
-};
-
export type HomepageConfig = {
siteTitle: string;
siteDescription: string;
@@ -45,15 +48,6 @@ export type HomepageConfig = {
cloudflareProject?: string;
};
-// The canonical home page slug. The home route renders this page's body (if it
-// exists) and it is never given its own "/<slug>" route.
-export const HOMEPAGE_INDEX_SLUG = "index";
-
-// Page slugs share the site-id grammar (lowercase slug, safe as a file/URL name).
-export function isValidHomepageSlug(slug: unknown): slug is string {
- return typeof slug === "string" && SITE_ID_RE.test(slug);
-}
-
function defaults(): HomepageConfig {
return {
siteTitle: "Archilyzer",
diff --git a/common/lib/homepageConstants.ts b/common/lib/homepageConstants.ts
@@ -0,0 +1,23 @@
+// Pure (fs-free) homepage constants, types, and validators — safe to import from
+// CLIENT components. The filesystem-backed config/page IO lives in homepage.ts
+// and homepagePages.ts (server only); importing those into a client bundle would
+// drag `node:fs` in and break the Turbopack client build.
+
+// The canonical home page slug: its body renders at "/", never at "/<slug>".
+export const HOMEPAGE_INDEX_SLUG = "index";
+
+// Page/nav slug grammar: a lowercase slug, safe as a file and URL segment.
+// Mirrors SITE_ID_RE in site.ts (kept inline here so this module pulls no fs).
+const HOMEPAGE_SLUG_RE = /^[a-z0-9][a-z0-9-]*$/;
+
+export function isValidHomepageSlug(slug: unknown): slug is string {
+ return typeof slug === "string" && HOMEPAGE_SLUG_RE.test(slug);
+}
+
+// One nav/page entry. The Markdown body is stored separately (homepagePages.ts);
+// the nav array is the single source of truth for page ORDER and link LABEL.
+export type HomepageNavItem = {
+ slug: string;
+ label: string;
+ order?: number;
+};
diff --git a/editor/app/homepage/PageEditor.tsx b/editor/app/homepage/PageEditor.tsx
@@ -6,7 +6,7 @@ import Markdown from "markdown-to-jsx";
import {
HOMEPAGE_INDEX_SLUG,
type HomepageNavItem,
-} from "yt-dlp-transcript-common/lib/homepage";
+} from "yt-dlp-transcript-common/lib/homepageConstants";
import {
saveHomepagePageAction,
deleteHomepagePageAction,