fumadocs-mdx 13.0.5 → 13.0.7

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 (42) hide show
  1. package/dist/bin.cjs +162 -131
  2. package/dist/{build-mdx-BjXOmv0b.d.cts → build-mdx-BnJhW5O1.d.cts} +1 -1
  3. package/dist/{build-mdx-CY5UldCO.d.ts → build-mdx-DNzfRRlY.d.ts} +1 -1
  4. package/dist/bun/index.cjs +156 -132
  5. package/dist/bun/index.d.cts +7 -2
  6. package/dist/bun/index.d.ts +7 -2
  7. package/dist/bun/index.js +8 -11
  8. package/dist/{chunk-TZ5EQBFW.js → chunk-2AQRQXSO.js} +7 -1
  9. package/dist/chunk-2E2JCOSO.js +135 -0
  10. package/dist/chunk-4757L6ST.js +77 -0
  11. package/dist/{chunk-ZNVPB2IR.js → chunk-ETIN2W7C.js} +49 -41
  12. package/dist/config/index.d.cts +1 -1
  13. package/dist/config/index.d.ts +1 -1
  14. package/dist/{core-DB7TdlyC.d.cts → core-HkAVGq_a.d.cts} +1 -1
  15. package/dist/{core-DB7TdlyC.d.ts → core-HkAVGq_a.d.ts} +1 -1
  16. package/dist/index.d.cts +3 -3
  17. package/dist/index.d.ts +3 -3
  18. package/dist/next/index.js +2 -4
  19. package/dist/node/loader.cjs +146 -119
  20. package/dist/node/loader.js +6 -10
  21. package/dist/plugins/json-schema.d.cts +1 -1
  22. package/dist/plugins/json-schema.d.ts +1 -1
  23. package/dist/runtime/next/async.d.cts +3 -3
  24. package/dist/runtime/next/async.d.ts +3 -3
  25. package/dist/runtime/next/index.d.cts +4 -4
  26. package/dist/runtime/next/index.d.ts +4 -4
  27. package/dist/runtime/vite/browser.d.cts +2 -2
  28. package/dist/runtime/vite/browser.d.ts +2 -2
  29. package/dist/runtime/vite/server.d.cts +2 -2
  30. package/dist/runtime/vite/server.d.ts +2 -2
  31. package/dist/{types-Bnh9n7mj.d.cts → types-By6wKOnT.d.cts} +1 -1
  32. package/dist/{types-ey1AZqrg.d.ts → types-DgD5Omj2.d.ts} +1 -1
  33. package/dist/vite/index.cjs +166 -134
  34. package/dist/vite/index.js +8 -14
  35. package/dist/webpack/mdx.cjs +86 -75
  36. package/dist/webpack/mdx.js +3 -3
  37. package/dist/webpack/meta.cjs +64 -37
  38. package/dist/webpack/meta.js +3 -3
  39. package/package.json +7 -7
  40. package/dist/chunk-4JSFLXXT.js +0 -8
  41. package/dist/chunk-XYGORKQA.js +0 -130
  42. package/dist/chunk-YAIPHUCZ.js +0 -56
@@ -707,6 +707,11 @@ var import_zod = require("zod");
707
707
  var import_promises = __toESM(require("fs/promises"), 1);
708
708
  var import_node_path2 = __toESM(require("path"), 1);
709
709
  var import_node_crypto = require("crypto");
