fumadocs-mdx 14.0.0 → 14.0.2

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 (77) hide show
  1. package/dist/{build-mdx-6UAK5FF5.js → build-mdx-W3233QBZ.js} +1 -1
  2. package/dist/bun/index.d.ts +7 -1
  3. package/dist/bun/index.js +9 -8
  4. package/dist/{chunk-5YXP7JLN.js → chunk-5OBUOALK.js} +8 -5
  5. package/dist/{chunk-ZY6UZ7NH.js → chunk-6RPNS75C.js} +1 -1
  6. package/dist/{chunk-XHJCLBZ4.js → chunk-ED3ON275.js} +86 -162
  7. package/dist/{chunk-7L2KNF6B.js → chunk-GB4W3YCZ.js} +51 -7
  8. package/dist/{chunk-SLY7WXTX.js → chunk-KOPLIEVQ.js} +5 -6
  9. package/dist/{chunk-OXSRIWQW.js → chunk-LPX7ZO66.js} +4 -3
  10. package/dist/{chunk-SRSRFOVI.js → chunk-OLL7FM7W.js} +3 -3
  11. package/dist/{chunk-5UMZCWKV.js → chunk-Q5OSGLJL.js} +1 -1
  12. package/dist/{chunk-E5DJTSIM.js → chunk-S7KOJHHO.js} +4 -1
  13. package/dist/{chunk-6NISOLQ6.js → chunk-USWQVJWR.js} +1 -1
  14. package/dist/chunk-WBIHDYMN.js +126 -0
  15. package/dist/config/index.d.ts +6 -1
  16. package/dist/config/index.js +1 -1
  17. package/dist/{index-D7JdSMpp.d.cts → core-C3QZSdEx.d.ts} +73 -4
  18. package/dist/{index-BlVBvy-z.d.ts → index-RVIZxMZG.d.ts} +1 -1
  19. package/dist/index.d.ts +56 -3
  20. package/dist/load-from-file-OZ5N7DXU.js +8 -0
  21. package/dist/next/index.cjs +263 -193
  22. package/dist/next/index.d.ts +7 -2
  23. package/dist/next/index.js +12 -10
  24. package/dist/node/loader.js +4 -4
  25. package/dist/plugins/index-file.d.ts +7 -22
  26. package/dist/plugins/index-file.js +2 -2
  27. package/dist/plugins/json-schema.d.ts +7 -1
  28. package/dist/plugins/last-modified.d.ts +15 -2
  29. package/dist/plugins/last-modified.js +43 -6
  30. package/dist/runtime/browser.d.ts +22 -19
  31. package/dist/runtime/browser.js +5 -6
  32. package/dist/runtime/dynamic.d.ts +12 -12
  33. package/dist/runtime/dynamic.js +12 -11
  34. package/dist/runtime/server.d.ts +10 -157
  35. package/dist/runtime/server.js +3 -3
  36. package/dist/runtime/types.d.ts +61 -0
  37. package/dist/runtime/types.js +0 -0
  38. package/dist/vite/index.d.ts +7 -2
  39. package/dist/vite/index.js +10 -9
  40. package/dist/webpack/mdx.d.ts +8 -2
  41. package/dist/webpack/mdx.js +5 -5
  42. package/dist/webpack/meta.d.ts +8 -2
  43. package/dist/webpack/meta.js +4 -4
  44. package/package.json +4 -6
  45. package/dist/bin.cjs +0 -1889
  46. package/dist/bin.d.cts +0 -1
  47. package/dist/bun/index.cjs +0 -1112
  48. package/dist/bun/index.d.cts +0 -19
  49. package/dist/chunk-PKI7ZDA5.js +0 -29
  50. package/dist/config/index.cjs +0 -400
  51. package/dist/config/index.d.cts +0 -13
  52. package/dist/index-D7JdSMpp.d.ts +0 -272
  53. package/dist/index-P2NNUkHn.d.cts +0 -8
  54. package/dist/index.cjs +0 -18
  55. package/dist/index.d.cts +0 -8
  56. package/dist/load-from-file-I3ALLIVB.js +0 -8
  57. package/dist/next/index.d.cts +0 -28
  58. package/dist/node/loader.cjs +0 -1165
  59. package/dist/node/loader.d.cts +0 -5
  60. package/dist/plugins/index-file.cjs +0 -471
  61. package/dist/plugins/index-file.d.cts +0 -29
  62. package/dist/plugins/json-schema.cjs +0 -114
  63. package/dist/plugins/json-schema.d.cts +0 -25
  64. package/dist/plugins/last-modified.cjs +0 -75
  65. package/dist/plugins/last-modified.d.cts +0 -27
  66. package/dist/runtime/browser.cjs +0 -94
  67. package/dist/runtime/browser.d.cts +0 -50
  68. package/dist/runtime/dynamic.cjs +0 -985
  69. package/dist/runtime/dynamic.d.cts +0 -27
  70. package/dist/runtime/server.cjs +0 -173
  71. package/dist/runtime/server.d.cts +0 -161
  72. package/dist/vite/index.cjs +0 -1620
  73. package/dist/vite/index.d.cts +0 -39
  74. package/dist/webpack/mdx.cjs +0 -1089
  75. package/dist/webpack/mdx.d.cts +0 -14
  76. package/dist/webpack/meta.cjs +0 -649
  77. package/dist/webpack/meta.d.cts +0 -14
