mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-26 23:49:51 +00:00
MDX: Fix alias imports
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'fumadocs-mdx': patch
|
||||
---
|
||||
|
||||
Fix alias imports
|
||||
@@ -45,10 +45,10 @@
|
||||
"@mdx-js/mdx": "^3.1.0",
|
||||
"chokidar": "^4.0.3",
|
||||
"cross-spawn": "^7.0.6",
|
||||
"esbuild": "^0.24.2",
|
||||
"estree-util-value-to-estree": "^3.2.1",
|
||||
"fast-glob": "^3.3.1",
|
||||
"gray-matter": "^4.0.3",
|
||||
"jiti": "^2.4.2",
|
||||
"micromatch": "^4.0.8",
|
||||
"unist-util-visit": "^5.0.0",
|
||||
"zod": "^3.24.1"
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import * as path from 'node:path';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
import { createJiti } from 'jiti';
|
||||
import type { DocCollection, MetaCollection } from '@/config/define';
|
||||
import { type GlobalConfig } from '@/config/types';
|
||||
import type { ProcessorOptions } from '@mdx-js/mdx';
|
||||
import { getDefaultMDXOptions } from '@/utils/mdx-options';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
|
||||
export function findConfigFile(): string {
|
||||
return path.resolve('source.config.ts');
|
||||
@@ -26,20 +25,36 @@ export interface LoadedConfig {
|
||||
export type InternalDocCollection = DocCollection;
|
||||
export type InternalMetaCollection = MetaCollection;
|
||||
|
||||
const jiti = createJiti(import.meta.url, {
|
||||
moduleCache: false,
|
||||
});
|
||||
|
||||
export async function loadConfig(configPath: string): Promise<LoadedConfig> {
|
||||
const imported = await jiti
|
||||
.import(pathToFileURL(configPath).href)
|
||||
.catch((e) => {
|
||||
throw new Error('failed to compile configuration file', e);
|
||||
});
|
||||
const outputPath = path.resolve('.source/source.config.mjs');
|
||||
const { build } = await import('esbuild');
|
||||
const transformed = await build({
|
||||
entryPoints: [{ in: configPath, out: 'source.config' }],
|
||||
bundle: true,
|
||||
outdir: '.source',
|
||||
target: 'node18',
|
||||
write: true,
|
||||
platform: 'node',
|
||||
format: 'esm',
|
||||
packages: 'external',
|
||||
outExtension: {
|
||||
'.js': '.mjs',
|
||||
},
|
||||
allowOverwrite: true,
|
||||
splitting: true,
|
||||
});
|
||||
|
||||
if (transformed.errors.length > 0) {
|
||||
throw new Error('failed to compile configuration file');
|
||||
}
|
||||
|
||||
const url = pathToFileURL(outputPath);
|
||||
const [err, config] = buildConfig(
|
||||
// every call to `loadConfig` will cause the previous cache to be ignored
|
||||
imported as Record<string, unknown>,
|
||||
(await import(`${url.href}?hash=${Date.now().toString()}`)) as Record<
|
||||
string,
|
||||
unknown
|
||||
>,
|
||||
);
|
||||
|
||||
if (err !== null) throw new Error(err);
|
||||
|
||||
Generated
+5
-4
@@ -773,6 +773,9 @@ importers:
|
||||
cross-spawn:
|
||||
specifier: ^7.0.6
|
||||
version: 7.0.6
|
||||
esbuild:
|
||||
specifier: ^0.24.2
|
||||
version: 0.24.2
|
||||
estree-util-value-to-estree:
|
||||
specifier: ^3.2.1
|
||||
version: 3.2.1
|
||||
@@ -782,9 +785,6 @@ importers:
|
||||
gray-matter:
|
||||
specifier: ^4.0.3
|
||||
version: 4.0.3
|
||||
jiti:
|
||||
specifier: ^2.4.2
|
||||
version: 2.4.2
|
||||
micromatch:
|
||||
specifier: ^4.0.8
|
||||
version: 4.0.8
|
||||
@@ -10358,7 +10358,8 @@ snapshots:
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
[email protected]: {}
|
||||
[email protected]:
|
||||
optional: true
|
||||
|
||||
[email protected]: {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user