710
+
711
+ // src/loaders/index.ts
712
+ var mdxLoaderGlob = /\.mdx?(\?.+?)?$/;
713
+
714
+ // src/loaders/mdx/index.ts
710
715
  var querySchema = import_zod.z.object({
711
716
  only: import_zod.z.literal(["frontmatter", "all"]).default("all"),
712
717
  collection: import_zod.z.string().optional()
@@ -717,84 +722,88 @@ var cacheEntry = import_zod.z.object({
717
722
  hash: import_zod.z.string().optional()
718
723
  });
719
724
  function createMdxLoader(configLoader) {
720
- return async ({
721
- source: value,
722
- development: isDevelopment,
723
- query,
724
- compiler,
725
- filePath
726
- }) => {
727
- const matter = fumaMatter(value);
728
- const parsed = querySchema.parse(query);
729
- const config = await configLoader.getConfig();
730
- let after;
731
- if (!isDevelopment && config.global.experimentalBuildCache) {
732
- const cacheDir = config.global.experimentalBuildCache;
733
- const cacheKey = `${parsed.hash}_${parsed.collection ?? "global"}_${generateCacheHash(filePath)}`;
734
- const cached = await import_promises.default.readFile(import_node_path2.default.join(cacheDir, cacheKey)).then((content) => cacheEntry.parse(JSON.parse(content.toString()))).catch(() => null);
735
- if (cached && cached.hash === generateCacheHash(value)) return cached;
736
- after = async () => {
737
- await import_promises.default.mkdir(cacheDir, { recursive: true });
738
- await import_promises.default.writeFile(
739
- import_node_path2.default.join(cacheDir, cacheKey),
740
- JSON.stringify({
741
- ...out,
742
- hash: generateCacheHash(value)
743
- })
725
+ return {
726
+ test: mdxLoaderGlob,
727
+ async load({
728
+ getSource,
729
+ development: isDevelopment,
730
+ query,
731
+ compiler,
732
+ filePath
733
+ }) {
734
+ const value = await getSource();
735
+ const matter = fumaMatter(value);
736
+ const parsed = querySchema.parse(query);
737
+ const config = await configLoader.getConfig();
738
+ let after;
739
+ if (!isDevelopment && config.global.experimentalBuildCache) {
740
+ const cacheDir = config.global.experimentalBuildCache;
741
+ const cacheKey = `${parsed.hash}_${parsed.collection ?? "global"}_${generateCacheHash(filePath)}`;
742
+ const cached = await import_promises.default.readFile(import_node_path2.default.join(cacheDir, cacheKey)).then((content) => cacheEntry.parse(JSON.parse(content.toString()))).catch(() => null);
743
+ if (cached && cached.hash === generateCacheHash(value)) return cached;
744
+ after = async () => {
745
+ await import_promises.default.mkdir(cacheDir, { recursive: true });
746
+ await import_promises.default.writeFile(
747
+ import_node_path2.default.join(cacheDir, cacheKey),
748
+ JSON.stringify({
749
+ ...out,
750
+ hash: generateCacheHash(value)
751
+ })
752
+ );
753
+ };
754
+ }
755
+ const collection = parsed.collection ? config.getCollection(parsed.collection) : void 0;
756
+ let docCollection;
757
+ switch (collection?.type) {
758
+ case "doc":
759
+ docCollection = collection;
760
+ break;
761
+ case "docs":
762
+ docCollection = collection.docs;
763
+ break;
764
+ }
765
+ if (docCollection?.schema) {
766
+ matter.data = await validate(
767
+ docCollection.schema,
768
+ matter.data,
769
+ {
770
+ source: value,
771
+ path: filePath
772
+ },
773
+ `invalid frontmatter in ${filePath}`
744
774
  );
745
- };
746
- }
747
- const collection = parsed.collection ? config.getCollection(parsed.collection) : void 0;
748
- let docCollection;
749
- switch (collection?.type) {
750
- case "doc":
751
- docCollection = collection;
752
- break;
753
- case "docs":
754
- docCollection = collection.docs;
755
- break;
756
- }
757
- if (docCollection?.schema) {
758
- matter.data = await validate(
759
- docCollection.schema,
760
- matter.data,
775
+ }
776
+ if (parsed.only === "frontmatter") {
777
+ return {
778
+ code: `export const frontmatter = ${JSON.stringify(matter.data)}`,
779
+ map: null
780
+ };
781
+ }
782
+ const data = {};
783
+ if (config.global.lastModifiedTime === "git") {
784
+ data.lastModified = (await getGitTimestamp(filePath))?.getTime();
785
+ }
786
+ const lineOffset = isDevelopment ? countLines(matter.matter) : 0;
787
+ const compiled = await buildMDX(
788
+ `${getConfigHash(config)}:${parsed.collection ?? "global"}`,
789
+ "\n".repeat(lineOffset) + matter.content,
761
790
  {
762
- source: value,
763
- path: filePath
764
- },
765
- `invalid frontmatter in ${filePath}`
791
+ development: isDevelopment,
792
+ ...docCollection?.mdxOptions ?? await config.getDefaultMDXOptions(),
793
+ postprocess: docCollection?.postprocess,
794
+ data,
795
+ filePath,
796
+ frontmatter: matter.data,
797
+ _compiler: compiler
798
+ }
766
799
  );
767
- }
768
- if (parsed.only === "frontmatter") {
769
- return {
770
- code: `export const frontmatter = ${JSON.stringify(matter.data)}`,
771
- map: null
800
+ const out = {
801
+ code: String(compiled.value),
802
+ map: compiled.map
772
803
  };
804
+ await after?.();
805
+ return out;
773
806
  }
774
- const data = {};
775
- if (config.global.lastModifiedTime === "git") {
776
- data.lastModified = (await getGitTimestamp(filePath))?.getTime();
777
- }
778
- const lineOffset = isDevelopment ? countLines(matter.matter) : 0;
779
- const compiled = await buildMDX(
780
- `${getConfigHash(config)}:${parsed.collection ?? "global"}`,
781
- "\n".repeat(lineOffset) + matter.content,
782
- {
783
- development: isDevelopment,
784
- ...docCollection?.mdxOptions ?? await config.getDefaultMDXOptions(),
785
- postprocess: docCollection?.postprocess,
786
- data,
787
- filePath,
788
- frontmatter: matter.data,
789
- _compiler: compiler
790
- }
791
- );
792
- const out = {
793
- code: String(compiled.value),
794
- map: compiled.map
795
- };
796
- await after?.();
797
- return out;
798
807
  };
799
808
  }
800
809
  var hashes = /* @__PURE__ */ new WeakMap();
@@ -824,10 +833,12 @@ var import_node_path3 = __toESM(require("path"), 1);
824
833
  function toWebpack(loader2) {
825
834
  return async function(source, callback) {
826
835
  try {
827
- const result = await loader2({
836
+ const result = await loader2.load({
828
837
  filePath: this.resourcePath,
829
838
  query: (0, import_node_querystring.parse)(this.resourceQuery.slice(1)),
830
- source,
839
+ getSource() {
840
+ return source;
841
+ },
831
842
  development: this.mode === "development",
832
843
  compiler: this
833
844
  });
@@ -1,16 +1,16 @@
1
1
  import {
2
2
  createMdxLoader
3
- } from "../chunk-XYGORKQA.js";
3
+ } from "../chunk-2E2JCOSO.js";
4
4
  import {
5
5
  createStandaloneConfigLoader,
6
6
  toWebpack
7
- } from "../chunk-ZNVPB2IR.js";
7
+ } from "../chunk-ETIN2W7C.js";
8
8
  import "../chunk-3J3WL7WN.js";
9
9
  import "../chunk-K5ZLPEIQ.js";
10
10
  import "../chunk-VUEZTR2H.js";
11
11
  import {
12
12
  createCore
13
- } from "../chunk-TZ5EQBFW.js";
13
+ } from "../chunk-2AQRQXSO.js";
14
14
  import "../chunk-VWJKRQZR.js";
15
15
 
16
16
  // src/webpack/mdx.ts
@@ -320,10 +320,12 @@ var import_node_path = __toESM(require("path"), 1);
320
320
  function toWebpack(loader2) {
321
321
  return async function(source, callback) {
322
322
  try {
323
- const result = await loader2({
323
+ const result = await loader2.load({
324
324
  filePath: this.resourcePath,
325
325
  query: (0, import_node_querystring.parse)(this.resourceQuery.slice(1)),
326
- source,
326
+ getSource() {
327
+ return source;
328
+ },
327
329
  development: this.mode === "development",
328
330
  compiler: this
329
331
  });
@@ -452,49 +454,74 @@ function createStandaloneConfigLoader({
452
454
  // src/loaders/meta.ts
453
455
  var import_js_yaml = require("js-yaml");
454
456
  var import_zod = require("zod");
457
+
458
+ // src/loaders/index.ts
459
+ var metaLoaderGlob = /\.(json|yaml)(\?.+?)?$/;
460
+
461
+ // src/loaders/meta.ts
455
462
  var querySchema = import_zod.z.object({
456
463
  collection: import_zod.z.string().optional()
457
464
  }).loose();
458
465
  function createMetaLoader(configLoader, resolve2 = {}) {
459
466
  const { json: resolveJson = "js", yaml: resolveYaml = "js" } = resolve2;
460
- return async ({ filePath, query, source }) => {
461
- const isJson = filePath.endsWith(".json");
462
- const parsed = querySchema.parse(query);
463
- const collection = parsed.collection ? (await configLoader.getConfig()).getCollection(parsed.collection) : void 0;
464
- if (!collection) return null;
465
- let data;
466
- try {
467
- data = isJson ? JSON.parse(source) : (0, import_js_yaml.load)(source);
468
- } catch (e) {
469
- throw new Error(`invalid data in ${filePath}`, { cause: e });
470
- }
471
- let schema;
472
- switch (collection?.type) {
473
- case "meta":
474
- schema = collection.schema;
475
- break;
476
- case "docs":
477
- schema = collection.meta.schema;
478
- break;
479
- }
480
- if (schema) {
481
- data = await validate(
482
- schema,
483
- data,
484
- { path: filePath, source },
485
- `invalid data in ${filePath}`
486
- );
487
- }
488
- let code;
467
+ function stringifyOutput(isJson, data) {
489
468
  if (isJson) {
490
- code = resolveJson === "json" ? JSON.stringify(data) : `export default ${JSON.stringify(data)}`;
469
+ return resolveJson === "json" ? JSON.stringify(data) : `export default ${JSON.stringify(data)}`;
491
470
  } else {
492
- code = resolveYaml === "yaml" ? (0, import_js_yaml.dump)(data) : `export default ${JSON.stringify(data)}`;
471
+ return resolveYaml === "yaml" ? (0, import_js_yaml.dump)(data) : `export default ${JSON.stringify(data)}`;
472
+ }
473
+ }
474
+ return {
475
+ test: metaLoaderGlob,
476
+ async load({ filePath, query, getSource }) {
477
+ const parsed = querySchema.parse(query);
478
+ const collection = parsed.collection ? (await configLoader.getConfig()).getCollection(parsed.collection) : void 0;
479
+ if (!collection) return null;
480
+ const isJson = filePath.endsWith(".json");
481
+ const source = await getSource();
482
+ let data;
483
+ try {
484
+ data = isJson ? JSON.parse(source) : (0, import_js_yaml.load)(source);
485
+ } catch (e) {
486
+ throw new Error(`invalid data in ${filePath}`, { cause: e });
487
+ }
488
+ let schema;
489
+ switch (collection?.type) {
490
+ case "meta":
491
+ schema = collection.schema;
492
+ break;
493
+ case "docs":
494
+ schema = collection.meta.schema;
495
+ break;
496
+ }
497
+ if (schema) {
498
+ data = await validate(
499
+ schema,
500
+ data,
501
+ { path: filePath, source },
502
+ `invalid data in ${filePath}`
503
+ );
504
+ }
505
+ return {
506
+ code: stringifyOutput(isJson, data)
507
+ };
508
+ },
509
+ bun: {
510
+ async fallback({ getSource, filePath }) {
511
+ const source = await getSource();
512
+ const isJson = filePath.endsWith(".json");
513
+ let data;
514
+ try {
515
+ data = isJson ? JSON.parse(source) : (0, import_js_yaml.load)(source);
516
+ } catch (e) {
517
+ throw new Error(`invalid data in ${filePath}`, { cause: e });
518
+ }
519
+ return {
520
+ loader: "object",
521
+ exports: data
522
+ };
523
+ }
493
524
  }
494
- return {
495
- code,
496
- map: null
497
- };
498
525
  };
499
526
  }
500
527
 
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  createMetaLoader
3
- } from "../chunk-YAIPHUCZ.js";
3
+ } from "../chunk-4757L6ST.js";
4
4
  import {
5
5
  createStandaloneConfigLoader,
6
6
  toWebpack
7
- } from "../chunk-ZNVPB2IR.js";
7
+ } from "../chunk-ETIN2W7C.js";
8
8
  import {
9
9
  createCore
10
- } from "../chunk-TZ5EQBFW.js";
10
+ } from "../chunk-2AQRQXSO.js";
11
11
 
12
12
  // src/webpack/meta.ts
13
13
  var instance;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-mdx",
3
- "version": "13.0.5",
3
+ "version": "13.0.7",
4
4
  "description": "The built-in source for Fumadocs",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -79,7 +79,7 @@
79
79
  "@mdx-js/mdx": "^3.1.1",
80
80
  "@standard-schema/spec": "^1.0.0",
81
81
  "chokidar": "^4.0.3",
82
- "esbuild": "^0.25.11",
82
+ "esbuild": "^0.25.12",
83
83
  "estree-util-value-to-estree": "^3.5.0",
84
84
  "js-yaml": "^4.1.0",
85
85
  "lru-cache": "^11.2.2",
@@ -87,7 +87,7 @@
87
87
  "picocolors": "^1.1.1",
88
88
  "picomatch": "^4.0.3",
89
89
  "remark-mdx": "^3.1.1",
90
- "tinyexec": "^1.0.1",
90
+ "tinyexec": "^1.0.2",
91
91
  "tinyglobby": "^0.2.15",
92
92
  "unified": "^11.0.5",
93
93
  "unist-util-remove-position": "^5.0.0",
@@ -99,10 +99,10 @@
99
99
  "@types/js-yaml": "^4.0.9",
100
100
  "@types/mdast": "^4.0.4",
101
101
  "@types/mdx": "^2.0.13",
102
- "@types/node": "^24.9.2",
102
+ "@types/node": "^24.10.0",
103
103
  "@types/picomatch": "^4.0.2",
104
104
  "@types/react": "^19.2.2",
105
- "astro": "^5.6.1",
105
+ "astro": "^5.15.3",
106
106
  "mdast-util-directive": "^3.1.0",
107
107
  "mdast-util-mdx-jsx": "^3.2.0",
108
108
  "next": "16.0.1",
@@ -112,11 +112,11 @@
112
112
  "remark-stringify": "^11.0.0",
113
113
  "rollup": "^4.52.5",
114
114
  "vfile": "^6.0.3",
115
- "vite": "^7.1.12",
115
+ "vite": "^7.2.0",
116
116
  "webpack": "^5.102.1",
117
117
  "@fumadocs/mdx-remote": "1.4.3",
118
118
  "eslint-config-custom": "0.0.0",
119
- "fumadocs-core": "16.0.7",
119
+ "fumadocs-core": "16.0.10",
120
120
  "tsconfig": "0.0.0"
121
121
  },
122
122
  "peerDependencies": {
@@ -1,8 +0,0 @@
1
- // src/loaders/index.ts
2
- var metaLoaderGlob = /\.(json|yaml)(\?.+?)?$/;
3
- var mdxLoaderGlob = /\.mdx?(\?.+?)?$/;
4
-
5
- export {
6
- metaLoaderGlob,
7
- mdxLoaderGlob
8
- };
@@ -1,130 +0,0 @@
1
- import {
2
- buildMDX
3
- } from "./chunk-3J3WL7WN.js";
4
- import {
5
- getGitTimestamp
6
- } from "./chunk-VUEZTR2H.js";
7
- import {
8
- validate
9
- } from "./chunk-TZ5EQBFW.js";
10
- import {
11
- fumaMatter
12
- } from "./chunk-VWJKRQZR.js";
13
-
14
- // src/loaders/mdx/index.ts
15
- import { z } from "zod";
16
- import fs from "fs/promises";
17
- import path from "path";
18
- import { createHash } from "crypto";
19
- var querySchema = z.object({
20
- only: z.literal(["frontmatter", "all"]).default("all"),
21
- collection: z.string().optional()
22
- }).loose();
23
- var cacheEntry = z.object({
24
- code: z.string(),
25
- map: z.any().optional(),
26
- hash: z.string().optional()
27
- });
28
- function createMdxLoader(configLoader) {
29
- return async ({
30
- source: value,
31
- development: isDevelopment,
32
- query,
33
- compiler,
34
- filePath
35
- }) => {
36
- const matter = fumaMatter(value);
37
- const parsed = querySchema.parse(query);
38
- const config = await configLoader.getConfig();
39
- let after;
40
- if (!isDevelopment && config.global.experimentalBuildCache) {
41
- const cacheDir = config.global.experimentalBuildCache;
42
- const cacheKey = `${parsed.hash}_${parsed.collection ?? "global"}_${generateCacheHash(filePath)}`;
43
- const cached = await fs.readFile(path.join(cacheDir, cacheKey)).then((content) => cacheEntry.parse(JSON.parse(content.toString()))).catch(() => null);
44
- if (cached && cached.hash === generateCacheHash(value)) return cached;
45
- after = async () => {
46
- await fs.mkdir(cacheDir, { recursive: true });
47
- await fs.writeFile(
48
- path.join(cacheDir, cacheKey),
49
- JSON.stringify({
50
- ...out,
51
- hash: generateCacheHash(value)
52
- })
53
- );
54
- };
55
- }
56
- const collection = parsed.collection ? config.getCollection(parsed.collection) : void 0;
57
- let docCollection;
58
- switch (collection?.type) {
59
- case "doc":
60
- docCollection = collection;
61
- break;
62
- case "docs":
63
- docCollection = collection.docs;
64
- break;
65
- }
66
- if (docCollection?.schema) {
67
- matter.data = await validate(
68
- docCollection.schema,
69
- matter.data,
70
- {
71
- source: value,
72
- path: filePath
73
- },
74
- `invalid frontmatter in ${filePath}`
75
- );
76
- }
77
- if (parsed.only === "frontmatter") {
78
- return {
79
- code: `export const frontmatter = ${JSON.stringify(matter.data)}`,
80
- map: null
81
- };
82
- }
83
- const data = {};
84
- if (config.global.lastModifiedTime === "git") {
85
- data.lastModified = (await getGitTimestamp(filePath))?.getTime();
86
- }
87
- const lineOffset = isDevelopment ? countLines(matter.matter) : 0;
88
- const compiled = await buildMDX(
89
- `${getConfigHash(config)}:${parsed.collection ?? "global"}`,
90
- "\n".repeat(lineOffset) + matter.content,
91
- {
92
- development: isDevelopment,
93
- ...docCollection?.mdxOptions ?? await config.getDefaultMDXOptions(),
94
- postprocess: docCollection?.postprocess,
95
- data,
96
- filePath,
97
- frontmatter: matter.data,
98
- _compiler: compiler
99
- }
100
- );
101
- const out = {
102
- code: String(compiled.value),
103
- map: compiled.map
104
- };
105
- await after?.();
106
- return out;
107
- };
108
- }
109
- var hashes = /* @__PURE__ */ new WeakMap();
110
- function getConfigHash(config) {
111
- let hash = hashes.get(config);
112
- if (hash) return hash;
113
- hash = Date.now().toString();
114
- hashes.set(config, hash);
115
- return hash;
116
- }
117
- function generateCacheHash(input) {
118
- return createHash("md5").update(input).digest("hex");
119
- }
120
- function countLines(s) {
121
- let num = 0;
122
- for (const c of s) {
123
- if (c === "\n") num++;
124
- }
125
- return num;
126
- }
127
-
128
- export {
129
- createMdxLoader
130
- };
@@ -1,56 +0,0 @@
1
- import {
2
- validate
3
- } from "./chunk-TZ5EQBFW.js";
4
-
5
- // src/loaders/meta.ts
6
- import { dump, load } from "js-yaml";
7
- import { z } from "zod";
8
- var querySchema = z.object({
9
- collection: z.string().optional()
10
- }).loose();
11
- function createMetaLoader(configLoader, resolve = {}) {
12
- const { json: resolveJson = "js", yaml: resolveYaml = "js" } = resolve;
13
- return async ({ filePath, query, source }) => {
14
- const isJson = filePath.endsWith(".json");
15
- const parsed = querySchema.parse(query);
16
- const collection = parsed.collection ? (await configLoader.getConfig()).getCollection(parsed.collection) : void 0;
17
- if (!collection) return null;
18
- let data;
19
- try {
20
- data = isJson ? JSON.parse(source) : load(source);
21
- } catch (e) {
22
- throw new Error(`invalid data in ${filePath}`, { cause: e });
23
- }
24
- let schema;
25
- switch (collection?.type) {
26
- case "meta":
27
- schema = collection.schema;
28
- break;
29
- case "docs":
30
- schema = collection.meta.schema;
31
- break;
32
- }
33
- if (schema) {
34
- data = await validate(
35
- schema,
36
- data,
37
- { path: filePath, source },
38
- `invalid data in ${filePath}`
39
- );
40
- }
41
- let code;
42
- if (isJson) {
43
- code = resolveJson === "json" ? JSON.stringify(data) : `export default ${JSON.stringify(data)}`;
44
- } else {
45
- code = resolveYaml === "yaml" ? dump(data) : `export default ${JSON.stringify(data)}`;
46
- }
47
- return {
48
- code,
49
- map: null
50
- };
51
- };
52
- }
53
-
54
- export {
55
- createMetaLoader
56
- };