fix(docs): generate .source at build time, and load it the way the runtime expects

With the lockfile resynced the docs job got past install and failed at build:

    Module not found: Can't resolve './.source'   (from lib/source.ts)

.source is GENERATED and gitignored, and this package had no step that produced
it — `build` was a bare `next build` and there was no postinstall. It only ever
worked where a stale .source happened to be lying around, which is why a laptop
built it and a fresh checkout never could.

Three things, each found by making the previous one fail differently:

1. Nothing generated .source. Now `hanzo-mdx source.config.ts .source` runs in
   both build and postinstall, the shape luxfi/consensus already uses.

2. `import { docs } from "@/.source"` is a DIRECTORY import and the generator
   emits no index — it writes browser.ts / dynamic.ts / server.ts. consensus
   imports "@/.source/server"; so does this now.

3. `docs.toFumadocsSource()` did not exist, and neither did `toSource()` — the
   generated code targets `@hanzo/docs/mdx/runtime/server`, while lib/source.ts
   pulled its loader from `fumadocs-core`, mixing two stacks. It resolved
   @hanzo/docs 16.2.7 where consensus runs 16.4.x and works. Loader now comes
   from `@hanzo/docs/core/source` with `toSource()`, and the range is pinned
   ^16.4.1 to match consensus rather than left to drift.

Verified as a fresh checkout would run it — node_modules and .source deleted
first:

    pnpm install --frozen-lockfile   OK
    .source after install            generated by postinstall
    pnpm build                       OK

Only docs/ is touched; the dashboard/ work in this tree is left alone.

Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
2026-08-02 06:22:34 -07:00
co-authored by Hanzo Dev
parent 760f491735
commit 7025aff29b
3 changed files with 3240 additions and 1089 deletions
+6 -15
View File
@@ -1,16 +1,7 @@
import { docs } from "@/.source"
import { loader } from "fumadocs-core/source"
import { docs } from "@/.source/server"
import { loader } from "@hanzo/docs/core/source"
let _source: ReturnType<typeof loader> | null = null
export function getSource() {
if (!_source) {
_source = loader({
baseUrl: "/docs",
source: docs.toFumadocsSource(),
})
}
return _source
}
export const source = getSource()
export const source = loader({
baseUrl: "/docs",
source: docs.toSource(),
})
+6 -5
View File
@@ -4,15 +4,16 @@
"private": true,
"scripts": {
"dev": "next dev --port 3022",
"build": "next build",
"build": "hanzo-mdx source.config.ts .source && next build",
"export": "TURBOPACK=0 next build",
"start": "next start",
"lint": "next lint"
"lint": "next lint",
"postinstall": "hanzo-mdx source.config.ts .source"
},
"dependencies": {
"@hanzo/docs": "^16.2.0",
"@hanzo/docs-core": "^16.2.0",
"@hanzo/mdx": "^14.2.0",
"@hanzo/docs": "^16.4.1",
"@hanzo/docs-core": "^16.9.3",
"@hanzo/mdx": "^14.2.5",
"@hanzo/ui": "^5.3.28",
"fumadocs-core": "^15.0.0",
"fumadocs-mdx": "^12.0.0",
+3228 -1069
View File
File diff suppressed because it is too large Load Diff