mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-25 04:20:02 +00:00
`@hanzo/docs-mdx` writes the collection modules to its outDir, `.docs/`.
Nothing read them there. Apps read a committed `docs/` copy instead, reached
three different ways:
13 apps `@hanzo/mdx:collections/server` + a webpack alias -> ./docs/*.ts
3 apps `@/docs/server`, straight into the committed copy
2 apps the alias, with no committed copy at all
The two with no copy — bootnode-docs and tasks-docs — could not build:
./lib/source.tsx
Module not found: Can't resolve '@hanzo/mdx:collections/server'
and four more built from a copy that no longer matched the content beside it:
./docs/server.ts
Module not found: Can't resolve
'../content/docs/reference/templates/USER.mdx?collection=docs&only=frontmatter'
That is what committing generated code buys: the build reads a snapshot of
the content rather than the content.
One name, one location, every app: `@hanzo/mdx:collections/*`, resolved to
`.docs/` — the generator's own output, rewritten on every build, gitignored.
`tsconfig` gains the matching `paths` entry so the specifier type-checks
instead of relying on `ignoreBuildErrors`; apps/docs stops overriding outDir
in both `next.config.mts` and `gen:collections`; turbo caches `.docs/**`. The
16 committed mirrors are deleted. Examples already did it this way.
`.source` goes with them — this fork's outDir has been `.docs` for a while,
leaving `.source` in the vite plugin's JSDoc, an example's import map, an
oxlint ignore and `.gitignore` pointing at a directory nothing writes.
Also declares in `globalEnv` the env vars the build scripts actually read
(HANZO_DOCS_SYNC, HIPS_REPO_DIR, DOCS_SECTION, the search vars...). Turbo
does not forward undeclared vars, so `HANZO_DOCS_SYNC=0 turbo run build` had
no effect on the sync it names.
turbo run build --filter='./apps/*' --continue
before Tasks: 33 successful, 40 total
Failed: bootnode-docs, docs, engine-docs, ml-docs, router-docs,
spec, tasks-docs
after Tasks: 38 successful, 40 total
Failed: docs, spec (both for unrelated reasons, fixed next)
(cherry picked from commit 3d11394b092530489b60931e46b4938a88a2bdd5)
Co-authored-by: Hanzo Dev <[email protected]>
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import { resolve } from 'path';
|
|
import createBundleAnalyzer from '@next/bundle-analyzer';
|
|
import { createMDX } from '@hanzo/docs/mdx/next';
|
|
import type { NextConfig } from 'next';
|
|
|
|
const withAnalyzer = createBundleAnalyzer({
|
|
enabled: process.env.ANALYZE === 'true',
|
|
});
|
|
|
|
const config: NextConfig = {
|
|
output: 'export',
|
|
reactStrictMode: true,
|
|
typescript: {
|
|
// Types resolve correctly at runtime via docsLazy/AsyncDocCollectionEntry
|
|
// but TS inference breaks on the complex MDX runtime generics chain
|
|
ignoreBuildErrors: true,
|
|
},
|
|
webpack: (config) => {
|
|
config.resolve.alias = {
|
|
...config.resolve.alias,
|
|
'@hanzo/mdx:collections/server': resolve(__dirname, './.docs/server.ts'),
|
|
'@hanzo/mdx:collections/browser': resolve(__dirname, './.docs/browser.ts'),
|
|
'@hanzo/mdx:collections/dynamic': resolve(__dirname, './.docs/dynamic.ts'),
|
|
};
|
|
return config;
|
|
},
|
|
logging: {
|
|
fetches: {
|
|
fullUrl: true,
|
|
},
|
|
},
|
|
serverExternalPackages: [
|
|
'shiki',
|
|
],
|
|
images: {
|
|
unoptimized: true,
|
|
},
|
|
};
|
|
|
|
const withMDX = createMDX();
|
|
|
|
export default withAnalyzer(withMDX(config as any) as NextConfig);
|