fumadocs-mdx 11.6.7 → 11.6.9

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.
@@ -5,9 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
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
8
  var __export = (target, all) => {
12
9
  for (var name in all)
13
10
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -30,133 +27,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
27
  ));
31
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
29
 
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
- remarkCodeTabOptions,
104
- ...mdxOptions
105
- }) {
106
- const mdxExports = [
107
- "structuredData",
108
- "frontmatter",
109
- "lastModified",
110
- ...valueToExport
111
- ];
112
- const remarkPlugins = pluginOption(
113
- (v) => [
114
- plugins.remarkGfm,
115
- [
116
- plugins.remarkHeading,
117
- {
118
- generateToc: false,
119
- ...remarkHeadingOptions
120
- }
121
- ],
122
- remarkImageOptions !== false && [plugins.remarkImage, remarkImageOptions],
123
- // Fumadocs 14 compatibility
124
- "remarkCodeTab" in plugins && remarkCodeTabOptions !== false && [
125
- plugins.remarkCodeTab,
126
- remarkCodeTabOptions
127
- ],
128
- ...v,
129
- remarkStructureOptions !== false && [
130
- plugins.remarkStructure,
131
- remarkStructureOptions
132
- ],
133
- [remarkMdxExport, { values: mdxExports }]
134
- ],
135
- mdxOptions.remarkPlugins
136
- );
137
- const rehypePlugins = pluginOption(
138
- (v) => [
139
- rehypeCodeOptions !== false && [plugins.rehypeCode, rehypeCodeOptions],
140
- ...v,
141
- plugins.rehypeToc
142
- ],
143
- mdxOptions.rehypePlugins
144
- );
145
- return {
146
- ...mdxOptions,
147
- remarkPlugins,
148
- rehypePlugins
149
- };
150
- }
151
- var plugins;
152
- var init_mdx_options = __esm({
153
- "src/utils/mdx-options.ts"() {
154
- "use strict";
155
- plugins = __toESM(require("fumadocs-core/mdx-plugins"), 1);
156
- init_remark_exports();
157
- }
158
- });
159
-
160
30
  // src/loader-mdx.ts
161
31
  var loader_mdx_exports = {};
