mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-25 04:20:02 +00:00
Core: Add framework adapters to optional peer deps
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'fumadocs-mdx': patch
|
||||
---
|
||||
|
||||
Add Vite config for Fumadocs Core & UI automatically
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'fumadocs-core': patch
|
||||
---
|
||||
|
||||
Add framework adapters to optional peer deps
|
||||
@@ -157,6 +157,33 @@ export const source = loader({
|
||||
|
||||
</Accordions>
|
||||
|
||||
### For Vite
|
||||
|
||||
<Accordions>
|
||||
<Accordion id='vite-context-error' title="Getting error with React contexts?">
|
||||
|
||||
There's some weird pre-bundling problems with Vite: [#3910](https://github.com/vitejs/vite/issues/3910).
|
||||
Make sure to exclude Fumadocs from pre-bundling and add it to `noExternal`:
|
||||
|
||||
```ts title="vite.config.ts"
|
||||
import { defineConfig } from 'vite';
|
||||
|
||||
// add other Fumadocs deps as needed
|
||||
const FumadocsDeps = ['fumadocs-core', 'fumadocs-ui'];
|
||||
|
||||
export default defineConfig({
|
||||
resolve: {
|
||||
noExternal: FumadocsDeps,
|
||||
},
|
||||
optimizeDeps: {
|
||||
exclude: FumadocsDeps,
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
</Accordion>
|
||||
</Accordions>
|
||||
|
||||
### For Next.js
|
||||
|
||||
<Accordions>
|
||||
|
||||
@@ -4,7 +4,6 @@ import * as MdxConfig from './source.config.js';
|
||||
|
||||
export default defineConfig({
|
||||
vite: {
|
||||
// avoid type problems due to Vite version conflicts
|
||||
plugins: [mdx(MdxConfig) as any],
|
||||
plugins: [mdx(MdxConfig)],
|
||||
},
|
||||
});
|
||||
|
||||
@@ -149,6 +149,8 @@
|
||||
"next": "14.x.x || 15.x.x",
|
||||
"react": "18.x.x || 19.x.x",
|
||||
"react-dom": "18.x.x || 19.x.x",
|
||||
"waku": "^0.26.0",
|
||||
"@tanstack/react-router": "1.x.x",
|
||||
"react-router": "7.x.x"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
@@ -175,6 +177,12 @@
|
||||
},
|
||||
"react-router": {
|
||||
"optional": true
|
||||
},
|
||||
"waku": {
|
||||
"optional": true
|
||||
},
|
||||
"@tanstack/react-router": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"publishConfig": {
|
||||
|
||||
@@ -4,7 +4,6 @@ import * as MdxConfig from './source.config.js';
|
||||
|
||||
export default defineConfig({
|
||||
vite: {
|
||||
// avoid type problems due to Vite version conflicts
|
||||
plugins: [mdx(MdxConfig) as any],
|
||||
plugins: [mdx(MdxConfig)],
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import type { Environment, Plugin, TransformResult } from 'vite';
|
||||
import {
|
||||
type Environment,
|
||||
mergeConfig,
|
||||
type Plugin,
|
||||
type TransformResult,
|
||||
type UserConfig,
|
||||
} from 'vite';
|
||||
import { buildConfig } from '@/config/build';
|
||||
import { buildMDX } from '@/utils/build-mdx';
|
||||
import { parse } from 'node:querystring';
|
||||
@@ -14,6 +20,8 @@ import type { SourceMap, TransformPluginContext } from 'rollup';
|
||||
import { getGitTimestamp } from '@/utils/git-timestamp';
|
||||
import { doc, docs, meta } from '@/vite/generate';
|
||||
|
||||
const FumadocsDeps = ['fumadocs-core', 'fumadocs-ui', 'fumadocs-openapi'];
|
||||
|
||||
const querySchema = z
|
||||
.object({
|
||||
only: z.literal(['frontmatter', 'all']).default('all'),
|
||||
@@ -179,6 +187,17 @@ export default function mdx(
|
||||
name: 'fumadocs-mdx',
|
||||
// needed, otherwise other plugins will be executed before our `transform`.
|
||||
enforce: 'pre',
|
||||
config(config) {
|
||||
return mergeConfig(config, {
|
||||
optimizeDeps: {
|
||||
exclude: FumadocsDeps,
|
||||
},
|
||||
resolve: {
|
||||
noExternal: FumadocsDeps,
|
||||
dedupe: FumadocsDeps,
|
||||
},
|
||||
} satisfies UserConfig);
|
||||
},
|
||||
async buildStart() {
|
||||
if (!generateIndexFile) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user