fumadocs-mdx 13.0.3 → 13.0.5

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.
Files changed (66) hide show
  1. package/dist/bin.cjs +353 -273
  2. package/dist/bin.js +1 -1
  3. package/dist/{build-mdx-TtQzmq6W.d.cts → build-mdx-BjXOmv0b.d.cts} +1 -1
  4. package/dist/{build-mdx--WI4tf2-.d.ts → build-mdx-CY5UldCO.d.ts} +1 -1
  5. package/dist/bun/index.cjs +177 -57
  6. package/dist/bun/index.d.cts +2 -2
  7. package/dist/bun/index.d.ts +2 -2
  8. package/dist/bun/index.js +26 -34
  9. package/dist/chunk-2HXTGJBI.js +101 -0
  10. package/dist/chunk-4JSFLXXT.js +8 -0
  11. package/dist/{chunk-JVZFH6ND.js → chunk-QXHN25N3.js} +2 -2
  12. package/dist/{chunk-EELYB2XC.js → chunk-TZ5EQBFW.js} +9 -103
  13. package/dist/chunk-VUEZTR2H.js +26 -0
  14. package/dist/{chunk-XQ5O7IPO.js → chunk-XYGORKQA.js} +5 -3
  15. package/dist/chunk-YAIPHUCZ.js +56 -0
  16. package/dist/chunk-ZNVPB2IR.js +170 -0
  17. package/dist/config/index.d.cts +2 -2
  18. package/dist/config/index.d.ts +2 -2
  19. package/dist/{core-DhfmVKRA.d.cts → core-DB7TdlyC.d.cts} +21 -7
  20. package/dist/{core-DhfmVKRA.d.ts → core-DB7TdlyC.d.ts} +21 -7
  21. package/dist/index-D7s7kCc2.d.cts +7 -0
  22. package/dist/index-D7s7kCc2.d.ts +7 -0
  23. package/dist/index.d.cts +4 -4
  24. package/dist/index.d.ts +4 -4
  25. package/dist/load-from-file-AVYOFOI7.js +7 -0
  26. package/dist/next/index.cjs +145 -139
  27. package/dist/next/index.js +56 -36
  28. package/dist/node/loader.cjs +242 -128
  29. package/dist/node/loader.d.cts +2 -2
  30. package/dist/node/loader.d.ts +2 -2
  31. package/dist/node/loader.js +29 -16
  32. package/dist/plugins/json-schema.cjs +22 -70
  33. package/dist/plugins/json-schema.d.cts +2 -2
  34. package/dist/plugins/json-schema.d.ts +2 -2
  35. package/dist/plugins/json-schema.js +19 -14
  36. package/dist/runtime/next/async.cjs +56 -11
  37. package/dist/runtime/next/async.d.cts +4 -6
  38. package/dist/runtime/next/async.d.ts +4 -6
  39. package/dist/runtime/next/async.js +3 -6
  40. package/dist/runtime/next/index.d.cts +5 -5
  41. package/dist/runtime/next/index.d.ts +5 -5
  42. package/dist/runtime/vite/browser.d.cts +3 -3
  43. package/dist/runtime/vite/browser.d.ts +3 -3
  44. package/dist/runtime/vite/server.d.cts +3 -3
  45. package/dist/runtime/vite/server.d.ts +3 -3
  46. package/dist/{types-zrV4v6mp.d.cts → types-Bnh9n7mj.d.cts} +2 -2
  47. package/dist/{types-CMva20Zp.d.ts → types-ey1AZqrg.d.ts} +2 -2
  48. package/dist/vite/index.cjs +238 -159
  49. package/dist/vite/index.js +113 -118
  50. package/dist/webpack/{index.cjs → mdx.cjs} +126 -104
  51. package/dist/webpack/mdx.d.cts +6 -0
  52. package/dist/webpack/mdx.d.ts +6 -0
  53. package/dist/webpack/{index.js → mdx.js} +12 -14
  54. package/dist/webpack/meta.cjs +528 -0
  55. package/dist/webpack/meta.d.cts +6 -0
  56. package/dist/webpack/meta.d.ts +6 -0
  57. package/dist/webpack/meta.js +42 -0
  58. package/loader-mdx.cjs +1 -1
  59. package/loader-meta.cjs +7 -0
  60. package/package.json +6 -3
  61. package/dist/chunk-U4MQ44TS.js +0 -53
  62. package/dist/chunk-XZY2AWJI.js +0 -81
  63. package/dist/chunk-YVCR6FUH.js +0 -82
  64. package/dist/load-MNG3CLET.js +0 -7
  65. package/dist/webpack/index.d.cts +0 -15
  66. package/dist/webpack/index.d.ts +0 -15