@@ -1,14 +0,0 @@
1
- import { LoaderContext } from 'webpack';
2
- import { W as WebpackLoaderOptions } from '../index-P2NNUkHn.cjs';
3
- import '../index-D7JdSMpp.cjs';
4
- import '@mdx-js/mdx';
5
- import '@standard-schema/spec';
6
- import 'unified';
7
- import 'fumadocs-core/mdx-plugins';
8
- import 'zod';
9
- import 'chokidar';
10
- import 'vfile';
11
-
12
- declare function loader(this: LoaderContext<WebpackLoaderOptions>, source: string, callback: LoaderContext<WebpackLoaderOptions>['callback']): Promise<void>;
13
-
14
- export { loader as default };
@@ -1,649 +0,0 @@
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/config/preset.ts
34
- function pluginOption(def, options = []) {
35
- const list = def(Array.isArray(options) ? options : []).filter(
36
- Boolean
37
- );
38
- if (typeof options === "function") {
39
- return options(list);
40
- }
41
- return list;
42
- }
43
- function applyMdxPreset(options = {}) {
44
- return async (environment = "bundler") => {
45
- if (options.preset === "minimal") return options;
46
- const plugins = await import("fumadocs-core/mdx-plugins");
47
- const {
48
- valueToExport = [],
49
- rehypeCodeOptions,
50
- remarkImageOptions,
51
- remarkHeadingOptions,
52
- remarkStructureOptions,
53
- remarkCodeTabOptions,
54
- remarkNpmOptions,
55
- ...mdxOptions
56
- } = options;
57
- const remarkPlugins = pluginOption(
58
- (v) => [
59
- plugins.remarkGfm,
60
- [
61
- plugins.remarkHeading,
62
- {
63
- generateToc: false,
64
- ...remarkHeadingOptions
65
- }
66
- ],
67
- remarkImageOptions !== false && [
68
- plugins.remarkImage,
69
- {
70
- ...remarkImageOptions,
71
- useImport: remarkImageOptions?.useImport ?? environment === "bundler"
72
- }
73
- ],
74
- "remarkCodeTab" in plugins && remarkCodeTabOptions !== false && [
75
- plugins.remarkCodeTab,
76
- remarkCodeTabOptions
77
- ],
78
- "remarkNpm" in plugins && remarkNpmOptions !== false && [plugins.remarkNpm, remarkNpmOptions],
79
- ...v,
80
- remarkStructureOptions !== false && [
81
- plugins.remarkStructure,
82
- remarkStructureOptions
83
- ],
84
- valueToExport.length > 0 && (() => {
85
- return (_, file) => {
86
- file.data["mdx-export"] ??= [];
87
- for (const name of valueToExport) {
88
- if (!(name in file.data)) continue;
89
- file.data["mdx-export"].push({
90
- name,
91
- value: file.data[name]
92
- });
93
- }
94
- };
95
- })
96
- ],
97
- mdxOptions.remarkPlugins
98
- );
99
- const rehypePlugins = pluginOption(
100
- (v) => [
101
- rehypeCodeOptions !== false && [plugins.rehypeCode, rehypeCodeOptions],
102
- ...v,
103
- plugins.rehypeToc
104
- ],
105
- mdxOptions.rehypePlugins
106
- );
107
- return {
108
- ...mdxOptions,
109
- outputFormat: environment === "runtime" ? "function-body" : mdxOptions.outputFormat,
110
- remarkPlugins,
111
- rehypePlugins
112
- };
113
- };
114
- }
115
- var init_preset = __esm({
116
- "src/config/preset.ts"() {
117
- "use strict";
118
- }
119
- });
120
-
121
- // src/config/build.ts
122
- function buildCollection(name, config) {
123
- if (config.type === "docs") {
124
- return {
125
- ...config,
126
- name,
127
- meta: buildPrimitiveCollection(name, config.meta),
128
- docs: buildPrimitiveCollection(name, config.docs),
129
- hasFile(filePath) {
130
- return this.docs.hasFile(filePath) || this.meta.hasFile(filePath);
131
- }
132
- };
133
- }
134
- return buildPrimitiveCollection(name, config);
135
- }
136
- function buildPrimitiveCollection(name, { files, ...config }) {
137
- const supportedFormats = SupportedFormats[config.type];
138
- const patterns = files ?? [`**/*.{${supportedFormats.join(",")}}`];
139
- let matchers;
140
- return {
141
- ...config,
142
- name,
143
- patterns,
144
- isFileSupported(filePath) {
145
- return supportedFormats.some((format) => filePath.endsWith(`.${format}`));
146
- },
147
- hasFile(filePath) {
148
- matchers ??= (Array.isArray(config.dir) ? config.dir : [config.dir]).map(
149
- (dir) => (0, import_picomatch.default)(patterns, {
150
- cwd: dir
151
- })
152
- );
153
- return this.isFileSupported(filePath) && matchers.some((matcher) => matcher(filePath));
154
- }
155
- };
156
- }
157
- function buildConfig(config) {
158
- const collections = /* @__PURE__ */ new Map();
159
- const loaded = {};
160
- for (const [k, v] of Object.entries(config)) {
161
- if (!v) {
162
- continue;
163
- }
164
- if (typeof v === "object" && "type" in v) {
165
- if (v.type === "docs") {
166
- collections.set(k, buildCollection(k, v));
167
- continue;
168
- }
169
- if (v.type === "doc" || v.type === "meta") {
170
- collections.set(
171
- k,
172
- buildCollection(k, v)
173
- );
174
- continue;
175
- }
176
- }
177
- if (k === "default" && v) {
178
- Object.assign(loaded, v);
179
- continue;
180
- }
181
- throw new Error(
182
- `Unknown export "${k}", you can only export collections from source configuration file.`
183
- );
184
- }
185
- const mdxOptionsCache = /* @__PURE__ */ new Map();
186
- return {
187
- global: loaded,
188
- collectionList: Array.from(collections.values()),
189
- getCollection(name) {
190
- return collections.get(name);
191
- },
192
- getMDXOptions(collection, environment = "bundler") {
193
- const key = collection ? `${environment}:${collection.name}` : environment;
194
- const cached = mdxOptionsCache.get(key);
195
- if (cached) return cached;
196
- let result;
197
- if (collection?.mdxOptions) {
198
- const optionsFn = collection.mdxOptions;
199
- result = typeof optionsFn === "function" ? optionsFn(environment) : optionsFn;
200
- } else {
201
- result = (async () => {
202
- const optionsFn = this.global.mdxOptions;
203
- const options = typeof optionsFn === "function" ? await optionsFn() : optionsFn;
204
- return applyMdxPreset(options)(environment);
205
- })();
206
- }
207
- mdxOptionsCache.set(key, result);
208
- return result;
209
- }
210
- };
211
- }
212
- var import_picomatch, SupportedFormats;
213
- var init_build = __esm({
214
- "src/config/build.ts"() {
215
- "use strict";
216
- import_picomatch = __toESM(require("picomatch"), 1);
217
- init_preset();
218
- SupportedFormats = {
219
- doc: ["mdx", "md"],
220
- meta: ["json", "yaml"]
221
- };
222
- }
223
- });
224
-
225
- // src/config/load-from-file.ts
226
- var load_from_file_exports = {};
227
- __export(load_from_file_exports, {
228
- loadConfig: () => loadConfig
229
- });
230
- async function compileConfig(core2) {
231
- const { build } = await import("esbuild");
232
- const transformed = await build({
233
- entryPoints: [{ in: core2._options.configPath, out: "source.config" }],
234
- bundle: true,
235
- outdir: core2._options.outDir,
236
- target: "node20",
237
- write: true,
238
- platform: "node",
239
- format: "esm",
240
- packages: "external",
241
- outExtension: {
242
- ".js": ".mjs"
243
- },
244
- allowOverwrite: true
245
- });
246
- if (transformed.errors.length > 0) {
247
- throw new Error("failed to compile configuration file");
248
- }
249
- }
250
- async function loadConfig(core2, build = false) {
251
- if (build) await compileConfig(core2);
252
- const url = (0, import_node_url2.pathToFileURL)(core2.getCompiledConfigPath());
253
- url.searchParams.set("hash", Date.now().toString());
254
- const config = import(url.href).then(
255
- (loaded) => buildConfig(loaded)
256
- );
257
- return await config;
258
- }
259
- var import_node_url2;
260
- var init_load_from_file = __esm({
261
- "src/config/load-from-file.ts"() {
262
- "use strict";
263
- import_node_url2 = require("url");
264
- init_build();
265
- }
266
- });
267
-
268
- // src/webpack/meta.ts
269
- var meta_exports = {};
270
- __export(meta_exports, {
271
- default: () => loader
272
- });
273
- module.exports = __toCommonJS(meta_exports);
274
-
275
- // src/loaders/adapter.ts
276
- var import_node_url = require("url");
277
- var import_promises = __toESM(require("fs/promises"), 1);
278
- var import_node_querystring = require("querystring");
279
-
280
- // src/utils/validation.ts
281
- var ValidationError = class extends Error {
282
- constructor(message, issues) {
283
- super(
284
- `${message}:
285
- ${issues.map((issue) => ` ${issue.path}: ${issue.message}`).join("\n")}`
286
- );
287
- this.title = message;
288
- this.issues = issues;
289
- }
290
- async toStringFormatted() {
291
- const picocolors = await import("picocolors");
292
- return [
293
- picocolors.bold(`[MDX] ${this.title}:`),
294
- ...this.issues.map(
295
- (issue) => picocolors.redBright(
296
- `- ${picocolors.bold(issue.path?.join(".") ?? "*")}: ${issue.message}`
297
- )
298
- )
299
- ].join("\n");
300
- }
301
- };
302
- async function validate(schema, data, context, errorMessage) {
303
- if (typeof schema === "function" && !("~standard" in schema)) {
304
- schema = schema(context);
305
- }
306
- if ("~standard" in schema) {
307
- const result = await schema["~standard"].validate(
308
- data
309
- );
310
- if (result.issues) {
311
- throw new ValidationError(errorMessage, result.issues);
312
- }
313
- return result.value;
314
- }
315
- return data;
316
- }
317
-
318
- // src/loaders/adapter.ts
319
- var import_node_path = __toESM(require("path"), 1);
320
- var import_node_fs = require("fs");
321
- function toWebpack(loader2) {
322
- return async function(source, callback) {
323
- try {
324
- const result = await loader2.load({
325
- filePath: this.resourcePath,
326
- query: (0, import_node_querystring.parse)(this.resourceQuery.slice(1)),
327
- getSource() {
328
- return source;
329
- },
330
- development: this.mode === "development",
331
- compiler: this
332
- });
333
- if (result === null) {
334
- callback(void 0, source);
335
- } else {
336
- callback(void 0, result.code, result.map);
337
- }
338
- } catch (error) {
339
- if (error instanceof ValidationError) {
340
- return callback(new Error(await error.toStringFormatted()));
341
- }
342
- if (!(error instanceof Error)) throw error;
343
- const fpath = import_node_path.default.relative(this.context, this.resourcePath);
344
- error.message = `${fpath}:${error.name}: ${error.message}`;
345
- callback(error);
346
- }
347
- };
348
- }
349
-
350
- // src/loaders/config.ts
351
- var import_promises2 = __toESM(require("fs/promises"), 1);
352
- function createStandaloneConfigLoader({
353
- core: core2,
354
- buildConfig: buildConfig2,
355
- mode
356
- }) {
357
- let loaded;
358
- async function getConfigHash() {
359
- if (mode === "production") return "static";
360
- const stats = await import_promises2.default.stat(core2._options.configPath).catch(() => {
361
- throw new Error("Cannot find config file");
362
- });
363
- return stats.mtime.getTime().toString();
364
- }
365
- async function newConfig() {
366
- const { loadConfig: loadConfig2 } = await Promise.resolve().then(() => (init_load_from_file(), load_from_file_exports));
367
- await core2.init({
368
- config: loadConfig2(core2, buildConfig2)
369
- });
370
- return core2.getConfig();
371
- }
372
- return {
373
- core: core2,
374
- async getConfig() {
375
- const hash = await getConfigHash();
376
- if (loaded && loaded.hash === hash) return loaded.config;
377
- loaded = {
378
- hash,
379
- config: newConfig()
380
- };
381
- return loaded.config;
382
- }
383
- };
384
- }
385
-
386
- // src/loaders/meta.ts
387
- var import_js_yaml = require("js-yaml");
388
- var import_zod = require("zod");
389
-
390
- // src/loaders/index.ts
391
- var metaLoaderGlob = /\.(json|yaml)(\?.+?)?$/;
392
-
393
- // src/loaders/meta.ts
394
- var querySchema = import_zod.z.object({
395
- collection: import_zod.z.string().optional()
396
- }).loose();
397
- function createMetaLoader(configLoader, resolve = {}) {
398
- const { json: resolveJson = "js", yaml: resolveYaml = "js" } = resolve;
399
- function parse2(filePath, source) {
400
- try {
401
- if (filePath.endsWith(".json")) return JSON.parse(source);
402
- if (filePath.endsWith(".yaml")) return (0, import_js_yaml.load)(source);
403
- } catch (e) {
404
- throw new Error(`invalid data in ${filePath}`, { cause: e });
405
- }
406
- throw new Error("Unknown file type " + filePath);
407
- }
408
- function onMeta(source, { filePath, query }) {
409
- const parsed = querySchema.safeParse(query);
410
- if (!parsed.success || !parsed.data.collection) return null;
411
- const collectionName = parsed.data.collection;
412
- return async () => {
413
- const config = await configLoader.getConfig();
414
- const collection = config.getCollection(collectionName);
415
- let metaCollection;
416
- switch (collection?.type) {
417
- case "meta":
418
- metaCollection = collection;
419
- break;
420
- case "docs":
421
- metaCollection = collection.meta;
422
- break;
423
- }
424
- const data = parse2(filePath, source);
425
- if (!metaCollection) return data;
426
- return configLoader.core.transformMeta(
427
- {
428
- collection: metaCollection,
429
- filePath,
430
- source
431
- },
432
- data
433
- );
434
- };
435
- }
436
- return {
437
- test: metaLoaderGlob,
438
- async load(input) {
439
- const result = onMeta(await input.getSource(), input);
440
- if (result === null) return null;
441
- const data = await result();
442
- if (input.filePath.endsWith(".json")) {
443
- return {
444
- code: resolveJson === "json" ? JSON.stringify(data) : `export default ${JSON.stringify(data)}`
445
- };
446
- } else {
447
- return {
448
- code: resolveYaml === "yaml" ? (0, import_js_yaml.dump)(data) : `export default ${JSON.stringify(data)}`
449
- };
450
- }
451
- },
452
- bun: {
453
- load(source, input) {
454
- const result = onMeta(source, input);
455
- if (result === null)
456
- return {
457
- loader: "object",
458
- exports: parse2(input.filePath, source)
459
- };
460
- return result().then((data) => ({
461
- loader: "object",
462
- exports: { default: data }
463
- }));
464
- }
465
- }
466
- };
467
- }
468
-
469
- // src/core.ts
470
- var import_node_path3 = __toESM(require("path"), 1);
471
- var import_promises4 = __toESM(require("fs/promises"), 1);
472
-
473
- // src/utils/codegen/cache.ts
474
- var import_lru_cache = require("lru-cache");
475
- var import_promises3 = __toESM(require("fs/promises"), 1);
476
- var import_node_path2 = __toESM(require("path"), 1);
477
- var map = new import_lru_cache.LRUCache({
478
- max: 100
479
- });
480
- function toFullPath(file) {
481
- if (import_node_path2.default.isAbsolute(file)) {
482
- return import_node_path2.default.relative(process.cwd(), file);
483
- }
484
- return file;
485
- }
486
- function removeFileCache(file) {
487
- map.delete(toFullPath(file));
488
- }
489
-
490
- // src/core.ts
491
- async function getPlugins(pluginOptions) {
492
- const plugins = [];
493
- for await (const option of pluginOptions) {
494
- if (!option) continue;
495
- if (Array.isArray(option)) plugins.push(...await getPlugins(option));
496
- else plugins.push(option);
497
- }
498
- return plugins;
499
- }
500
- function createCore(options, defaultPlugins = []) {
501
- let config;
502
- let plugins;
503
- async function transformMetadata({
504
- collection,
505
- filePath,
506
- source
507
- }, data) {
508
- if (collection.schema) {
509
- data = await validate(
510
- collection.schema,
511
- data,
512
- { path: filePath, source },
513
- collection.type === "doc" ? `invalid frontmatter in ${filePath}` : `invalid data in ${filePath}`
514
- );
515
- }
516
- return data;
517
- }
518
- const core2 = {
519
- _options: options,
520
- /**
521
- * Convenient cache store, reset when config changes
522
- */
523
- cache: /* @__PURE__ */ new Map(),
524
- async init({ config: newConfig }) {
525
- config = await newConfig;
526
- this.cache.clear();
527
- plugins = await getPlugins([
528
- ...defaultPlugins,
529
- ...config.global.plugins ?? []
530
- ]);
531
- for (const plugin of plugins) {
532
- const out = await plugin.config?.call(pluginContext, config);
533
- if (out) config = out;
534
- }
535
- return this;
536
- },
537
- getConfig() {
538
- return config;
539
- },
540
- /**
541
- * The file path of compiled config file, the file may not exist (e.g. on Vite, or still compiling)
542
- */
543
- getCompiledConfigPath() {
544
- return import_node_path3.default.join(options.outDir, "source.config.mjs");
545
- },
546
- async initServer(server) {
547
- server.watcher?.on("all", async (event, file) => {
548
- if (event === "change") removeFileCache(file);
549
- });
550
- for (const plugin of plugins) {
551
- await plugin.configureServer?.call(pluginContext, server);
552
- }
553
- },
554
- async emit({ filterPlugin = () => true } = {}) {
555
- return (await Promise.all(
556
- plugins.map((plugin) => {
557
- if (!filterPlugin(plugin) || !plugin.emit) return [];
558
- return plugin.emit.call(pluginContext);
559
- })
560
- )).flat();
561
- },
562
- async emitAndWrite(emitOptions) {
563
- const start = performance.now();
564
- const out = await this.emit(emitOptions);
565
- await Promise.all(
566
- out.map(async (entry) => {
567
- const file = import_node_path3.default.join(options.outDir, entry.path);
568
- await import_promises4.default.mkdir(import_node_path3.default.dirname(file), { recursive: true });
569
- await import_promises4.default.writeFile(file, entry.content);
570
- })
571
- );
572
- console.log(`[MDX] generated files in ${performance.now() - start}ms`);
573
- },
574
- async transformMeta(options2, data) {
575
- const ctx = {
576
- ...pluginContext,
577
- ...options2
578
- };
579
- data = await transformMetadata(options2, data);
580
- for (const plugin of plugins) {
581
- if (plugin.meta?.transform)
582
- data = await plugin.meta.transform.call(ctx, data) ?? data;
583
- }
584
- return data;
585
- },
586
- async transformFrontmatter(options2, data) {
587
- const ctx = {
588
- ...pluginContext,
589
- ...options2
590
- };
591
- data = await transformMetadata(options2, data);
592
- for (const plugin of plugins) {
593
- if (plugin.doc?.frontmatter)
594
- data = await plugin.doc.frontmatter.call(ctx, data) ?? data;
595
- }
596
- return data;
597
- },
598
- async transformVFile(options2, file) {
599
- const ctx = {
600
- ...pluginContext,
601
- ...options2
602
- };
603
- for (const plugin of plugins) {
604
- if (plugin.doc?.vfile)
605
- file = await plugin.doc.vfile.call(ctx, file) ?? file;
606
- }
607
- return file;
608
- }
609
- };
610
- const pluginContext = {
611
- core: core2,
612
- ...options
613
- };
614
- return core2;
615
- }
616
-
617
- // src/webpack/index.ts
618
- var core;
619
- function getCore(options) {
620
- return core ??= createCore({
621
- environment: "webpack",
622
- outDir: options.outDir,
623
- configPath: options.configPath
624
- });
625
- }
626
-
627
- // src/webpack/meta.ts
628
- var instance;
629
- async function loader(source, callback) {
630
- const options = this.getOptions();
631
- this.cacheable(true);
632
- this.addDependency(options.compiledConfigPath);
633
- if (!instance) {
634
- instance = toWebpack(
635
- createMetaLoader(
636
- createStandaloneConfigLoader({
637
- core: getCore(options),
638
- buildConfig: false,
639
- mode: options.isDev ? "dev" : "production"
640
- }),
641
- {
642
- json: "json",
643
- yaml: "js"
644
- }
645
- )
646
- );
647
- }
648
- await instance.call(this, source, callback);
649
- }
@@ -1,14 +0,0 @@
1
- import { LoaderContext } from 'webpack';
2
- import { W as WebpackLoaderOptions } from '../index-P2NNUkHn.cjs';
3
- import '../index-D7JdSMpp.cjs';
4
- import '@mdx-js/mdx';
5
- import '@standard-schema/spec';
6
- import 'unified';
7
- import 'fumadocs-core/mdx-plugins';
8
- import 'zod';
9
- import 'chokidar';
10
- import 'vfile';
11
-
12
- declare function loader(this: LoaderContext<WebpackLoaderOptions>, source: string, callback: LoaderContext<WebpackLoaderOptions>['callback']): Promise<void>;
13
-
14
- export { loader as default };