fumadocs-mdx 15.2.2 → 15.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,10 +3,10 @@ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
3
3
  var build_exports = /* @__PURE__ */ __exportAll({ buildMDX: () => buildMDX });
4
4
  async function buildMDX(core, collection, options) {
5
5
  if ((collection ? collection.compiler : core.getConfig().global.compiler) === "satteri") {
6
- const { buildSatteriMDX } = await import("./build-satteri-k0DGJ1In.js");
6
+ const { buildSatteriMDX } = await import("./build-satteri-D-ZGkE5A.js");
7
7
  return buildSatteriMDX(core, collection, options);
8
8
  }
9
- const { buildJSMDX } = await import("./build-default-C77dbnhG.js");
9
+ const { buildJSMDX } = await import("./build-default-LB5TcE_V.js");
10
10
  return buildJSMDX(core, collection, options);
11
11
  }
12
12
  //#endregion
@@ -158,7 +158,8 @@ function getMDXOptions(config, collection, environment = "bundler") {
158
158
  result = typeof optionsFn === "function" ? optionsFn(environment) : optionsFn;
159
159
  } else result = (async () => {
160
160
  const optionsFn = config.global.mdxOptions;
161
- return applyMdxPreset(typeof optionsFn === "function" ? await optionsFn() : optionsFn)(environment);
161
+ const options = typeof optionsFn === "function" ? await optionsFn() : optionsFn;
162
+ return applyMdxPreset(options)(environment);
162
163
  })();
163
164
  cacheMap.set(key, result);
164
165
  return result;
