mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-26 23:49:51 +00:00
MDX: require fumadocs-core 16.7+
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
---
|
||||
'fumadocs-mdx': major
|
||||
---
|
||||
|
||||
**Require ESM for `next.config`**
|
||||
|
||||
Modern Node.js now supports `next.config.mts` format, compatibility layer is no longer needed.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'fumadocs-mdx': major
|
||||
---
|
||||
|
||||
Raise minimum `fumadocs-core` version to `16.7.0`
|
||||
@@ -2,6 +2,7 @@
|
||||
"name": "docs",
|
||||
"version": "0.1.3",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "pnpm build:pre && next build && pnpm build:post",
|
||||
"build:pre": "bun ./scripts/pre-build.ts",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
export default {
|
||||
plugins: {
|
||||
'@tailwindcss/postcss': {},
|
||||
},
|
||||
|
||||
@@ -7,14 +7,7 @@
|
||||
"env": {
|
||||
"builtin": true
|
||||
},
|
||||
"ignorePatterns": [
|
||||
"dist/",
|
||||
"node_modules/",
|
||||
"test/**/*.output.js",
|
||||
"bin.js",
|
||||
"loader-mdx.cjs",
|
||||
"loader-meta.cjs"
|
||||
],
|
||||
"ignorePatterns": ["dist/", "node_modules/", "test/**/*.output.js", "bin.js"],
|
||||
"rules": {
|
||||
"constructor-super": "error",
|
||||
"for-direction": "error",
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
module.exports = function loader(code) {
|
||||
const callback = this.async();
|
||||
|
||||
import('./dist/webpack/mdx.js').then((mod) => mod.default.call(this, code, callback));
|
||||
};
|
||||
@@ -1,5 +0,0 @@
|
||||
module.exports = function loader(code) {
|
||||
const callback = this.async();
|
||||
|
||||
import('./dist/webpack/meta.js').then((mod) => mod.default.call(this, code, callback));
|
||||
};
|
||||
+21
-26
@@ -12,34 +12,29 @@
|
||||
"repository": "github:fuma-nama/fumadocs",
|
||||
"bin": "./dist/bin.js",
|
||||
"files": [
|
||||
"loader-mdx.cjs",
|
||||
"loader-meta.cjs",
|
||||
"dist"
|
||||
],
|
||||
"type": "module",
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
".": "./dist/index.js",
|
||||
"./bin": "./dist/bin.js",
|
||||
"./bun": "./dist/bun/index.js",
|
||||
"./config": "./dist/config/index.js",
|
||||
"./next": "./dist/next/index.js",
|
||||
"./node": "./dist/node/index.js",
|
||||
"./node/_loader": "./dist/node/_loader.js",
|
||||
"./node/loader": "./dist/node/loader.js",
|
||||
"./plugins/index-file": "./dist/plugins/index-file.js",
|
||||
"./plugins/json-schema": "./dist/plugins/json-schema.js",
|
||||
"./plugins/last-modified": "./dist/plugins/last-modified.js",
|
||||
"./runtime/browser": "./dist/runtime/browser.js",
|
||||
"./runtime/dynamic": "./dist/runtime/dynamic.js",
|
||||
"./runtime/server": "./dist/runtime/server.js",
|
||||
"./runtime/types": "./dist/runtime/types.js",
|
||||
"./vite": "./dist/vite/index.js",
|
||||
"./webpack/mdx": "./dist/webpack/mdx.js",
|
||||
"./webpack/meta": "./dist/webpack/meta.js",
|
||||
"./package.json": "./package.json",
|
||||
"./loader-mdx": "./loader-mdx.cjs",
|
||||
"./loader-meta": "./loader-meta.cjs"
|
||||
".": "./dist/index.mjs",
|
||||
"./bin": "./dist/bin.mjs",
|
||||
"./bun": "./dist/bun/index.mjs",
|
||||
"./config": "./dist/config/index.mjs",
|
||||
"./next": "./dist/next/index.mjs",
|
||||
"./node": "./dist/node/index.mjs",
|
||||
"./node/_loader": "./dist/node/_loader.mjs",
|
||||
"./node/loader": "./dist/node/loader.mjs",
|
||||
"./plugins/index-file": "./dist/plugins/index-file.mjs",
|
||||
"./plugins/json-schema": "./dist/plugins/json-schema.mjs",
|
||||
"./plugins/last-modified": "./dist/plugins/last-modified.mjs",
|
||||
"./runtime/browser": "./dist/runtime/browser.mjs",
|
||||
"./runtime/dynamic": "./dist/runtime/dynamic.mjs",
|
||||
"./runtime/server": "./dist/runtime/server.mjs",
|
||||
"./runtime/types": "./dist/runtime/types.mjs",
|
||||
"./vite": "./dist/vite/index.mjs",
|
||||
"./webpack/mdx": "./dist/webpack/mdx.mjs",
|
||||
"./webpack/meta": "./dist/webpack/meta.mjs",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
@@ -95,11 +90,11 @@
|
||||
"@types/mdast": "*",
|
||||
"@types/mdx": "*",
|
||||
"@types/react": "*",
|
||||
"fumadocs-core": "^15.0.0 || ^16.0.0",
|
||||
"fumadocs-core": "^16.7.0",
|
||||
"mdast-util-directive": "*",
|
||||
"next": "^15.3.0 || ^16.0.0",
|
||||
"react": "^19.2.0",
|
||||
"vite": "6.x.x || 7.x.x || 8.x.x"
|
||||
"vite": "7.x.x || 8.x.x"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"mdast-util-directive": {
|
||||
|
||||
@@ -39,7 +39,6 @@ export async function loadConfig(core: Core, build = false): Promise<LoadedConfi
|
||||
// always return a new config
|
||||
url.searchParams.set('hash', Date.now().toString());
|
||||
|
||||
const config = import(url.href).then((loaded) => buildConfig(loaded as Record<string, unknown>));
|
||||
|
||||
return await config;
|
||||
const loaded = await import(url.href);
|
||||
return buildConfig(loaded as Record<string, unknown>);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ export function createMDX(createOptions: CreateMDXOptions = {}) {
|
||||
'*.{md,mdx}': {
|
||||
loaders: [
|
||||
{
|
||||
loader: 'fumadocs-mdx/loader-mdx',
|
||||
loader: 'fumadocs-mdx/webpack/mdx',
|
||||
options: loaderOptions as unknown as TurbopackLoaderOptions,
|
||||
},
|
||||
],
|
||||
@@ -62,7 +62,7 @@ export function createMDX(createOptions: CreateMDXOptions = {}) {
|
||||
'*.json': {
|
||||
loaders: [
|
||||
{
|
||||
loader: 'fumadocs-mdx/loader-meta',
|
||||
loader: 'fumadocs-mdx/webpack/meta',
|
||||
options: loaderOptions as unknown as TurbopackLoaderOptions,
|
||||
},
|
||||
],
|
||||
@@ -71,7 +71,7 @@ export function createMDX(createOptions: CreateMDXOptions = {}) {
|
||||
'*.yaml': {
|
||||
loaders: [
|
||||
{
|
||||
loader: 'fumadocs-mdx/loader-meta',
|
||||
loader: 'fumadocs-mdx/webpack/meta',
|
||||
options: loaderOptions as unknown as TurbopackLoaderOptions,
|
||||
},
|
||||
],
|
||||
@@ -96,7 +96,7 @@ export function createMDX(createOptions: CreateMDXOptions = {}) {
|
||||
use: [
|
||||
options.defaultLoaders.babel,
|
||||
{
|
||||
loader: 'fumadocs-mdx/loader-mdx',
|
||||
loader: 'fumadocs-mdx/webpack/mdx',
|
||||
options: loaderOptions,
|
||||
},
|
||||
],
|
||||
@@ -106,7 +106,7 @@ export function createMDX(createOptions: CreateMDXOptions = {}) {
|
||||
enforce: 'pre',
|
||||
use: [
|
||||
{
|
||||
loader: 'fumadocs-mdx/loader-meta',
|
||||
loader: 'fumadocs-mdx/webpack/meta',
|
||||
options: loaderOptions,
|
||||
},
|
||||
],
|
||||
|
||||
@@ -9,7 +9,7 @@ export interface NodeLoaderOptions extends Partial<CoreOptions> {
|
||||
}
|
||||
|
||||
export function register(options: NodeLoaderOptions = {}) {
|
||||
module.register('./_loader.js', import.meta.url, {
|
||||
module.register('./_loader.mjs', import.meta.url, {
|
||||
data: options,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -20,6 +20,9 @@ const configLoader = createStandaloneConfigLoader({
|
||||
const mdxLoader = toNode(createMdxLoader(configLoader));
|
||||
const metaLoader = toNode(createMetaLoader(configLoader));
|
||||
|
||||
/**
|
||||
* @deprecated use the `register()` function from `fumadocs-mdx/node` instead.
|
||||
*/
|
||||
export const load: LoadHook = (url, context, nextLoad) => {
|
||||
return mdxLoader(url, context, (v, ctx) => metaLoader(v, { ...context, ...ctx }, nextLoad));
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { type LoaderContext } from 'webpack';
|
||||
import type { LoaderDefinitionFunction } from 'webpack';
|
||||
import { createMdxLoader } from '@/loaders/mdx';
|
||||
import { toWebpack, type WebpackLoader } from '@/loaders/adapter';
|
||||
import { createStandaloneConfigLoader } from '@/loaders/config';
|
||||
@@ -6,11 +6,8 @@ import { getCore, type WebpackLoaderOptions } from '@/webpack';
|
||||
|
||||
let instance: WebpackLoader | undefined;
|
||||
|
||||
export default async function loader(
|
||||
this: LoaderContext<WebpackLoaderOptions>,
|
||||
source: string,
|
||||
callback: LoaderContext<WebpackLoaderOptions>['callback'],
|
||||
): Promise<void> {
|
||||
const loader: LoaderDefinitionFunction<WebpackLoaderOptions> = function loader(source) {
|
||||
const callback = this.async();
|
||||
const options = this.getOptions();
|
||||
this.cacheable(true);
|
||||
this.addDependency(options.absoluteCompiledConfigPath);
|
||||
@@ -27,5 +24,7 @@ export default async function loader(
|
||||
);
|
||||
}
|
||||
|
||||
await instance.call(this, source, callback);
|
||||
}
|
||||
void instance.call(this, source, callback);
|
||||
};
|
||||
|
||||
export default loader;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { type LoaderContext } from 'webpack';
|
||||
import { LoaderDefinitionFunction } from 'webpack';
|
||||
import { toWebpack, type WebpackLoader } from '@/loaders/adapter';
|
||||
import { createStandaloneConfigLoader } from '@/loaders/config';
|
||||
import { createMetaLoader } from '@/loaders/meta';
|
||||
@@ -6,11 +6,8 @@ import { getCore, type WebpackLoaderOptions } from '@/webpack';
|
||||
|
||||
let instance: WebpackLoader | undefined;
|
||||
|
||||
export default async function loader(
|
||||
this: LoaderContext<WebpackLoaderOptions>,
|
||||
source: string,
|
||||
callback: LoaderContext<WebpackLoaderOptions>['callback'],
|
||||
): Promise<void> {
|
||||
const loader: LoaderDefinitionFunction<WebpackLoaderOptions> = function (source) {
|
||||
const callback = this.async();
|
||||
const options = this.getOptions();
|
||||
this.cacheable(true);
|
||||
this.addDependency(options.absoluteCompiledConfigPath);
|
||||
@@ -31,5 +28,7 @@ export default async function loader(
|
||||
);
|
||||
}
|
||||
|
||||
await instance.call(this, source, callback);
|
||||
}
|
||||
void instance.call(this, source, callback);
|
||||
};
|
||||
|
||||
export default loader;
|
||||
|
||||
@@ -1,14 +1,5 @@
|
||||
import { defineConfig } from 'tsdown';
|
||||
|
||||
const external = ['next', 'typescript', 'webpack', 'bun', 'mdx/types'];
|
||||
|
||||
const noExternal = [
|
||||
// TODO: remove this when the min `fumadocs-core` version is above 16.2.3
|
||||
'fumadocs-core/source/schema',
|
||||
// TODO: remove this when the min `fumadocs-core` version is above 16.6.17
|
||||
'fumadocs-core/mdx-plugins/remark-llms',
|
||||
];
|
||||
|
||||
export default defineConfig({
|
||||
entry: [
|
||||
'./src/{index,bin}.ts',
|
||||
@@ -19,18 +10,13 @@ export default defineConfig({
|
||||
'./src/plugins/*.ts',
|
||||
],
|
||||
format: 'esm',
|
||||
dts: true,
|
||||
fixedExtension: false,
|
||||
target: 'node22',
|
||||
exports: {
|
||||
customExports: {
|
||||
'./loader-mdx': './loader-mdx.cjs',
|
||||
'./loader-meta': './loader-meta.cjs',
|
||||
},
|
||||
dts: {
|
||||
sourcemap: false,
|
||||
},
|
||||
target: 'node22',
|
||||
exports: true,
|
||||
deps: {
|
||||
onlyBundle: noExternal,
|
||||
alwaysBundle: noExternal,
|
||||
neverBundle: external,
|
||||
onlyBundle: [],
|
||||
neverBundle: ['webpack', 'bun'],
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user