fumadocs-mdx
Version:
The built-in source for Fumadocs
38 lines (36 loc) • 1.14 kB
JavaScript
import { t as buildConfig } from "./build-BTTNEFmV.js";
import { pathToFileURL } from "node:url";
//#region src/config/load-from-file.ts
async function compileConfig(core) {
const { build } = await import("esbuild");
const { configPath, outDir } = core.getOptions();
if ((await build({
entryPoints: [{
in: configPath,
out: "source.config"
}],
bundle: true,
outdir: outDir,
target: "node20",
write: true,
platform: "node",
format: "esm",
packages: "external",
outExtension: { ".js": ".mjs" },
allowOverwrite: true
})).errors.length > 0) throw new Error("failed to compile configuration file");
}
/**
* Load config
*
* @param build - By default, it assumes the config file has been compiled. Set this `true` to compile the config first.
*/
async function loadConfig(core, build = false) {
if (build) await compileConfig(core);
const url = pathToFileURL(core.getCompiledConfigPath());
url.searchParams.set("hash", Date.now().toString());
return await import(url.href).then((loaded) => buildConfig(loaded));
}
//#endregion
export { loadConfig as t };
//# sourceMappingURL=load-from-file-Doc98oEB.js.map