fumadocs-mdx 11.2.2 → 11.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,14 +3,11 @@ import {
3
3
  } from "./chunk-GUHWD47S.js";
4
4
  import {
5
5
  getConfigHash,
6
- getManifestEntryPath,
7
6
  loadConfigCached
8
- } from "./chunk-2KEQHW7J.js";
9
- import "./chunk-MKWJLEE7.js";
7
+ } from "./chunk-2ZPSMAUV.js";
10
8
 
11
9
  // src/loader-mdx.ts
12
10
  import * as path2 from "node:path";
13
- import * as fs2 from "node:fs/promises";
14
11
  import { parse } from "node:querystring";
15
12
  import grayMatter from "gray-matter";
16
13
 
@@ -54,7 +51,7 @@ function buildMDX(group, configHash, source, options = {}) {
54
51
  }
55
52
 
56
53
  // src/utils/format-error.ts
57
- function formatError(file, error) {
54
+ function formatError(message, error) {
58
55
  const lines = [];
59
56
  function walk(key, { _errors, ...rest }, padStart = 0) {
60
57
  if (key !== void 0 || _errors.length > 0) {
@@ -68,7 +65,7 @@ function formatError(file, error) {
68
65
  }
69
66
  }
70
67
  walk(void 0, error.format());
71
- return [`in ${file}:`, ...lines].join("\n");
68
+ return [message, ...lines].join("\n");
72
69
  }
73
70
 
74
71
  // src/utils/git-timestamp.ts
@@ -124,7 +121,7 @@ async function loader(source, callback) {
124
121
  if (collection && collection.type !== "doc") {
125
122
  collection = void 0;
126
123
  }
127
- const mdxOptions = collection?.mdxOptions ?? config.defaultMdxOptions;
124
+ const mdxOptions = collection?.mdxOptions ?? await config.getDefaultMDXOptions();
128
125
  let frontmatter = matter.data;
129
126
  if (collection?.schema) {
130
127
  let schema = collection.schema;
@@ -145,7 +142,11 @@ async function loader(source, callback) {
145
142
  }
146
143
  const result = await schema.safeParseAsync(frontmatter);
147
144
  if (result.error) {
148
- callback(new Error(formatError(filePath, result.error)));
145
+ callback(
146
+ new Error(
147
+ formatError(`invalid frontmatter in ${filePath}:`, result.error)
148
+ )
149
+ );
149
150
  return;
150
151
  }
151
152
  frontmatter = result.data;
@@ -170,16 +171,6 @@ async function loader(source, callback) {
170
171
  }
171
172
  );
172
173
  callback(void 0, String(file.value), file.map ?? void 0);
173
- if (config.global?.generateManifest) {
174
- await fs2.mkdir(".next/cache/fumadocs", { recursive: true });
175
- await fs2.writeFile(
176
- getManifestEntryPath(filePath),
177
- JSON.stringify({
178
- path: filePath,
179
- data: file.data
180
- })
181
- );
182
- }
183
174
  } catch (error) {
184
175
  if (!(error instanceof Error)) throw error;
185
176
  const fpath = path2.relative(context, filePath);
@@ -0,0 +1,6 @@
1
+ import {
2
+ getDefaultMDXOptions
3
+ } from "./chunk-6LEQ23AC.js";
4
+ export {
5
+ getDefaultMDXOptions
6
+ };
@@ -0,0 +1,556 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __esm = (fn, res) => function __init() {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ };
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
+
33
+ // src/mdx-plugins/remark-exports.ts
34
+ function remarkMdxExport({ values }) {
35
+ return (tree, vfile) => {
36
+ for (const name of values) {
37
+ if (!(name in vfile.data)) return;
38
+ tree.children.unshift(getMdastExport(name, vfile.data[name]));
39
+ }
40
+ };
41
+ }
42
+ function getMdastExport(name, value) {
43
+ return {
44
+ type: "mdxjsEsm",
45
+ value: "",
46
+ data: {
47
+ estree: {
48
+ type: "Program",
49
+ sourceType: "module",
50
+ body: [
51
+ {
52
+ type: "ExportNamedDeclaration",
53
+ specifiers: [],
54
+ source: null,
55
+ declaration: {
56
+ type: "VariableDeclaration",
57
+ kind: "let",
58
+ declarations: [
59
+ {
60
+ type: "VariableDeclarator",
61
+ id: {
62
+ type: "Identifier",
63
+ name
64
+ },
65
+ init: (0, import_estree_util_value_to_estree.valueToEstree)(value)
66
+ }
67
+ ]
68
+ }
69
+ }
70
+ ]
71
+ }
72
+ }
73
+ };
74
+ }
75
+ var import_estree_util_value_to_estree;
76
+ var init_remark_exports = __esm({
77
+ "src/mdx-plugins/remark-exports.ts"() {
78
+ "use strict";
79
+ import_estree_util_value_to_estree = require("estree-util-value-to-estree");
80
+ }
81
+ });
82
+
83
+ // src/utils/mdx-options.ts
84
+ var mdx_options_exports = {};
85
+ __export(mdx_options_exports, {
86
+ getDefaultMDXOptions: () => getDefaultMDXOptions
87
+ });
88
+ function pluginOption(def, options = []) {
89
+ const list = def(Array.isArray(options) ? options : []).filter(
90
+ Boolean
91
+ );
92
+ if (typeof options === "function") {
93
+ return options(list);
94
+ }
95
+ return list;
96
+ }
97
+ function getDefaultMDXOptions({
98
+ valueToExport = [],
99
+ rehypeCodeOptions,
100
+ remarkImageOptions,
101
+ remarkHeadingOptions,
102
+ remarkStructureOptions,
103
+ ...mdxOptions
104
+ }) {
105
+ const mdxExports = [
106
+ "structuredData",
107
+ "frontmatter",
108
+ "lastModified",
109
+ ...valueToExport
110
+ ];
111
+ const remarkPlugins = pluginOption(
112
+ (v) => [
113
+ import_mdx_plugins.remarkGfm,
114
+ [
115
+ import_mdx_plugins.remarkHeading,
116
+ {
117
+ generateToc: false,
118
+ ...remarkHeadingOptions
119
+ }
120
+ ],
121
+ remarkImageOptions !== false && [import_mdx_plugins.remarkImage, remarkImageOptions],
122
+ ...v,
123
+ remarkStructureOptions !== false && [
124
+ import_mdx_plugins.remarkStructure,
125
+ remarkStructureOptions
126
+ ],
127
+ [remarkMdxExport, { values: mdxExports }]
128
+ ],
129
+ mdxOptions.remarkPlugins
130
+ );
131
+ const rehypePlugins = pluginOption(
132
+ (v) => [
133
+ rehypeCodeOptions !== false && [import_mdx_plugins.rehypeCode, rehypeCodeOptions],
134
+ ...v,
135
+ [import_mdx_plugins.rehypeToc]
136
+ ],
137
+ mdxOptions.rehypePlugins
138
+ );
139
+ return {
140
+ ...mdxOptions,
141
+ remarkPlugins,
142
+ rehypePlugins
143
+ };
144
+ }
145
+ var import_mdx_plugins;
146
+ var init_mdx_options = __esm({
147
+ "src/utils/mdx-options.ts"() {
148
+ "use strict";
149
+ import_mdx_plugins = require("fumadocs-core/mdx-plugins");
150
+ init_remark_exports();
151
+ }
152
+ });
153
+
154
+ // src/map/watcher.ts
155
+ var watcher_exports = {};
156
+ __export(watcher_exports, {
157
+ watcher: () => watcher
158
+ });
159
+ function watcher(configPath, config) {
160
+ const deps = [configPath];
161
+ for (const collection of config.collections.values()) {
162
+ if (Array.isArray(collection.dir)) deps.push(...collection.dir);
163
+ else deps.push(collection.dir);
164
+ }
165
+ return (0, import_chokidar.watch)(deps, {
166
+ ignoreInitial: true,
167
+ persistent: true
168
+ });
169
+ }
170
+ var import_chokidar;
171
+ var init_watcher = __esm({
172
+ "src/map/watcher.ts"() {
173
+ "use strict";
174
+ import_chokidar = require("chokidar");
175
+ }
176
+ });
177
+
178
+ // src/next/index.ts
179
+ var next_exports = {};
180
+ __export(next_exports, {
181
+ createMDX: () => createMDX,
182
+ postInstall: () => postInstall,
183
+ start: () => start
184
+ });
185
+ module.exports = __toCommonJS(next_exports);
186
+
187
+ // src/next/create.ts
188
+ var import_node_path2 = __toESM(require("path"), 1);
189
+
190
+ // src/config/load.ts
191
+ var path = __toESM(require("path"), 1);
192
+ var import_node_url = require("url");
193
+ function findConfigFile() {
194
+ return path.resolve("source.config.ts");
195
+ }
196
+ async function loadConfig(configPath) {
197
+ const { build } = await import("esbuild");
198
+ const url = (0, import_node_url.pathToFileURL)(path.resolve(".source/source.config.mjs"));
199
+ const transformed = await build({
200
+ entryPoints: [{ in: configPath, out: "source.config" }],
201
+ bundle: true,
202
+ outdir: ".source",
203
+ target: "node18",
204
+ write: true,
205
+ platform: "node",
206
+ format: "esm",
207
+ packages: "external",
208
+ outExtension: {
209
+ ".js": ".mjs"
210
+ },
211
+ allowOverwrite: true
212
+ });
213
+ if (transformed.errors.length > 0) {
214
+ throw new Error("failed to compile configuration file");
215
+ }
216
+ const loaded = await import(`${url.href}?hash=${Date.now().toString()}`);
217
+ const [err, config] = buildConfig(
218
+ // every call to `loadConfig` will cause the previous cache to be ignored
219
+ loaded
220
+ );
221
+ if (err !== null) throw new Error(err);
222
+ return config;
223
+ }
224
+ function buildConfig(config) {
225
+ const collections = /* @__PURE__ */ new Map();
226
+ let globalConfig;
227
+ for (const [k, v] of Object.entries(config)) {
228
+ if (!v) {
229
+ continue;
230
+ }
231
+ if (typeof v === "object" && "_doc" in v && v._doc === "collections") {
232
+ collections.set(
233
+ k,
234
+ v
235
+ );
236
+ continue;
237
+ }
238
+ if (k === "default") {
239
+ globalConfig = v;
240
+ continue;
241
+ }
242
+ return [
243
+ `Unknown export "${k}", you can only export collections from source configuration file.`,
244
+ null
245
+ ];
246
+ }
247
+ let cachedMdxOptions;
248
+ return [
249
+ null,
250
+ {
251
+ global: globalConfig,
252
+ collections,
253
+ async getDefaultMDXOptions() {
254
+ if (cachedMdxOptions) return cachedMdxOptions;
255
+ const { getDefaultMDXOptions: getDefaultMDXOptions2 } = await Promise.resolve().then(() => (init_mdx_options(), mdx_options_exports));
256
+ const mdxOptions = globalConfig?.mdxOptions ?? {};
257
+ if (typeof mdxOptions === "function") {
258
+ cachedMdxOptions = getDefaultMDXOptions2(await mdxOptions());
259
+ } else {
260
+ cachedMdxOptions = getDefaultMDXOptions2(mdxOptions);
261
+ }
262
+ return cachedMdxOptions;
263
+ },
264
+ _runtime: {
265
+ files: /* @__PURE__ */ new Map()
266
+ }
267
+ }
268
+ ];
269
+ }
270
+
271
+ // src/map/index.ts
272
+ var path3 = __toESM(require("path"), 1);
273
+ var fs2 = __toESM(require("fs"), 1);
274
+ var import_promises = require("fs/promises");
275
+ var import_gray_matter = __toESM(require("gray-matter"), 1);
276
+
277
+ // src/config/cached.ts
278
+ var import_node_crypto = require("crypto");
279
+ var fs = __toESM(require("fs"), 1);
280
+ var cache = /* @__PURE__ */ new Map();
281
+ async function loadConfigCached(configPath, hash) {
282
+ const cached = cache.get(configPath);
283
+ if (cached && cached.hash === hash) {
284
+ return await cached.config;
285
+ }
286
+ const config = loadConfig(configPath);
287
+ cache.set(configPath, { config, hash });
288
+ return await config;
289
+ }
290
+ async function getConfigHash(configPath) {
291
+ const hash = (0, import_node_crypto.createHash)("md5");
292
+ const rs = fs.createReadStream(configPath);
293
+ for await (const chunk of rs) {
294
+ hash.update(chunk);
295
+ }
296
+ return hash.digest("hex");
297
+ }
298
+
299
+ // src/map/generate.ts
300
+ var path2 = __toESM(require("path"), 1);
301
+ var import_fast_glob = __toESM(require("fast-glob"), 1);
302
+
303
+ // src/utils/get-type-from-path.ts
304
+ var import_node_path = require("path");
305
+ var docTypes = [".mdx", ".md"];
306
+ var metaTypes = [".json", ".yaml"];
307
+ function getTypeFromPath(path6) {
308
+ const ext = (0, import_node_path.extname)(path6);
309
+ if (docTypes.includes(ext)) return "doc";
310
+ if (metaTypes.includes(ext)) return "meta";
311
+ }
312
+
313
+ // src/map/generate.ts
314
+ async function generateJS(configPath, config, outputPath, configHash, getFrontmatter) {
315
+ const outDir2 = path2.dirname(outputPath);
316
+ const imports = [
317
+ {
318
+ type: "named",
319
+ names: ["toRuntime", "toRuntimeAsync"],
320
+ specifier: "fumadocs-mdx"
321
+ }
322
+ ];
323
+ const importedCollections = /* @__PURE__ */ new Set();
324
+ async function generateEntry(file, collectionName, collection, importId) {
325
+ if (collection.type === "doc" && collection.async) {
326
+ const importPath = `${toImportPath(file.absolutePath, outDir2)}?hash=${configHash}&collection=${collectionName}`;
327
+ const frontmatter = await getFrontmatter(file.absolutePath);
328
+ return `toRuntimeAsync(${JSON.stringify(frontmatter)}, () => import(${JSON.stringify(importPath)}), ${JSON.stringify(file)})`;
329
+ }
330
+ imports.push({
331
+ type: "namespace",
332
+ name: importId,
333
+ specifier: `${toImportPath(file.absolutePath, outDir2)}?collection=${collectionName}&hash=${configHash}`
334
+ });
335
+ return `toRuntime("${collection.type}", ${importId}, ${JSON.stringify(file)})`;
336
+ }
337
+ config._runtime.files.clear();
338
+ const entries = Array.from(config.collections.entries());
339
+ const declares = entries.map(async ([k, collection]) => {
340
+ const files = await getCollectionFiles(collection);
341
+ const items = files.map(async (file, i) => {
342
+ config._runtime.files.set(file.absolutePath, k);
343
+ return generateEntry(file, k, collection, `${k}_${i}`);
344
+ });
345
+ const resolvedItems = await Promise.all(items);
346
+ if (collection.transform) {
347
+ if (config.global) importedCollections.add("default");
348
+ importedCollections.add(k);
349
+ }
350
+ return collection.transform ? `export const ${k} = await Promise.all([${resolvedItems.join(", ")}].map(v => c_${k}.transform(v, ${config.global ? "c_default" : "undefined"})));` : `export const ${k} = [${resolvedItems.join(", ")}];`;
351
+ });
352
+ const resolvedDeclares = await Promise.all(declares);
353
+ if (importedCollections.size > 0) {
354
+ imports.push({
355
+ type: "named",
356
+ names: Array.from(importedCollections.values()).sort().map((v) => [v, `c_${v}`]),
357
+ specifier: toImportPath(configPath, outDir2)
358
+ });
359
+ }
360
+ return [...imports.map(getImportCode), ...resolvedDeclares].join("\n");
361
+ }
362
+ async function getCollectionFiles(collection) {
363
+ const files = /* @__PURE__ */ new Map();
364
+ const dirs = Array.isArray(collection.dir) ? collection.dir : [collection.dir];
365
+ await Promise.all(
366
+ dirs.map(async (dir) => {
367
+ const result = await (0, import_fast_glob.default)(collection.files ?? "**/*", {
368
+ cwd: path2.resolve(dir),
369
+ absolute: true
370
+ });
371
+ for (const item of result) {
372
+ if (getTypeFromPath(item) !== collection.type) continue;
373
+ files.set(item, {
374
+ path: path2.relative(dir, item),
375
+ absolutePath: item
376
+ });
377
+ }
378
+ })
379
+ );
380
+ return Array.from(files.values());
381
+ }
382
+ function getImportCode(info) {
383
+ const specifier = JSON.stringify(info.specifier);
384
+ if (info.type === "default") return `import ${info.name} from ${specifier}`;
385
+ if (info.type === "namespace")
386
+ return `import * as ${info.name} from ${specifier}`;
387
+ if (info.type === "named") {
388
+ const names = info.names.map(
389
+ (name) => Array.isArray(name) ? `${name[0]} as ${name[1]}` : name
390
+ );
391
+ return `import { ${names.join(", ")} } from ${specifier}`;
392
+ }
393
+ return `import ${specifier}`;
394
+ }
395
+ function toImportPath(file, dir) {
396
+ let importPath = path2.relative(dir, file);
397
+ if (!path2.isAbsolute(importPath) && !importPath.startsWith(".")) {
398
+ importPath = `./${importPath}`;
399
+ }
400
+ return importPath.replaceAll(path2.sep, "/");
401
+ }
402
+ function generateTypes(configPath, config, outputPath) {
403
+ const importPath = JSON.stringify(
404
+ toImportPath(configPath, path2.dirname(outputPath))
405
+ );
406
+ const lines = [
407
+ 'import type { GetOutput } from "fumadocs-mdx/config"'
408
+ ];
409
+ for (const name of config.collections.keys()) {
410
+ lines.push(
411
+ `export declare const ${name}: GetOutput<typeof import(${importPath}).${name}>`
412
+ );
413
+ }
414
+ return lines.join("\n");
415
+ }
416
+
417
+ // src/map/index.ts
418
+ async function start(dev, configPath, outDir2) {
419
+ let configHash = await getConfigHash(configPath);
420
+ let config = await loadConfigCached(configPath, configHash);
421
+ const jsOut = path3.resolve(outDir2, `index.js`);
422
+ const typeOut = path3.resolve(outDir2, `index.d.ts`);
423
+ const frontmatterCache = /* @__PURE__ */ new Map();
424
+ let hookUpdate = false;
425
+ const readFrontmatter = async (file) => {
426
+ const cached = frontmatterCache.get(file);
427
+ if (cached) return cached;
428
+ hookUpdate = true;
429
+ return (0, import_gray_matter.default)({
430
+ content: await (0, import_promises.readFile)(file).then((res) => res.toString())
431
+ }).data;
432
+ };
433
+ fs2.mkdirSync(outDir2, { recursive: true });
434
+ fs2.writeFileSync(
435
+ jsOut,
436
+ await generateJS(configPath, config, jsOut, configHash, readFrontmatter)
437
+ );
438
+ fs2.writeFileSync(typeOut, generateTypes(configPath, config, typeOut));
439
+ console.log("[MDX] initialized map file");
440
+ if (dev) {
441
+ const { watcher: watcher2 } = await Promise.resolve().then(() => (init_watcher(), watcher_exports));
442
+ const instance = watcher2(configPath, config);
443
+ instance.on("ready", () => {
444
+ console.log("[MDX] started dev server");
445
+ });
446
+ instance.on("all", (event, file) => {
447
+ if (typeof file !== "string") return;
448
+ const onUpdate = async () => {
449
+ const isConfigFile = path3.resolve(file) === configPath;
450
+ if (isConfigFile) {
451
+ configHash = await getConfigHash(configPath);
452
+ config = await loadConfigCached(configPath, configHash);
453
+ await (0, import_promises.writeFile)(typeOut, generateTypes(configPath, config, typeOut));
454
+ console.log("[MDX] Updated map types");
455
+ }
456
+ if (isConfigFile || event !== "change" || hookUpdate) {
457
+ if (event === "change") frontmatterCache.delete(file);
458
+ await (0, import_promises.writeFile)(
459
+ jsOut,
460
+ await generateJS(
461
+ configPath,
462
+ config,
463
+ jsOut,
464
+ configHash,
465
+ readFrontmatter
466
+ )
467
+ );
468
+ console.log("[MDX] Updated map file");
469
+ }
470
+ };
471
+ void onUpdate();
472
+ });
473
+ process.on("exit", () => {
474
+ console.log("[MDX] closing dev server");
475
+ void instance.close();
476
+ });
477
+ }
478
+ }
479
+
480
+ // src/next/create.ts
481
+ var outDir = import_node_path2.default.resolve(".source");
482
+ var defaultPageExtensions = ["mdx", "md", "jsx", "js", "tsx", "ts"];
483
+ function createMDX({
484
+ configPath = findConfigFile()
485
+ } = {}) {
486
+ const isDev = process.argv.includes("dev");
487
+ const isBuild = process.argv.includes("build");
488
+ if ((isDev || isBuild) && process.env._FUMADOCS_MDX !== "1") {
489
+ process.env._FUMADOCS_MDX = "1";
490
+ void start(isDev, configPath, outDir);
491
+ }
492
+ return (nextConfig = {}) => {
493
+ const mdxLoaderOptions = {
494
+ _ctx: {
495
+ configPath
496
+ }
497
+ };
498
+ return {
499
+ ...nextConfig,
500
+ experimental: {
501
+ ...nextConfig.experimental,
502
+ turbo: {
503
+ ...nextConfig.experimental?.turbo,
504
+ rules: {
505
+ ...nextConfig.experimental?.turbo?.rules,
506
+ // @ts-expect-error -- safe types
507
+ "*.{md,mdx}": {
508
+ loaders: [
509
+ {
510
+ loader: "fumadocs-mdx/loader-mdx",
511
+ options: mdxLoaderOptions
512
+ }
513
+ ],
514
+ as: "*.js"
515
+ }
516
+ }
517
+ }
518
+ },
519
+ pageExtensions: nextConfig.pageExtensions ?? defaultPageExtensions,
520
+ webpack: (config, options) => {
521
+ config.resolve ||= {};
522
+ config.module ||= {};
523
+ config.module.rules ||= [];
524
+ config.module.rules.push({
525
+ test: /\.mdx?$/,
526
+ use: [
527
+ options.defaultLoaders.babel,
528
+ {
529
+ loader: "fumadocs-mdx/loader-mdx",
530
+ options: mdxLoaderOptions
531
+ }
532
+ ]
533
+ });
534
+ config.plugins ||= [];
535
+ return nextConfig.webpack?.(config, options) ?? config;
536
+ }
537
+ };
538
+ };
539
+ }
540
+
541
+ // src/postinstall.ts
542
+ var path5 = __toESM(require("path"), 1);
543
+ var fs3 = __toESM(require("fs"), 1);
544
+ async function postInstall(configPath = findConfigFile()) {
545
+ const typeOut = path5.resolve(".source/index.d.ts");
546
+ const config = await loadConfig(configPath);
547
+ fs3.mkdirSync(path5.dirname(typeOut), { recursive: true });
548
+ fs3.writeFileSync(typeOut, generateTypes(configPath, config, typeOut));
549
+ console.log("[MDX] types generated");
550
+ }
551
+ // Annotate the CommonJS export names for ESM import in node:
552
+ 0 && (module.exports = {
553
+ createMDX,
554
+ postInstall,
555
+ start
556
+ });
@@ -0,0 +1,21 @@
1
+ import { NextConfig } from 'next';
2
+
3
+ /**
4
+ * Start a MDX server that builds index and manifest files.
5
+ *
6
+ * In development mode, it starts a file watcher to auto-update output as your input changes.
7
+ */
8
+ declare function start(dev: boolean, configPath: string, outDir: string): Promise<void>;
9
+
10
+ interface CreateMDXOptions {
11
+ /**
12
+ * Path to source configuration file
13
+ */
14
+ configPath?: string;
15
+ }
16
+
17
+ declare function createMDX({ configPath, }?: CreateMDXOptions): (nextConfig?: NextConfig) => NextConfig;
18
+
19
+ declare function postInstall(configPath?: string): Promise<void>;
20
+
21
+ export { type CreateMDXOptions, createMDX, postInstall, start };