@@ -50,19 +50,19 @@ async function buildSatteriMDX(core, collection, { filePath, frontmatter, source
50
50
  function postprocessPlugin({ extractLinkReferences = false }, lastModified) {
51
51
  return {
52
52
  name: "remark-postprocess",
53
+ before(_root, ctx) {
54
+ if (extractLinkReferences) ctx.data.extractedReferences ??= [];
55
+ },
53
56
  heading(node, ctx) {
54
57
  const frontmatter = ctx.data.frontmatter ??= {};
55
58
  if (!frontmatter.title && node.depth === 1) frontmatter.title = ctx.textContent(node);
56
59
  },
57
60
  link(node, ctx) {
58
- if (extractLinkReferences) (ctx.data.extractedReferences ??= []).push({ href: node.url });
61
+ if (extractLinkReferences) ctx.data.extractedReferences.push({ href: node.url });
59
62
  },
60
63
  collectExports({ data, addExport }) {
61
- if (extractLinkReferences) addExport("extractedReferences", JSON.stringify(data.extractedReferences ??= []));
64
+ if (extractLinkReferences) addExport("extractedReferences", JSON.stringify(data.extractedReferences));
62
65
  if (lastModified) addExport("lastModified", `new Date(${lastModified.getTime()})`);
63
- },
64
- afterToJs({ result }) {
65
- if (extractLinkReferences) result.data.extractedReferences ??= [];
66
66
  }
67
67
  };
68
68
  }
package/dist/bun/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { t as createMdxLoader } from "../mdx-3XO-apdE.js";
1
+ import { t as createMdxLoader } from "../mdx-DkuxK47O.js";
2
2
  import { i as buildConfig, t as createCore } from "../core-BPlsDtvN.js";
3
3
  import { r as slash } from "../codegen-ESdi9CDJ.js";
4
4
  import { a as createIntegratedConfigLoader, t as toBun } from "../adapter-Bf3BetFi.js";
5
- import { t as createMetaLoader } from "../meta-DWvKGgBH.js";
5
+ import { t as createMetaLoader } from "../meta-BR_rkCyY.js";
6
6
  import { r as metaLoaderGlob, t as mdxLoaderGlob } from "../loaders-DWC_Uwqq.js";
7
7
  import { r as resolveMacroOptions } from "../options-BNnYUjkM.js";
8
8
  import fs from "node:fs/promises";
@@ -0,0 +1,226 @@
1
+ import fsSync from "node:fs";
2
+ import fs from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { createRequire } from "node:module";
5
+ //#region ../vite/dist/index.js
6
+ let pnp;
7
+ let pnpWorkspaceLocators = [];
8
+ if (process.versions.pnp) try {
9
+ pnp = createRequire(import.meta.url)("pnpapi");
10
+ pnpWorkspaceLocators = pnp.getDependencyTreeRoots();
11
+ } catch {}
12
+ async function crawlFrameworkPkgs(options) {
13
+ const pkgJsonPath = await findClosestPkgJsonPath(options.root);
14
+ if (!pkgJsonPath) return {
15
+ optimizeDeps: {
16
+ include: [],
17
+ exclude: []
18
+ },
19
+ ssr: {
20
+ noExternal: [],
21
+ external: []
22
+ }
23
+ };
24
+ const pkgJson = await readJson(pkgJsonPath).catch((e) => {
25
+ throw new Error(`Unable to read ${pkgJsonPath}`, { cause: e });
26
+ });
27
+ const optimizeDepsIncludeByPkgJsonPath = /* @__PURE__ */ new Map();
28
+ const optimizeDepsSubpathsByPkgJsonPath = /* @__PURE__ */ new Map();
29
+ let optimizeDepsInclude = [];
30
+ let optimizeDepsExclude = [];
31
+ let ssrNoExternal = [];
32
+ let ssrExternal = [];
33
+ await crawl(pkgJsonPath, pkgJson);
34
+ optimizeDepsInclude = [...optimizeDepsIncludeByPkgJsonPath.entries()].flatMap(([depPkgJsonPath, chain]) => (optimizeDepsSubpathsByPkgJsonPath.get(depPkgJsonPath) ?? ["."]).map((subpath) => subpath === "." ? chain : chain + subpath.slice(1)));
35
+ if (options.viteUserConfig) {
36
+ const userOptimizeDepsExclude = options.viteUserConfig.optimizeDeps?.exclude;
37
+ if (userOptimizeDepsExclude) optimizeDepsInclude = optimizeDepsInclude.filter((dep) => !isDepExcluded(dep, userOptimizeDepsExclude));
38
+ const userOptimizeDepsInclude = options.viteUserConfig.optimizeDeps?.include;
39
+ if (userOptimizeDepsInclude) optimizeDepsExclude = optimizeDepsExclude.filter((dep) => !isDepIncluded(dep, userOptimizeDepsInclude));
40
+ const userSsrExternal = options.viteUserConfig.ssr?.external;
41
+ if (userSsrExternal) ssrNoExternal = ssrNoExternal.filter((dep) => !isDepExternaled(dep, userSsrExternal));
42
+ const userSsrNoExternal = options.viteUserConfig.ssr?.noExternal;
43
+ if (userSsrNoExternal) ssrExternal = ssrExternal.filter((dep) => !isDepNoExternaled(dep, userSsrNoExternal));
44
+ }
45
+ optimizeDepsInclude.sort();
46
+ optimizeDepsExclude.sort();
47
+ ssrExternal.sort();
48
+ ssrNoExternal.sort();
49
+ return {
50
+ optimizeDeps: {
51
+ include: optimizeDepsInclude,
52
+ exclude: optimizeDepsExclude
53
+ },
54
+ ssr: {
55
+ noExternal: ssrNoExternal,
56
+ external: ssrExternal
57
+ }
58
+ };
59
+ async function crawl(currentPkgJsonPath, currentPkgJson, parentDepNames = [], parentIsFrameworkPkg = false, hasFrameworkAncestor = false) {
60
+ const crawlDevDependencies = parentDepNames.length === 0 || isPrivateWorkspacePackage(currentPkgJsonPath, currentPkgJson, options.workspaceRoot);
61
+ const deps = [...Object.keys(currentPkgJson.dependencies ?? {}), ...crawlDevDependencies ? Object.keys(currentPkgJson.devDependencies ?? {}) : []].filter((dep) => !parentDepNames.includes(dep));
62
+ await Promise.all(deps.map(async (dep) => {
63
+ const frameworkByName = options.isFrameworkPkgByName?.(dep);
64
+ const semiFrameworkByName = options.isSemiFrameworkPkgByName?.(dep);
65
+ if (frameworkByName === false || semiFrameworkByName === false) return;
66
+ const depPkgJsonPath = await findDepPkgJsonPath(dep, currentPkgJsonPath, !!options.workspaceRoot);
67
+ if (!depPkgJsonPath) return;
68
+ const depPkgJson = await readJson(depPkgJsonPath).catch(() => {});
69
+ if (!depPkgJson) return;
70
+ const isFrameworkPkg = frameworkByName === true || options.isFrameworkPkgByJson?.(depPkgJson) === true;
71
+ const isSemiFrameworkPkg = semiFrameworkByName === true || options.isSemiFrameworkPkgByJson?.(depPkgJson) === true;
72
+ const depChain = parentDepNames.concat(dep);
73
+ if (isFrameworkPkg || isSemiFrameworkPkg) {
74
+ if (isFrameworkPkg) {
75
+ pushUnique(optimizeDepsExclude, dep);
76
+ pushUnique(ssrNoExternal, dep);
77
+ } else pushUnique(ssrNoExternal, dep);
78
+ await crawl(depPkgJsonPath, depPkgJson, depChain, true, true);
79
+ return;
80
+ }
81
+ if (!hasFrameworkAncestor) return;
82
+ if (await pkgNeedsOptimization(depPkgJson, depPkgJsonPath)) addOptimizedDep(depPkgJsonPath, depChain, depPkgJson);
83
+ else await crawl(depPkgJsonPath, depPkgJson, depChain, false, true);
84
+ if (!options.isBuild && parentIsFrameworkPkg) pushUnique(ssrExternal, dep);
85
+ }));
86
+ }
87
+ function addOptimizedDep(depPkgJsonPath, depChain, depPkgJson) {
88
+ const includePath = depChain.join(" > ");
89
+ const current = optimizeDepsIncludeByPkgJsonPath.get(depPkgJsonPath);
90
+ if (!current || compareDepChains(includePath, current) < 0) optimizeDepsIncludeByPkgJsonPath.set(depPkgJsonPath, includePath);
91
+ if (!optimizeDepsSubpathsByPkgJsonPath.has(depPkgJsonPath)) optimizeDepsSubpathsByPkgJsonPath.set(depPkgJsonPath, getExportsSubpaths(depPkgJson.exports));
92
+ }
93
+ }
94
+ async function findClosestPkgJsonPath(dir, predicate) {
95
+ let currentDir = dir.endsWith("package.json") ? path.dirname(dir) : dir;
96
+ while (currentDir) {
97
+ const pkg = path.join(currentDir, "package.json");
98
+ try {
99
+ if ((await fs.stat(pkg)).isFile() && (!predicate || await predicate(pkg))) return pkg;
100
+ } catch {}
101
+ const nextDir = path.dirname(currentDir);
102
+ if (nextDir === currentDir) break;
103
+ currentDir = nextDir;
104
+ }
105
+ }
106
+ async function pkgNeedsOptimization(pkgJson, pkgJsonPath) {
107
+ if (pkgJson.module || pkgJson.type === "module") return false;
108
+ if (pkgJson.exports) return !exportsHasEsmEntry(pkgJson.exports);
109
+ if (pkgJson.main) {
110
+ const entryExt = path.extname(pkgJson.main);
111
+ return !entryExt || entryExt === ".js" || entryExt === ".cjs";
112
+ }
113
+ try {
114
+ await fs.access(path.join(path.dirname(pkgJsonPath), "index.js"));
115
+ return true;
116
+ } catch {
117
+ return false;
118
+ }
119
+ }
120
+ function exportsHasEsmEntry(exportsField) {
121
+ if (typeof exportsField === "string") return exportsField.endsWith(".mjs");
122
+ if (Array.isArray(exportsField)) return exportsField.some(exportsHasEsmEntry);
123
+ if (exportsField && typeof exportsField === "object") return Object.entries(exportsField).some(([key, value]) => key === "import" || key === "module" || exportsHasEsmEntry(value));
124
+ return false;
125
+ }
126
+ function getExportsSubpaths(exportsField) {
127
+ if (!exportsField || typeof exportsField !== "object" || Array.isArray(exportsField)) return ["."];
128
+ const subpathKeys = Object.keys(exportsField).filter((key) => key.startsWith("."));
129
+ if (subpathKeys.length === 0) return ["."];
130
+ const subpaths = subpathKeys.filter((key) => key === "." || /^\.\/[^*.]+$/.test(key));
131
+ return subpaths.length > 0 ? subpaths : ["."];
132
+ }
133
+ async function findDepPkgJsonPath(dep, parent, usePnpWorkspaceLocators) {
134
+ if (pnp) {
135
+ if (usePnpWorkspaceLocators) try {
136
+ const locator = pnpWorkspaceLocators.find((root) => root.name === dep);
137
+ if (locator) {
138
+ const pkgPath = pnp.getPackageInformation(locator).packageLocation;
139
+ return path.resolve(pkgPath, "package.json");
140
+ }
141
+ } catch {}
142
+ try {
143
+ const depRoot = pnp.resolveToUnqualified(dep, parent);
144
+ if (!depRoot) return;
145
+ return path.join(depRoot, "package.json");
146
+ } catch {
147
+ return;
148
+ }
149
+ }
150
+ let root = parent;
151
+ while (root) {
152
+ const pkg = path.join(root, "node_modules", dep, "package.json");
153
+ try {
154
+ await fs.access(pkg);
155
+ return fsSync.realpathSync(pkg);
156
+ } catch {}
157
+ const nextRoot = path.dirname(root);
158
+ if (nextRoot === root) break;
159
+ root = nextRoot;
160
+ }
161
+ }
162
+ async function readJson(pkgJsonPath) {
163
+ return JSON.parse(await fs.readFile(pkgJsonPath, "utf8"));
164
+ }
165
+ function isPrivateWorkspacePackage(pkgJsonPath, pkgJson, workspaceRoot) {
166
+ return !!(workspaceRoot && pkgJson.private && !pkgJsonPath.match(/[/\\]node_modules[/\\]/) && !path.relative(workspaceRoot, pkgJsonPath).startsWith(".."));
167
+ }
168
+ function pushUnique(array, value) {
169
+ if (!array.includes(value)) array.push(value);
170
+ }
171
+ function compareDepChains(left, right) {
172
+ const leftDepth = left.split(" > ").length;
173
+ const rightDepth = right.split(" > ").length;
174
+ if (leftDepth !== rightDepth) return leftDepth - rightDepth;
175
+ return left.localeCompare(right);
176
+ }
177
+ function isDepIncluded(dep, optimizeDepsInclude) {
178
+ return optimizeDepsInclude.some((include) => dep === include);
179
+ }
180
+ function isDepExcluded(dep, optimizeDepsExclude) {
181
+ return optimizeDepsExclude.some((exclude) => dep === exclude || dep.startsWith(`${exclude} > `));
182
+ }
183
+ function isDepNoExternaled(dep, ssrNoExternal) {
184
+ if (typeof ssrNoExternal === "boolean") return ssrNoExternal;
185
+ return (Array.isArray(ssrNoExternal) ? ssrNoExternal : [ssrNoExternal]).some((noExternal) => {
186
+ if (typeof noExternal === "string") return dep === noExternal;
187
+ return noExternal.test(dep);
188
+ });
189
+ }
190
+ function isDepExternaled(dep, ssrExternal) {
191
+ if (typeof ssrExternal === "boolean") return ssrExternal;
192
+ return ssrExternal.some((external) => dep === external);
193
+ }
194
+ /**
195
+ * Vite config for a project using Fumadocs, derived from its installed dependencies.
196
+ *
197
+ * Our packages are served as source rather than pre-bundled, which means Vite also serves their
198
+ * dependencies raw and no longer discovers the CommonJS ones on its own. The crawl walks the
199
+ * project's tree to name them explicitly:
200
+ * https://vite.dev/config/dep-optimization-options#optimizedeps-exclude
201
+ */
202
+ async function getConfig(options) {
203
+ const out = await crawlFrameworkPkgs({
204
+ root: options.root,
205
+ isBuild: options.isBuild,
206
+ isFrameworkPkgByName(pkgName) {
207
+ if (pkgName.startsWith("@fumadocs/") || pkgName.startsWith("fumadocs-")) return true;
208
+ switch (pkgName) {
209
+ case "vite":
210
+ case "waku":
211
+ case "shiki": return false;
212
+ }
213
+ }
214
+ });
215
+ return {
216
+ optimizeDeps: out.optimizeDeps,
217
+ ssr: { noExternal: out.ssr.noExternal },
218
+ resolve: options.isBuild ? { alias: buildAlias } : {}
219
+ };
220
+ }
221
+ const buildAlias = [{
222
+ find: /^use-sync-external-store\/shim$/,
223
+ replacement: "react"
224
+ }];
225
+ //#endregion
226
+ export { getConfig };
@@ -51,9 +51,7 @@ function createMdxLoader({ getCore }) {
51
51
  case "doc":
52
52
  docCollection = collection;
53
53
  break;
54
- case "docs":
55
- docCollection = collection.docs;
56
- break;
54
+ case "docs": docCollection = collection.docs;
57
55
  }
58
56
  }
59
57
  if (docCollection) matter.data = await core.transformFrontmatter({
@@ -65,7 +63,7 @@ function createMdxLoader({ getCore }) {
65
63
  code: `export const frontmatter = ${JSON.stringify(matter.data)}`,
66
64
  map: null
67
65
  };
68
- const { buildMDX } = await import("./build-DINFMoNj.js").then((n) => n.n);
66
+ const { buildMDX } = await import("./build-DvX_5u5A.js").then((n) => n.n);
69
67
  const compiled = await buildMDX(core, docCollection, {
70
68
  isDevelopment,
71
69
  source: "\n".repeat(countLines(matter.matter)) + matter.content,
@@ -42,9 +42,7 @@ function createMetaLoader({ getCore }, resolve = {}) {
42
42
  case "meta":
43
43
  metaCollection = collection;
44
44
  break;
45
- case "docs":
46
- metaCollection = collection.meta;
47
- break;
45
+ case "docs": metaCollection = collection.meta;
48
46
  }
49
47
  }
50
48
  const data = parse$1(filePath, source);
@@ -1,8 +1,8 @@
1
- import { t as createMdxLoader } from "../mdx-3XO-apdE.js";
1
+ import { t as createMdxLoader } from "../mdx-DkuxK47O.js";
2
2
  import { t as createCore } from "../core-BPlsDtvN.js";
3
3
  import { r as slash } from "../codegen-ESdi9CDJ.js";
4
4
  import { n as toNode, o as createStandaloneConfigLoader } from "../adapter-Bf3BetFi.js";
5
- import { t as createMetaLoader } from "../meta-DWvKGgBH.js";
5
+ import { t as createMetaLoader } from "../meta-BR_rkCyY.js";
6
6
  import { r as metaLoaderGlob, t as mdxLoaderGlob } from "../loaders-DWC_Uwqq.js";
7
7
  import { n as createMacroMatcher, r as resolveMacroOptions } from "../options-BNnYUjkM.js";
8
8
  import { n as createNodeEvaluator, t as MacroCollector } from "../eval-z3HV4VJp.js";
@@ -1,11 +1,12 @@
1
- import { t as createMdxLoader } from "../mdx-3XO-apdE.js";
1
+ import { t as createMdxLoader } from "../mdx-DkuxK47O.js";
2
2
  import { t as createCore } from "../core-BPlsDtvN.js";
3
3
  import { n as toNode, o as createStandaloneConfigLoader } from "../adapter-Bf3BetFi.js";
4
- import { t as createMetaLoader } from "../meta-DWvKGgBH.js";
4
+ import { t as createMetaLoader } from "../meta-BR_rkCyY.js";
5
5
  import { r as metaLoaderGlob, t as mdxLoaderGlob } from "../loaders-DWC_Uwqq.js";
6
6
  //#region src/node/loader.ts
7
+ const core = createCore({ environment: "node" });
7
8
  const configLoader = createStandaloneConfigLoader({
8
- core: createCore({ environment: "node" }),
9
+ core,
9
10
  buildConfig: true,
10
11
  mode: "production"
11
12
  });
@@ -1,8 +1,8 @@
1
- import { t as createMdxLoader } from "../mdx-3XO-apdE.js";
1
+ import { t as createMdxLoader } from "../mdx-DkuxK47O.js";
2
2
  import { i as buildConfig, t as createCore } from "../core-BPlsDtvN.js";
3
3
  import { r as slash } from "../codegen-ESdi9CDJ.js";
4
4
  import { a as createIntegratedConfigLoader, r as toVite } from "../adapter-Bf3BetFi.js";
5
- import { t as createMetaLoader } from "../meta-DWvKGgBH.js";
5
+ import { t as createMetaLoader } from "../meta-BR_rkCyY.js";
6
6
  import { r as metaLoaderGlob, t as mdxLoaderGlob } from "../loaders-DWC_Uwqq.js";
7
7
  import { r as resolveMacroOptions, t as MacroModuleId } from "../options-BNnYUjkM.js";
8
8
  import { n as createNodeEvaluator, t as MacroCollector } from "../eval-z3HV4VJp.js";
@@ -47,7 +47,8 @@ function createClientLoader(globEntries, options) {
47
47
  return getRenderer(path);
48
48
  },
49
49
  useContent(path, props) {
50
- return /* @__PURE__ */ jsx(getRenderer(path), { ...props });
50
+ const Comp = getRenderer(path);
51
+ return /* @__PURE__ */ jsx(Comp, { ...props });
51
52
  }
52
53
  };
53
54
  }
@@ -1,5 +1,5 @@
1
1
  import { i as buildConfig, t as createCore } from "../core-BPlsDtvN.js";
2
- import { t as buildMDX } from "../build-DINFMoNj.js";
2
+ import { t as buildMDX } from "../build-DvX_5u5A.js";
3
3
  import { server } from "./server.js";
4
4
  import { frontmatter } from "fumadocs-core/content/md/frontmatter";
5
5
  import fs from "node:fs/promises";
@@ -45,7 +45,8 @@ function asyncEntries(raw) {
45
45
  const load = () => promise ??= track(entry.load());
46
46
  function Body(props) {
47
47
  const loaded = load();
48
- return createElement((loaded.status === "fulfilled" ? loaded.value : use(loaded)).body, props);
48
+ const data = loaded.status === "fulfilled" ? loaded.value : use(loaded);
49
+ return createElement(data.body, props);
49
50
  }
50
51
  return {
51
52
  ...entry,
@@ -1,7 +1,7 @@
1
- import { t as createMdxLoader } from "../mdx-3XO-apdE.js";
1
+ import { t as createMdxLoader } from "../mdx-DkuxK47O.js";
2
2
  import { i as buildConfig, t as createCore } from "../core-BPlsDtvN.js";
3
3
  import { a as createIntegratedConfigLoader, r as toVite } from "../adapter-Bf3BetFi.js";
4
- import { t as createMetaLoader } from "../meta-DWvKGgBH.js";
4
+ import { t as createMetaLoader } from "../meta-BR_rkCyY.js";
5
5
  import { r as metaLoaderGlob, t as mdxLoaderGlob } from "../loaders-DWC_Uwqq.js";
6
6
  import { r as resolveMacroOptions, t as MacroModuleId } from "../options-BNnYUjkM.js";
7
7
  import { t as indexFile } from "../index-file-pX-fCn8l.js";
@@ -109,8 +109,11 @@ function mdx(forcedConfig, pluginOptions = {}) {
109
109
  }
110
110
  if ("_fumadocs_skipViteConfig" in config && config._fumadocs_skipViteConfig) return;
111
111
  if (!updateViteConfig) return;
112
- const { getConfig } = await import("../dist-DaA0UDzw.js");
113
- return getConfig({ root: core.root });
112
+ const { getConfig } = await import("../dist-Bniav-AK.js");
113
+ return getConfig({
114
+ root: core.root,
115
+ isBuild: env.command === "build"
116
+ });
114
117
  },
115
118
  async buildStart() {
116
119
  if (forcedConfig || managed.watchConfig) await managed.core.emit({ write: true });
@@ -1,4 +1,4 @@
1
- import { t as createMdxLoader } from "../mdx-3XO-apdE.js";
1
+ import { t as createMdxLoader } from "../mdx-DkuxK47O.js";
2
2
  import { i as toWebpack, o as createStandaloneConfigLoader } from "../adapter-Bf3BetFi.js";
3
3
  import { t as getCore } from "../webpack-BSog6pml.js";
4
4
  //#region src/webpack/mdx.ts
@@ -1,5 +1,5 @@
1
1
  import { i as toWebpack, o as createStandaloneConfigLoader } from "../adapter-Bf3BetFi.js";
2
- import { t as createMetaLoader } from "../meta-DWvKGgBH.js";
2
+ import { t as createMetaLoader } from "../meta-BR_rkCyY.js";
3
3
  import { t as getCore } from "../webpack-BSog6pml.js";
4
4
  //#region src/webpack/meta.ts
5
5
  const instances = /* @__PURE__ */ new Map();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-mdx",
3
- "version": "15.2.2",
3
+ "version": "15.3.0",
4
4
  "description": "The built-in source for Fumadocs",
5
5
  "keywords": [
6
6
  "Docs",
@@ -56,44 +56,44 @@
56
56
  "@mdx-js/mdx": "^3.1.1",
57
57
  "@standard-schema/spec": "^1.1.0",
58
58
  "chokidar": "^5.0.0",
59
- "esbuild": "^0.28.1",
59
+ "esbuild": "^0.28.2",
60
60
  "estree-util-value-to-estree": "^3.5.0",
61
61
  "github-slugger": "^2.0.0",
62
- "magic-string": "^1.1.0",
62
+ "magic-string": "^1.1.1",
63
63
  "mdast-util-mdx": "^3.0.0",
64
64
  "picocolors": "^1.1.1",
65
65
  "picomatch": "^4.0.5",
66
- "tinyexec": "^1.2.4",
66
+ "tinyexec": "^1.3.0",
67
67
  "tinyglobby": "^0.2.17",
68
68
  "unified": "^11.0.5",
69
69
  "unist-util-remove-position": "^5.0.0",
70
70
  "unist-util-visit": "^5.1.0",
71
71
  "vfile": "^6.0.3",
72
72
  "yaml": "^2.9.0",
73
- "yuku-analyzer": "^0.8.1",
73
+ "yuku-analyzer": "^0.8.5",
74
74
  "zod": "^4.4.3"
75
75
  },
76
76
  "devDependencies": {
77
77
  "@types/bun": "^1.3.14",
78
78
  "@types/mdast": "^4.0.4",
79
79
  "@types/mdx": "^2.0.14",
80
- "@types/node": "^26.1.2",
80
+ "@types/node": "^26.2.0",
81
81
  "@types/picomatch": "^4.0.3",
82
- "@types/react": "^19.2.17",
82
+ "@types/react": "^19.2.18",
83
83
  "mdast-util-directive": "^3.1.0",
84
- "next": "^16.2.12",
84
+ "next": "^16.3.0",
85
85
  "react": "^19.2.8",
86
86
  "remark": "^15.0.1",
87
87
  "remark-directive": "^4.0.0",
88
88
  "remark-mdx": "^3.1.1",
89
- "rolldown": "^1.2.0",
90
- "satteri": "^0.9.5",
89
+ "rolldown": "^1.2.4",
90
+ "satteri": "^0.10.3",
91
91
  "tsdown": "0.22.14",
92
- "vite": "^8.1.5",
92
+ "vite": "^8.2.1",
93
93
  "webpack": "^5.109.2",
94
- "@fumadocs/satteri": "0.3.1",
94
+ "@fumadocs/satteri": "0.4.0",
95
95
  "@fumadocs/vite": "0.1.0",
96
- "fumadocs-core": "16.14.0",
96
+ "fumadocs-core": "16.14.5",
97
97
  "tsconfig": "0.0.0"
98
98
  },
99
99
  "peerDependencies": {
@@ -106,7 +106,7 @@
106
106
  "next": "^15.3.0 || ^16.0.0",
107
107
  "react": "^19.2.0",
108
108
  "rolldown": "*",
109
- "satteri": "^0.9.4",
109
+ "satteri": "^0.10.0",
110
110
  "vite": "7.x.x || 8.x.x"
111
111
  },
112
112
  "peerDependenciesMeta": {
@@ -1,123 +0,0 @@
1
- import fs from "node:fs/promises";
2
- import path from "node:path";
3
- //#region ../vite/dist/index.js
4
- async function findClosestPkgJsonPath(dir, predicate) {
5
- let currentDir = dir.endsWith("package.json") ? path.dirname(dir) : dir;
6
- while (currentDir) {
7
- const pkg = path.join(currentDir, "package.json");
8
- try {
9
- if ((await fs.stat(pkg)).isFile() && (!predicate || await predicate(pkg))) return pkg;
10
- } catch {}
11
- const nextDir = path.dirname(currentDir);
12
- if (nextDir === currentDir) break;
13
- currentDir = nextDir;
14
- }
15
- }
16
- async function readJson(pkgJsonPath) {
17
- return JSON.parse(await fs.readFile(pkgJsonPath, "utf8"));
18
- }
19
- var generated_default = {
20
- optimizeDeps: {
21
- "include": [
22
- "@fumadocs/local-md > @fumadocs/local-content > picomatch",
23
- "@fumadocs/local-md > estree-util-to-js > source-map",
24
- "@fumadocs/local-md > hast-util-to-jsx-runtime > mdast-util-mdx-expression > mdast-util-from-markdown > micromark > debug",
25
- "@fumadocs/local-md > hast-util-to-jsx-runtime > style-to-js",
26
- "@fumadocs/local-md > remark-rehype > unified > extend",
27
- "@fumadocs/mdx-remote > @mdx-js/mdx > hast-util-to-jsx-runtime > style-to-js",
28
- "@fumadocs/mdx-remote > @mdx-js/mdx > remark-parse > mdast-util-from-markdown > micromark > debug",
29
- "@fumadocs/mdx-remote > @mdx-js/mdx > source-map",
30
- "@fumadocs/mdx-remote > unified > extend",
31
- "@fumadocs/story > ts-morph",
32
- "fumadocs-core > hast-util-to-estree > style-to-js",
33
- "fumadocs-core > mdast-util-mdx > mdast-util-from-markdown > micromark > debug",
34
- "fumadocs-core > tinyglobby > picomatch",
35
- "fumadocs-core > unified > extend",
36
- "fumadocs-mdx > @mdx-js/mdx > hast-util-to-jsx-runtime > style-to-js",
37
- "fumadocs-mdx > @mdx-js/mdx > source-map",
38
- "fumadocs-mdx > esbuild",
39
- "fumadocs-mdx > mdast-util-mdx > mdast-util-from-markdown > micromark > debug",
40
- "fumadocs-mdx > picocolors",
41
- "fumadocs-mdx > picomatch",
42
- "fumadocs-mdx > unified > extend",
43
- "fumadocs-twoslash > mdast-util-from-markdown > micromark > debug",
44
- "fumadocs-typescript > hast-util-to-jsx-runtime > mdast-util-mdx-expression > mdast-util-from-markdown > micromark > debug",
45
- "fumadocs-typescript > hast-util-to-jsx-runtime > style-to-js",
46
- "fumadocs-typescript > ts-morph",
47
- "fumadocs-typescript > unified > extend"
48
- ],
49
- "exclude": [
50
- "@fumadocs/basehub",
51
- "@fumadocs/local-content",
52
- "@fumadocs/local-md",
53
- "@fumadocs/mdx-remote",
54
- "@fumadocs/sanity",
55
- "@fumadocs/story",
56
- "@fumadocs/tailwind",
57
- "fumadocs-core",
58
- "fumadocs-mdx",
59
- "fumadocs-twoslash",
60
- "fumadocs-typescript",
61
- "fumadocs-ui"
62
- ]
63
- },
64
- ssr: { "noExternal": [
65
- "@fumadocs/basehub",
66
- "@fumadocs/local-content",
67
- "@fumadocs/local-md",
68
- "@fumadocs/mdx-remote",
69
- "@fumadocs/sanity",
70
- "@fumadocs/story",
71
- "@fumadocs/tailwind",
72
- "fumadocs-core",
73
- "fumadocs-mdx",
74
- "fumadocs-twoslash",
75
- "fumadocs-typescript",
76
- "fumadocs-ui"
77
- ] }
78
- };
79
- /**
80
- * `use-sync-external-store` is a CommonJS package Base UI depends on for React 17, where
81
- * `useSyncExternalStore` wasn't built into React yet.
82
- *
83
- * When it is bundled for SSR, its `require('react')` stays a runtime require, so it ends up with a
84
- * different React instance than the bundled one the renderer installs its hook dispatcher on.
85
- * Calling a hook then reads a null dispatcher and every component using a Base UI store (dialogs,
86
- * navigation menu, scroll area) throws during SSR.
87
- *
88
- * We require React 19, where the shim only forwards to React's own `useSyncExternalStore`.
89
- */
90
- const alias = [{
91
- find: /^use-sync-external-store\/shim$/,
92
- replacement: "react"
93
- }];
94
- async function getConfig(options) {
95
- const pkgJsonPath = await findClosestPkgJsonPath(options.root);
96
- if (!pkgJsonPath) return {
97
- optimizeDeps: {
98
- include: [],
99
- exclude: []
100
- },
101
- ssr: { noExternal: [] },
102
- resolve: { alias }
103
- };
104
- const pkgJson = await readJson(pkgJsonPath).catch((e) => {
105
- throw new Error(`Unable to read ${pkgJsonPath}`, { cause: e });
106
- });
107
- const out = structuredClone(generated_default);
108
- const deps = /* @__PURE__ */ new Set();
109
- if (pkgJson.dependencies) for (const name in pkgJson.dependencies) deps.add(name);
110
- if (pkgJson.devDependencies) for (const name in pkgJson.devDependencies) deps.add(name);
111
- out.optimizeDeps.include = out.optimizeDeps.include.filter((item) => {
112
- const first = item.slice(0, item.indexOf(" > "));
113
- return deps.has(first);
114
- });
115
- out.optimizeDeps.exclude = out.optimizeDeps.exclude.filter((item) => deps.has(item));
116
- out.ssr.noExternal = out.ssr.noExternal.filter((item) => deps.has(item));
117
- return {
118
- ...out,
119
- resolve: { alias }
120
- };
121
- }
122
- //#endregion
123
- export { getConfig };