@@ -118,35 +118,78 @@ var init_preset = __esm({
118
118
  });
119
119
 
120
120
  // src/config/build.ts
121
+ function buildCollection(name, config) {
122
+ if (config.type === "docs") {
123
+ return {
124
+ ...config,
125
+ name,
126
+ meta: buildPrimitiveCollection(name, config.meta),
127
+ docs: buildPrimitiveCollection(name, config.docs)
128
+ };
129
+ }
130
+ return buildPrimitiveCollection(name, config);
131
+ }
132
+ function buildPrimitiveCollection(name, { files, ...config }) {
133
+ const supportedFormats = SupportedFormats[config.type];
134
+ const patterns = files ?? [`**/*.{${supportedFormats.join(",")}}`];
135
+ let matchers;
136
+ return {
137
+ ...config,
138
+ name,
139
+ patterns,
140
+ isFileSupported(filePath) {
141
+ return supportedFormats.some((format) => filePath.endsWith(`.${format}`));
142
+ },
143
+ hasFile(filePath) {
144
+ matchers ??= (Array.isArray(config.dir) ? config.dir : [config.dir]).map(
145
+ (dir) => (0, import_picomatch.default)(patterns, {
146
+ cwd: dir
147
+ })
148
+ );
149
+ return this.isFileSupported(filePath) && matchers.some((matcher) => matcher(filePath));
150
+ }
151
+ };
152
+ }
121
153
  function buildConfig(config) {
122
154
  const collections = /* @__PURE__ */ new Map();
123
- let globalConfig = {};
155
+ const loaded = {};
124
156
  for (const [k, v] of Object.entries(config)) {
125
157
  if (!v) {
126
158
  continue;
127
159
  }
128
160
  if (typeof v === "object" && "type" in v) {
129
161
  if (v.type === "docs") {
130
- collections.set(k, v);
162
+ collections.set(k, buildCollection(k, v));
131
163
  continue;
132
164
  }
133
165
  if (v.type === "doc" || v.type === "meta") {
134
- collections.set(k, v);
166
+ collections.set(
167
+ k,
168
+ buildCollection(k, v)
169
+ );
135
170
  continue;
136
171
  }
137
172
  }
138
173
  if (k === "default" && v) {
139
- globalConfig = v;
174
+ Object.assign(loaded, v);
140
175
  continue;
141
176
  }
142
177
  throw new Error(
143
178
  `Unknown export "${k}", you can only export collections from source configuration file.`
144
179
  );
145
180
  }
181
+ if (loaded.collections) {
182
+ for (const [k, v] of Object.entries(loaded.collections)) {
183
+ collections.set(k, buildCollection(k, v));
184
+ }
185
+ }
146
186
  const mdxOptionsCache = /* @__PURE__ */ new Map();
147
187
  return {
148
- global: globalConfig,
149
- collections,
188
+ global: loaded,
189
+ collectionList: Array.from(collections.values()),
190
+ getCollection(name) {
191
+ return collections.get(name);
192
+ },
150
193
  async getDefaultMDXOptions(mode = "default") {
151
194
  const cached = mdxOptionsCache.get(mode);
152
195
  if (cached) return cached;
@@ -166,15 +209,21 @@ function buildConfig(config) {
166
209
  }
167
210
  };
168
211
  }
212
+ var import_picomatch, SupportedFormats;
169
213
  var init_build = __esm({
170
214
  "src/config/build.ts"() {
171
215
  "use strict";
216
+ import_picomatch = __toESM(require("picomatch"), 1);
217
+ SupportedFormats = {
218
+ doc: ["mdx", "md"],
219
+ meta: ["json", "yaml"]
220
+ };
172
221
  }
173
222
  });
174
223
 
175
- // src/loaders/config/load.ts
176
- var load_exports = {};
177
- __export(load_exports, {
224
+ // src/config/load-from-file.ts
225
+ var load_from_file_exports = {};
226
+ __export(load_from_file_exports, {
178
227
  loadConfig: () => loadConfig
179
228
  });
180
229
  async function compileConfig(configPath, outDir) {
@@ -199,19 +248,19 @@ async function compileConfig(configPath, outDir) {
199
248
  }
200
249
  async function loadConfig(configPath, outDir, build = false) {
201
250
  if (build) await compileConfig(configPath, outDir);
202
- const url = (0, import_node_url.pathToFileURL)(path.resolve(outDir, "source.config.mjs"));
251
+ const url = (0, import_node_url2.pathToFileURL)(path6.resolve(outDir, "source.config.mjs"));
203
252
  url.searchParams.set("hash", Date.now().toString());
204
253
  const config = import(url.href).then(
205
254
  (loaded) => buildConfig(loaded)
206
255
  );
207
256
  return await config;
208
257
  }
209
- var path, import_node_url;
210
- var init_load = __esm({
211
- "src/loaders/config/load.ts"() {
258
+ var path6, import_node_url2;
259
+ var init_load_from_file = __esm({
260
+ "src/config/load-from-file.ts"() {
212
261
  "use strict";
213
- path = __toESM(require("path"), 1);
214
- import_node_url = require("url");
262
+ path6 = __toESM(require("path"), 1);
263
+ import_node_url2 = require("url");
215
264
  init_build();
216
265
  }
217
266
  });
@@ -219,35 +268,75 @@ var init_load = __esm({
219
268
  // src/node/loader.ts
220
269
  var loader_exports = {};
221
270
  __export(loader_exports, {
222
- load: () => load2
271
+ load: () => load3
223
272
  });
224
273
  module.exports = __toCommonJS(loader_exports);
225
274
 
226
- // src/loaders/config/index.ts
275
+ // src/core.ts
227
276
  var import_node_path = __toESM(require("path"), 1);
228
277
  var import_promises = __toESM(require("fs/promises"), 1);
229
278
  function findConfigFile() {
230
279
  return import_node_path.default.resolve("source.config.ts");
231
280
  }
232
- function staticConfig({
233
- core: core2,
234
- buildConfig: buildConfig2
235
- }) {
236
- let cached;
237
- async function newConfig() {
238
- const { loadConfig: loadConfig2 } = await Promise.resolve().then(() => (init_load(), load_exports));
239
- await core2.init({
240
- config: loadConfig2(
241
- core2._options.configPath,
242
- core2._options.outDir,
243
- buildConfig2
244
- )
245
- });
246
- return core2.getConfig();
247
- }
281
+ function createCore(options, defaultPlugins = []) {
282
+ let config;
283
+ let plugins2;
248
284
  return {
249
- async getConfig() {
250
- return cached ??= newConfig();
285
+ _options: options,
286
+ getPluginContext() {
287
+ return {
288
+ core: this,
289
+ ...options
290
+ };
291
+ },
292
+ /**
293
+ * Convenient cache store, reset when config changes
294
+ */
295
+ cache: /* @__PURE__ */ new Map(),
296
+ async init({ config: newConfig }) {
297
+ config = await newConfig;
298
+ this.cache.clear();
299
+ plugins2 = [];
300
+ for await (const option of [
301
+ ...defaultPlugins,
302
+ ...config.global.plugins ?? []
303
+ ]) {
304
+ if (!option) continue;
305
+ if (Array.isArray(option)) plugins2.push(...option);
306
+ else plugins2.push(option);
307
+ }
308
+ for (const plugin of plugins2) {
309
+ const out = await plugin.config?.call(this.getPluginContext(), config);
310
+ if (out) config = out;
311
+ }
312
+ return this;
313
+ },
314
+ getConfig() {
315
+ return config;
316
+ },
317
+ async initServer(server) {
318
+ for (const plugin of plugins2) {
319
+ await plugin.configureServer?.call(this.getPluginContext(), server);
320
+ }
321
+ },
322
+ async emitAndWrite({
323
+ filterPlugin = () => true
324
+ } = {}) {
325
+ const start = performance.now();
326
+ const out = await Promise.all(
327
+ plugins2.map((plugin) => {
328
+ if (!filterPlugin(plugin) || !plugin.emit) return [];
329
+ return plugin.emit.call(this.getPluginContext());
330
+ })
331
+ );
332
+ await Promise.all(
333
+ out.flat().map(async (entry) => {
334
+ const file = import_node_path.default.join(options.outDir, entry.path);
335
+ await import_promises.default.mkdir(import_node_path.default.dirname(file), { recursive: true });
336
+ await import_promises.default.writeFile(file, entry.content);
337
+ })
338
+ );
339
+ console.log(`[MDX] generated files in ${performance.now() - start}ms`);
251
340
  }
252
341
  };
253
342
  }
@@ -335,7 +424,7 @@ var import_mdx = require("@mdx-js/mdx");
335
424
  // src/loaders/mdx/remark-include.ts
336
425
  var import_unified = require("unified");
337
426
  var import_unist_util_visit2 = require("unist-util-visit");
338
- var path4 = __toESM(require("path"), 1);
427
+ var path3 = __toESM(require("path"), 1);
339
428
  var fs2 = __toESM(require("fs/promises"), 1);
340
429
  var import_mdx_plugins = require("fumadocs-core/mdx-plugins");
341
430
 
@@ -466,7 +555,7 @@ ${e instanceof Error ? e.message : String(e)}`,
466
555
  { cause: e }
467
556
  );
468
557
  }
469
- const ext = path4.extname(file);
558
+ const ext = path3.extname(file);
470
559
  data._compiler?.addDependency(file);
471
560
  if (params.lang || ext !== ".md" && ext !== ".mdx") {
472
561
  const lang = params.lang ?? ext.slice(1);
@@ -499,7 +588,7 @@ ${e instanceof Error ? e.message : String(e)}`,
499
588
  } else {
500
589
  mdast = await baseProcessor.run(mdast);
501
590
  }
502
- await update(mdast, path4.dirname(file), data);
591
+ await update(mdast, path3.dirname(file), data);
503
592
  return mdast;
504
593
  };
505
594
  async function update(tree, directory, data) {
@@ -511,7 +600,7 @@ ${e instanceof Error ? e.message : String(e)}`,
511
600
  if (specifier.length === 0) return "skip";
512
601
  const attributes = parseElementAttributes(node);
513
602
  const { file: relativePath, section } = parseSpecifier(specifier);
514
- const file = path4.resolve(
603
+ const file = path3.resolve(
515
604
  "cwd" in attributes ? process.cwd() : directory,
516
605
  relativePath
517
606
  );
@@ -528,7 +617,7 @@ ${e instanceof Error ? e.message : String(e)}`,
528
617
  await Promise.all(queue);
529
618
  }
530
619
  return async (tree, file) => {
531
- await update(tree, path4.dirname(file.path), file.data);
620
+ await update(tree, path3.dirname(file.path), file.data);
532
621
  };
533
622
  }
534
623
 
@@ -696,7 +785,7 @@ var cacheEntry = import_zod.z.object({
696
785
  map: import_zod.z.any().optional(),
697
786
  hash: import_zod.z.string().optional()
698
787
  });
699
- function createMdxLoader(configLoader) {
788
+ function createMdxLoader(configLoader2) {
700
789
  return async ({
701
790
  source: value,
702
791
  development: isDevelopment,
@@ -706,7 +795,7 @@ function createMdxLoader(configLoader) {
706
795
  }) => {
707
796
  const matter = fumaMatter(value);
708
797
  const parsed = querySchema.parse(query);
709
- const config = await configLoader.getConfig();
798
+ const config = await configLoader2.getConfig();
710
799
  let after;
711
800
  if (!isDevelopment && config.global.experimentalBuildCache) {
712
801
  const cacheDir = config.global.experimentalBuildCache;
@@ -724,7 +813,7 @@ function createMdxLoader(configLoader) {
724
813
  );
725
814
  };
726
815
  }
727
- const collection = parsed.collection ? config.collections.get(parsed.collection) : void 0;
816
+ const collection = parsed.collection ? config.getCollection(parsed.collection) : void 0;
728
817
  let docCollection;
729
818
  switch (collection?.type) {
730
819
  case "doc":
@@ -797,16 +886,15 @@ function countLines(s) {
797
886
  }
798
887
 
799
888
  // src/loaders/adapter.ts
800
- var import_node_url2 = require("url");
889
+ var import_node_url = require("url");
801
890
  var import_promises3 = __toESM(require("fs/promises"), 1);
802
891
  var import_node_querystring = require("querystring");
803
892
  var import_node_path4 = __toESM(require("path"), 1);
804
- function toNode(loader, filterByPath) {
893
+ function toNode(loader, test) {
805
894
  return async (url, _context, nextLoad) => {
806
- if (!url.startsWith("file:///")) return nextLoad(url);
807
- const parsedUrl = new URL(url);
808
- const filePath = (0, import_node_url2.fileURLToPath)(parsedUrl);
809
- if (filterByPath(filePath)) {
895
+ if (url.startsWith("file:///") && test.test(url)) {
896
+ const parsedUrl = new URL(url);
897
+ const filePath = (0, import_node_url.fileURLToPath)(parsedUrl);
810
898
  const source = (await import_promises3.default.readFile(filePath)).toString();
811
899
  const result = await loader({
812
900
  filePath,
@@ -818,104 +906,130 @@ function toNode(loader, filterByPath) {
818
906
  }
819
907
  }
820
908
  });
821
- return {
822
- source: result.code,
823
- format: "module",
824
- shortCircuit: true
825
- };
909
+ if (result) {
910
+ return {
911
+ source: result.code,
912
+ format: "module",
913
+ shortCircuit: true
914
+ };
915
+ }
826
916
  }
827
917
  return nextLoad(url);
828
918
  };
829
919
  }
830
920
 
831
- // src/core.ts
832
- var import_node_path5 = __toESM(require("path"), 1);
921
+ // src/loaders/config.ts
833
922
  var import_promises4 = __toESM(require("fs/promises"), 1);
834
- function createCore(options, defaultPlugins = []) {
835
- let config;
836
- let plugins2;
923
+ function createStandaloneConfigLoader({
924
+ core: core2,
925
+ buildConfig: buildConfig2,
926
+ mode
927
+ }) {
928
+ let loaded;
929
+ async function getConfigHash2() {
930
+ if (mode === "production") return "static";
931
+ const stats = await import_promises4.default.stat(core2._options.configPath).catch(() => {
932
+ throw new Error("Cannot find config file");
933
+ });
934
+ return stats.mtime.getTime().toString();
935
+ }
936
+ async function newConfig() {
937
+ const { loadConfig: loadConfig2 } = await Promise.resolve().then(() => (init_load_from_file(), load_from_file_exports));
938
+ await core2.init({
939
+ config: loadConfig2(
940
+ core2._options.configPath,
941
+ core2._options.outDir,
942
+ buildConfig2
943
+ )
944
+ });
945
+ return core2.getConfig();
946
+ }
837
947
  return {
838
- _options: options,
839
- getPluginContext() {
840
- return {
841
- core: this,
842
- ...options
843
- };
844
- },
845
- /**
846
- * Convenient cache store, reset when config changes
847
- */
848
- cache: /* @__PURE__ */ new Map(),
849
- async init({ config: newConfig }) {
850
- config = await newConfig;
851
- this.cache.clear();
852
- plugins2 = [];
853
- for await (const option of [
854
- ...defaultPlugins,
855
- ...config.global.plugins ?? []
856
- ]) {
857
- if (!option) continue;
858
- if (Array.isArray(option)) plugins2.push(...option);
859
- else plugins2.push(option);
860
- }
861
- for (const plugin of plugins2) {
862
- const out = await plugin.config?.call(this.getPluginContext(), config);
863
- if (out) config = out;
864
- }
865
- return this;
866
- },
867
- getConfig() {
868
- return config;
869
- },
870
- creatConfigLoader() {
871
- return {
872
- getConfig() {
873
- return config;
874
- }
948
+ async getConfig() {
949
+ const hash = await getConfigHash2();
950
+ if (loaded && loaded.hash === hash) return loaded.config;
951
+ loaded = {
952
+ hash,
953
+ config: newConfig()
875
954
  };
876
- },
877
- async initServer(server) {
878
- for (const plugin of plugins2) {
879
- await plugin.configureServer?.call(this.getPluginContext(), server);
880
- }
881
- },
882
- async emitAndWrite({
883
- filterPlugin = () => true
884
- } = {}) {
885
- const start = performance.now();
886
- const out = await Promise.all(
887
- plugins2.map((plugin) => {
888
- if (!filterPlugin(plugin) || !plugin.emit) return [];
889
- return plugin.emit.call(this.getPluginContext());
890
- })
891
- );
892
- await Promise.all(
893
- out.flat().map(async (entry) => {
894
- const file = import_node_path5.default.join(options.outDir, entry.path);
895
- await import_promises4.default.mkdir(import_node_path5.default.dirname(file), { recursive: true });
896
- await import_promises4.default.writeFile(file, entry.content);
897
- })
955
+ return loaded.config;
956
+ }
957
+ };
958
+ }
959
+
960
+ // src/loaders/meta.ts
961
+ var import_js_yaml2 = require("js-yaml");
962
+ var import_zod2 = require("zod");
963
+ var querySchema2 = import_zod2.z.object({
964
+ collection: import_zod2.z.string().optional()
965
+ }).loose();
966
+ function createMetaLoader(configLoader2, resolve3 = {}) {
967
+ const { json: resolveJson = "js", yaml: resolveYaml = "js" } = resolve3;
968
+ return async ({ filePath, query, source }) => {
969
+ const isJson = filePath.endsWith(".json");
970
+ const parsed = querySchema2.parse(query);
971
+ const collection = parsed.collection ? (await configLoader2.getConfig()).getCollection(parsed.collection) : void 0;
972
+ if (!collection) return null;
973
+ let data;
974
+ try {
975
+ data = isJson ? JSON.parse(source) : (0, import_js_yaml2.load)(source);
976
+ } catch (e) {
977
+ throw new Error(`invalid data in ${filePath}`, { cause: e });
978
+ }
979
+ let schema;
980
+ switch (collection?.type) {
981
+ case "meta":
982
+ schema = collection.schema;
983
+ break;
984
+ case "docs":
985
+ schema = collection.meta.schema;
986
+ break;
987
+ }
988
+ if (schema) {
989
+ data = await validate(
990
+ schema,
991
+ data,
992
+ { path: filePath, source },
993
+ `invalid data in ${filePath}`
898
994
  );
899
- console.log(`[MDX] generated files in ${performance.now() - start}ms`);
900
995
  }
996
+ let code;
997
+ if (isJson) {
998
+ code = resolveJson === "json" ? JSON.stringify(data) : `export default ${JSON.stringify(data)}`;
999
+ } else {
1000
+ code = resolveYaml === "yaml" ? (0, import_js_yaml2.dump)(data) : `export default ${JSON.stringify(data)}`;
1001
+ }
1002
+ return {
1003
+ code,
1004
+ map: null
1005
+ };
901
1006
  };
902
1007
  }
903
1008
 
1009
+ // src/loaders/index.ts
1010
+ var metaLoaderGlob = /\.(json|yaml)(\?.+?)?$/;
1011
+ var mdxLoaderGlob = /\.mdx?(\?.+?)?$/;
1012
+
904
1013
  // src/node/loader.ts
905
1014
  var core = createCore({
906
1015
  environment: "node",
907
1016
  configPath: findConfigFile(),
908
1017
  outDir: ".source"
909
1018
  });
910
- var load2 = toNode(
911
- createMdxLoader(
912
- staticConfig({
913
- core,
914
- buildConfig: true
915
- })
916
- ),
917
- (filePath) => filePath.endsWith(".md") || filePath.endsWith(".mdx")
918
- );
1019
+ var configLoader = createStandaloneConfigLoader({
1020
+ core,
1021
+ buildConfig: true,
1022
+ mode: "production"
1023
+ });
1024
+ var mdxLoader = toNode(createMdxLoader(configLoader), mdxLoaderGlob);
1025
+ var metaLoader = toNode(createMetaLoader(configLoader), metaLoaderGlob);
1026
+ var load3 = (url, context, nextLoad) => {
1027
+ return mdxLoader(
1028
+ url,
1029
+ context,
1030
+ (v, ctx) => metaLoader(v, { ...context, ...ctx }, nextLoad)
1031
+ );
1032
+ };
919
1033
  // Annotate the CommonJS export names for ESM import in node:
920
1034
  0 && (module.exports = {
921
1035
  load
@@ -1,5 +1,5 @@
1
- import * as module from 'module';
1
+ import { LoadHook } from 'node:module';
2
2
 
3
- declare const load: module.LoadHook;
3
+ declare const load: LoadHook;
4
4
 
5
5
  export { load };
@@ -1,5 +1,5 @@
1
- import * as module from 'module';
1
+ import { LoadHook } from 'node:module';
2
2
 
3
- declare const load: module.LoadHook;
3
+ declare const load: LoadHook;
4
4
 
5
5
  export { load };
@@ -1,16 +1,24 @@
1
- import {
2
- toNode
3
- } from "../chunk-YVCR6FUH.js";
4
1
  import {
5
2
  createMdxLoader
6
- } from "../chunk-XQ5O7IPO.js";
3
+ } from "../chunk-XYGORKQA.js";
4
+ import {
5
+ createMetaLoader
6
+ } from "../chunk-YAIPHUCZ.js";
7
+ import {
8
+ createStandaloneConfigLoader,
9
+ toNode
10
+ } from "../chunk-ZNVPB2IR.js";
7
11
  import "../chunk-3J3WL7WN.js";
8
12
  import "../chunk-K5ZLPEIQ.js";
13
+ import {
14
+ mdxLoaderGlob,
15
+ metaLoaderGlob
16
+ } from "../chunk-4JSFLXXT.js";
17
+ import "../chunk-VUEZTR2H.js";
9
18
  import {
10
19
  createCore,
11
- findConfigFile,
12
- staticConfig
13
- } from "../chunk-EELYB2XC.js";
20
+ findConfigFile
21
+ } from "../chunk-TZ5EQBFW.js";
14
22
  import "../chunk-VWJKRQZR.js";
15
23
 
16
24
  // src/node/loader.ts
@@ -19,15 +27,20 @@ var core = createCore({
19
27
  configPath: findConfigFile(),
20
28
  outDir: ".source"
21
29
  });
22
- var load = toNode(
23
- createMdxLoader(
24
- staticConfig({
25
- core,
26
- buildConfig: true
27
- })
28
- ),
29
- (filePath) => filePath.endsWith(".md") || filePath.endsWith(".mdx")
30
- );
30
+ var configLoader = createStandaloneConfigLoader({
31
+ core,
32
+ buildConfig: true,
33
+ mode: "production"
34
+ });
35
+ var mdxLoader = toNode(createMdxLoader(configLoader), mdxLoaderGlob);
36
+ var metaLoader = toNode(createMetaLoader(configLoader), metaLoaderGlob);
37
+ var load = (url, context, nextLoad) => {
38
+ return mdxLoader(
39
+ url,
40
+ context,
41
+ (v, ctx) => metaLoader(v, { ...context, ...ctx }, nextLoad)
42
+ );
43
+ };
31
44
  export {
32
45
  load
33
46
  };