162
32
  __export(loader_mdx_exports, {
@@ -165,7 +35,6 @@ __export(loader_mdx_exports, {
165
35
  module.exports = __toCommonJS(loader_mdx_exports);
166
36
  var path4 = __toESM(require("path"), 1);
167
37
  var import_node_querystring = require("querystring");
168
- var import_gray_matter2 = __toESM(require("gray-matter"), 1);
169
38
 
170
39
  // src/utils/config.ts
171
40
  var fs = __toESM(require("fs/promises"), 1);
@@ -262,7 +131,24 @@ var import_mdx = require("@mdx-js/mdx");
262
131
  var import_unist_util_visit = require("unist-util-visit");
263
132
  var path2 = __toESM(require("path"), 1);
264
133
  var fs2 = __toESM(require("fs/promises"), 1);
265
- var import_gray_matter = __toESM(require("gray-matter"), 1);
134
+
135
+ // src/utils/fuma-matter.ts
136
+ var import_js_yaml = require("js-yaml");
137
+ var regex = /^---\r?\n(.+?)\r?\n---\r?\n/s;
138
+ function fumaMatter(input) {
139
+ const output = { matter: "", data: {}, content: input };
140
+ const match = regex.exec(input);
141
+ if (!match) {
142
+ return output;
143
+ }
144
+ output.matter = match[1];
145
+ output.content = input.slice(match[0].length);
146
+ const loaded = (0, import_js_yaml.load)(output.matter);
147
+ output.data = loaded ?? {};
148
+ return output;
149
+ }
150
+
151
+ // src/mdx-plugins/remark-include.ts
266
152
  function flattenNode(node) {
267
153
  if ("children" in node)
268
154
  return node.children.map((child) => flattenNode(child)).join("");
@@ -297,7 +183,7 @@ function remarkInclude() {
297
183
  );
298
184
  const asCode = params.lang || !specifier.endsWith(".md") && !specifier.endsWith(".mdx");
299
185
  queue.push(
300
- fs2.readFile(targetPath).then(async (content) => {
186
+ fs2.readFile(targetPath).then((buffer) => buffer.toString()).then(async (content) => {
301
187
  compiler?.addDependency(targetPath);
302
188
  if (asCode) {
303
189
  const lang = params.lang ?? path2.extname(specifier).slice(1);
@@ -310,7 +196,7 @@ function remarkInclude() {
310
196
  });
311
197
  return;
312
198
  }
313
- const parsed = processor.parse((0, import_gray_matter.default)(content).content);
199
+ const parsed = processor.parse(fumaMatter(content).content);
314
200
  await update(parsed, targetPath, processor, compiler);
315
201
  Object.assign(
316
202
  parent && parent.type === "paragraph" ? parent : node,
@@ -344,10 +230,9 @@ async function buildMDX(cacheKey, source, options) {
344
230
  format ??= "mdx";
345
231
  const key = `${cacheKey}:${format}`;
346
232
  let cached = cache2.get(key);
347
- if (cached === void 0) {
233
+ if (!cached) {
348
234
  cached = (0, import_mdx.createProcessor)({
349
235
  outputFormat: "program",
350
- development: process.env.NODE_ENV === "development",
351
236
  ...rest,
352
237
  remarkPlugins: [remarkInclude, ...rest.remarkPlugins ?? []],
353
238
  format
@@ -443,13 +328,143 @@ async function validate(schema, data, context, errorMessage) {
443
328
  return data;
444
329
  }
445
330
 
331
+ // src/utils/count-lines.ts
332
+ function countLines(s) {
333
+ let num = 0;
334
+ for (const c of s) {
335
+ if (c === "\n") num++;
336
+ }
337
+ return num;
338
+ }
339
+
340
+ // src/utils/mdx-options.ts
341
+ var plugins = __toESM(require("fumadocs-core/mdx-plugins"), 1);
342
+
343
+ // src/mdx-plugins/remark-exports.ts
344
+ var import_estree_util_value_to_estree = require("estree-util-value-to-estree");
345
+ function remarkMdxExport({ values }) {
346
+ return (tree, vfile) => {
347
+ for (const name of values) {
348
+ if (!(name in vfile.data)) return;
349
+ tree.children.unshift(getMdastExport(name, vfile.data[name]));
350
+ }
351
+ };
352
+ }
353
+ function getMdastExport(name, value) {
354
+ return {
355
+ type: "mdxjsEsm",
356
+ value: "",
357
+ data: {
358
+ estree: {
359
+ type: "Program",
360
+ sourceType: "module",
361
+ body: [
362
+ {
363
+ type: "ExportNamedDeclaration",
364
+ specifiers: [],
365
+ source: null,
366
+ declaration: {
367
+ type: "VariableDeclaration",
368
+ kind: "let",
369
+ declarations: [
370
+ {
371
+ type: "VariableDeclarator",
372
+ id: {
373
+ type: "Identifier",
374
+ name
375
+ },
376
+ init: (0, import_estree_util_value_to_estree.valueToEstree)(value)
377
+ }
378
+ ]
379
+ }
380
+ }
381
+ ]
382
+ }
383
+ }
384
+ };
385
+ }
386
+
387
+ // src/utils/mdx-options.ts
388
+ function pluginOption(def, options = []) {
389
+ const list = def(Array.isArray(options) ? options : []).filter(
390
+ Boolean
391
+ );
392
+ if (typeof options === "function") {
393
+ return options(list);
394
+ }
395
+ return list;
396
+ }
397
+ function getDefaultMDXOptions({
398
+ valueToExport = [],
399
+ rehypeCodeOptions,
400
+ remarkImageOptions,
401
+ remarkHeadingOptions,
402
+ remarkStructureOptions,
403
+ remarkCodeTabOptions,
404
+ ...mdxOptions
405
+ }) {
406
+ const mdxExports = [
407
+ "structuredData",
408
+ "frontmatter",
409
+ "lastModified",
410
+ ...valueToExport
411
+ ];
412
+ const remarkPlugins = pluginOption(
413
+ (v) => [
414
+ plugins.remarkGfm,
415
+ [
416
+ plugins.remarkHeading,
417
+ {
418
+ generateToc: false,
419
+ ...remarkHeadingOptions
420
+ }
421
+ ],
422
+ remarkImageOptions !== false && [plugins.remarkImage, remarkImageOptions],
423
+ // Fumadocs 14 compatibility
424
+ "remarkCodeTab" in plugins && remarkCodeTabOptions !== false && [
425
+ plugins.remarkCodeTab,
426
+ remarkCodeTabOptions
427
+ ],
428
+ ...v,
429
+ remarkStructureOptions !== false && [
430
+ plugins.remarkStructure,
431
+ remarkStructureOptions
432
+ ],
433
+ [remarkMdxExport, { values: mdxExports }]
434
+ ],
435
+ mdxOptions.remarkPlugins
436
+ );
437
+ const rehypePlugins = pluginOption(
438
+ (v) => [
439
+ rehypeCodeOptions !== false && [plugins.rehypeCode, rehypeCodeOptions],
440
+ ...v,
441
+ plugins.rehypeToc
442
+ ],
443
+ mdxOptions.rehypePlugins
444
+ );
445
+ return {
446
+ ...mdxOptions,
447
+ remarkPlugins,
448
+ rehypePlugins
449
+ };
450
+ }
451
+ async function loadDefaultOptions(config) {
452
+ const input = config.global?.mdxOptions;
453
+ config._mdx_loader ??= {};
454
+ const mdxLoader = config._mdx_loader;
455
+ if (!mdxLoader.cachedOptions) {
456
+ mdxLoader.cachedOptions = typeof input === "function" ? getDefaultMDXOptions(await input()) : getDefaultMDXOptions(input ?? {});
457
+ }
458
+ return mdxLoader.cachedOptions;
459
+ }
460
+
446
461
  // src/loader-mdx.ts
447
462
  async function loader(source, callback) {
448
463
  this.cacheable(true);
449
464
  const context = this.context;
450
465
  const filePath = this.resourcePath;
451
466
  const { configPath, outDir } = this.getOptions();
452
- const matter2 = (0, import_gray_matter2.default)(source);
467
+ const matter = fumaMatter(source);
453
468
  const {
454
469
  hash: configHash = await getConfigHash(configPath),
455
470
  collection: collectionId
@@ -460,12 +475,13 @@ async function loader(source, callback) {
460
475
  if (collection && collection.type !== "doc") {
461
476
  collection = void 0;
462
477
  }
478
+ let data = matter.data;
463
479
  const mdxOptions = collection?.mdxOptions ?? await loadDefaultOptions(config);
464
480
  if (collection?.schema) {
465
481
  try {
466
- matter2.data = await validate(
482
+ data = await validate(
467
483
  collection.schema,
468
- matter2.data,
484
+ matter.data,
469
485
  {
470
486
  source,
471
487
  path: filePath
@@ -485,16 +501,16 @@ async function loader(source, callback) {
485
501
  }
486
502
  try {
487
503
  const lineOffset = "\n".repeat(
488
- this.mode === "development" ? lines(matter2.matter) : 0
504
+ this.mode === "development" ? countLines(matter.matter) : 0
489
505
  );
490
506
  const file = await buildMDX(
491
507
  `${configHash}:${collectionId ?? "global"}`,
492
- lineOffset + matter2.content,
508
+ lineOffset + matter.content,
493
509
  {
494
510
  development: this.mode === "development",
495
511
  ...mdxOptions,
496
512
  filePath,
497
- frontmatter: matter2.data,
513
+ frontmatter: data,
498
514
  data: {
499
515
  lastModified: timestamp
500
516
  },
@@ -509,20 +525,3 @@ async function loader(source, callback) {
509
525
  callback(error);
510
526
  }
511
527
  }
512
- async function loadDefaultOptions(config) {
513
- const input = config.global?.mdxOptions;
514
- config._mdx_loader ??= {};
515
- const mdxLoader = config._mdx_loader;
516
- if (!mdxLoader.cachedOptions) {
517
- const { getDefaultMDXOptions: getDefaultMDXOptions2 } = await Promise.resolve().then(() => (init_mdx_options(), mdx_options_exports));
518
- mdxLoader.cachedOptions = typeof input === "function" ? getDefaultMDXOptions2(await input()) : getDefaultMDXOptions2(input ?? {});
519
- }
520
- return mdxLoader.cachedOptions;
521
- }
522
- function lines(s) {
523
- let num = 0;
524
- for (const c of s) {
525
- if (c === "\n") num++;
526
- }
527
- return num;
528
- }
@@ -8,55 +8,27 @@ import {
8
8
  validate
9
9
  } from "./chunk-OTM6WYMS.js";
10
10
  import {
11
- remarkInclude
12
- } from "./chunk-2Z6EJ3GA.js";
11
+ buildMDX,
12
+ countLines
13
+ } from "./chunk-6PDS7MUA.js";
14
+ import {
15
+ loadDefaultOptions
16
+ } from "./chunk-YRT4TZBA.js";
17
+ import "./chunk-AVMO2SRO.js";
13
18
  import "./chunk-DRVUBK5B.js";
19
+ import {
20
+ fumaMatter
21
+ } from "./chunk-KVWX6THC.js";
14
22
 
15
23
  // src/loader-mdx.ts
16
24
  import * as path from "path";
17
25
  import { parse } from "querystring";
18
- import grayMatter from "gray-matter";
19
-
20
- // src/utils/build-mdx.ts
21
- import { createProcessor } from "@mdx-js/mdx";
22
- var cache = /* @__PURE__ */ new Map();
23
- async function buildMDX(cacheKey, source, options) {
24
- const { filePath, frontmatter, data, ...rest } = options;
25
- let format = options.format;
26
- if (!format && filePath) {
27
- format = filePath.endsWith(".mdx") ? "mdx" : "md";
28
- }
29
- format ??= "mdx";
30
- const key = `${cacheKey}:${format}`;
31
- let cached = cache.get(key);
32
- if (cached === void 0) {
33
- cached = createProcessor({
34
- outputFormat: "program",
35
- development: process.env.NODE_ENV === "development",
36
- ...rest,
37
- remarkPlugins: [remarkInclude, ...rest.remarkPlugins ?? []],
38
- format
39
- });
40
- cache.set(key, cached);
41
- }
42
- return cached.process({
43
- value: source,
44
- path: filePath,
45
- data: {
46
- ...data,
47
- frontmatter,
48
- _compiler: options._compiler
49
- }
50
- });
51
- }
52
-
53
- // src/loader-mdx.ts
54
26
  async function loader(source, callback) {
55
27
  this.cacheable(true);
56
28
  const context = this.context;
57
29
  const filePath = this.resourcePath;
58
30
  const { configPath, outDir } = this.getOptions();
59
- const matter = grayMatter(source);
31
+ const matter = fumaMatter(source);
60
32
  const {
61
33
  hash: configHash = await getConfigHash(configPath),
62
34
  collection: collectionId
@@ -67,10 +39,11 @@ async function loader(source, callback) {
67
39
  if (collection && collection.type !== "doc") {
68
40
  collection = void 0;
69
41
  }
42
+ let data = matter.data;
70
43
  const mdxOptions = collection?.mdxOptions ?? await loadDefaultOptions(config);
71
44
  if (collection?.schema) {
72
45
  try {
73
- matter.data = await validate(
46
+ data = await validate(
74
47
  collection.schema,
75
48
  matter.data,
76
49
  {
@@ -92,7 +65,7 @@ async function loader(source, callback) {
92
65
  }
93
66
  try {
94
67
  const lineOffset = "\n".repeat(
95
- this.mode === "development" ? lines(matter.matter) : 0
68
+ this.mode === "development" ? countLines(matter.matter) : 0
96
69
  );
97
70
  const file = await buildMDX(
98
71
  `${configHash}:${collectionId ?? "global"}`,
@@ -101,7 +74,7 @@ async function loader(source, callback) {
101
74
  development: this.mode === "development",
102
75
  ...mdxOptions,
103
76
  filePath,
104
- frontmatter: matter.data,
77
+ frontmatter: data,
105
78
  data: {
106
79
  lastModified: timestamp
107
80
  },
@@ -116,23 +89,6 @@ async function loader(source, callback) {
116
89
  callback(error);
117
90
  }
118
91
  }
119
- async function loadDefaultOptions(config) {
120
- const input = config.global?.mdxOptions;
121
- config._mdx_loader ??= {};
122
- const mdxLoader = config._mdx_loader;
123
- if (!mdxLoader.cachedOptions) {
124
- const { getDefaultMDXOptions } = await import("./mdx-options-YGL3EP3M.js");
125
- mdxLoader.cachedOptions = typeof input === "function" ? getDefaultMDXOptions(await input()) : getDefaultMDXOptions(input ?? {});
126
- }
127
- return mdxLoader.cachedOptions;
128
- }
129
- function lines(s) {
130
- let num = 0;
131
- for (const c of s) {
132
- if (c === "\n") num++;
133
- }
134
- return num;
135
- }
136
92
  export {
137
93
  loader as default
138
94
  };
@@ -255,8 +255,7 @@ var fileCache = {
255
255
  };
256
256
 
257
257
  // src/map/generate.ts
258
- var import_gray_matter = __toESM(require("gray-matter"), 1);
259
- var import_js_yaml = require("js-yaml");
258
+ var import_js_yaml2 = require("js-yaml");
260
259
 
261
260
  // src/utils/git-timestamp.ts
262
261
  var import_node_path2 = __toESM(require("path"), 1);
@@ -281,14 +280,29 @@ async function getGitTimestamp(file) {
281
280
  }
282
281
  }
283
282
 
283
+ // src/utils/fuma-matter.ts
284
+ var import_js_yaml = require("js-yaml");
285
+ var regex = /^---\r?\n(.+?)\r?\n---\r?\n/s;
286
+ function fumaMatter(input) {
287
+ const output = { matter: "", data: {}, content: input };
288
+ const match = regex.exec(input);
289
+ if (!match) {
290
+ return output;
291
+ }
292
+ output.matter = match[1];
293
+ output.content = input.slice(match[0].length);
294
+ const loaded = (0, import_js_yaml.load)(output.matter);
295
+ output.data = loaded ?? {};
296
+ return output;
297
+ }
298
+
284
299
  // src/map/generate.ts
285
300
  async function readFileWithCache(file) {
286
301
  const cached = fileCache.read("read-file", file);
287
302
  if (cached) return cached;
288
303
  return (await fs2.readFile(file)).toString();
289
304
  }
290
- async function generateJS(configPath, config, outputPath, configHash) {
291
- const outDir = path3.dirname(outputPath);
305
+ async function generateJS(configPath, config, importPath, configHash = false) {
292
306
  let asyncInit = false;
293
307
  const lines = [
294
308
  getImportCode({
@@ -298,7 +312,7 @@ async function generateJS(configPath, config, outputPath, configHash) {
298
312
  }),
299
313
  getImportCode({
300
314
  type: "namespace",
301
- specifier: toImportPath(configPath, outDir),
315
+ specifier: toImportPath(configPath, importPath),
302
316
  name: "_source"
303
317
  })
304
318
  ];
@@ -306,11 +320,15 @@ async function generateJS(configPath, config, outputPath, configHash) {
306
320
  async function getDocEntries(collectionName, files) {
307
321
  const items = files.map(async (file, i) => {
308
322
  const importId = `${collectionName}_${i}`;
323
+ const params = [`collection=${collectionName}`];
324
+ if (configHash) {
325
+ params.push(`hash=${configHash}`);
326
+ }
309
327
  lines.unshift(
310
328
  getImportCode({
311
329
  type: "namespace",
312
330
  name: importId,
313
- specifier: `${toImportPath(file.absolutePath, outDir)}?collection=${collectionName}&hash=${configHash}`
331
+ specifier: `${toImportPath(file.absolutePath, importPath)}?${params.join("&")}`
314
332
  })
315
333
  );
316
334
  return `{ info: ${JSON.stringify(file)}, data: ${importId} }`;
@@ -353,11 +371,12 @@ async function generateJS(configPath, config, outputPath, configHash) {
353
371
  asyncInit = true;
354
372
  }
355
373
  const entries2 = files.map(async (file) => {
356
- const parsed = (0, import_gray_matter.default)(
374
+ const parsed = fumaMatter(
357
375
  await readFileWithCache(file.absolutePath).catch(() => "")
358
376
  );
377
+ let data = parsed.data;
359
378
  if (collection.schema) {
360
- parsed.data = await validate(
379
+ data = await validate(
361
380
  collection.schema,
362
381
  parsed.data,
363
382
  { path: file.absolutePath, source: parsed.content },
@@ -371,7 +390,7 @@ async function generateJS(configPath, config, outputPath, configHash) {
371
390
  return JSON.stringify({
372
391
  info: file,
373
392
  lastModified,
374
- data: parsed.data,
393
+ data,
375
394
  content: parsed.content
376
395
  });
377
396
  });
@@ -439,14 +458,17 @@ function getImportCode(info) {
439
458
  }
440
459
  return `import ${specifier}`;
441
460
  }
442
- function toImportPath(file, dir) {
461
+ function toImportPath(file, config) {
443
462
  const ext = path3.extname(file);
444
- let importPath = path3.relative(
445
- dir,
446
- ext === ".ts" ? file.substring(0, file.length - ext.length) : file
447
- );
448
- if (!path3.isAbsolute(importPath) && !importPath.startsWith(".")) {
449
- importPath = `./${importPath}`;
463
+ const filename = ext === ".ts" ? file.substring(0, file.length - ext.length) : file;
464
+ let importPath;
465
+ if ("relativeTo" in config) {
466
+ importPath = path3.relative(config.relativeTo, filename);
467
+ if (!path3.isAbsolute(importPath) && !importPath.startsWith(".")) {
468
+ importPath = `./${importPath}`;
469
+ }
470
+ } else {
471
+ importPath = path3.resolve(filename);
450
472
  }
451
473
  return importPath.replaceAll(path3.sep, "/");
452
474
  }
@@ -454,7 +476,7 @@ function parseMetaEntry(file, content) {
454
476
  const extname3 = path3.extname(file);
455
477
  try {
456
478
  if (extname3 === ".json") return JSON.parse(content);
457
- if (extname3 === ".yaml") return (0, import_js_yaml.load)(content);
479
+ if (extname3 === ".yaml") return (0, import_js_yaml2.load)(content);
458
480
  } catch (e) {
459
481
  throw new Error(`Failed to parse meta file: ${file}.`, {
460
482
  cause: e
@@ -473,7 +495,12 @@ async function start(dev, configPath, outDir) {
473
495
  try {
474
496
  await fs3.writeFile(
475
497
  outPath,
476
- await generateJS(configPath, config, outPath, configHash)
498
+ await generateJS(
499
+ configPath,
500
+ config,
501
+ { relativeTo: outDir },
502
+ configHash
503
+ )
477
504
  );
478
505
  } catch (err) {
479
506
  if (err instanceof ValidationError) {
@@ -578,7 +605,10 @@ async function postInstall(configPath = findConfigFile(), outDir = ".source") {
578
605
  const config = await loadConfig(configPath, outDir, hash, true);
579
606
  await fs4.rm(path5.dirname(jsOut), { recursive: true });
580
607
  await fs4.mkdir(path5.dirname(jsOut), { recursive: true });
581
- await fs4.writeFile(jsOut, await generateJS(configPath, config, jsOut, hash));
608
+ await fs4.writeFile(
609
+ jsOut,
610
+ await generateJS(configPath, config, { relativeTo: outDir }, hash)
611
+ );
582
612
  console.log("[MDX] types generated");
583
613
  }
584
614
  // Annotate the CommonJS export names for ESM import in node: