fumadocs-mdx 15.2.1 → 15.2.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.
@@ -1,5 +1,5 @@
1
1
  import { i as buildConfig, n as ValidationError } from "./core-BPlsDtvN.js";
2
- import { t as loadConfig } from "./load-from-file-DNDIyOo3.js";
2
+ import { t as loadConfig } from "./load-from-file-CIW3c2FZ.js";
3
3
  import { readFileSync } from "node:fs";
4
4
  import fs from "node:fs/promises";
5
5
  import { fileURLToPath } from "node:url";
@@ -14,7 +14,7 @@ function createStandaloneConfigLoader({ core, buildConfig: buildConfig$1, mode }
14
14
  }
15
15
  async function load(hash) {
16
16
  if (hash === "missing") return buildConfig({}, process.cwd());
17
- return await loadConfig(core, buildConfig$1);
17
+ return (await loadConfig(core, buildConfig$1)).config;
18
18
  }
19
19
  return { async getCore() {
20
20
  const hash = await getConfigHash();
package/dist/bun/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { t as createMdxLoader } from "../mdx-3XO-apdE.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
- import { a as createIntegratedConfigLoader, t as toBun } from "../adapter-DvWJNDHu.js";
4
+ import { a as createIntegratedConfigLoader, t as toBun } from "../adapter-Bf3BetFi.js";
5
5
  import { t as createMetaLoader } from "../meta-DWvKGgBH.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";
@@ -23,7 +23,7 @@ var generated_default = {
23
23
  "@fumadocs/local-md > estree-util-to-js > source-map",
24
24
  "@fumadocs/local-md > hast-util-to-jsx-runtime > mdast-util-mdx-expression > mdast-util-from-markdown > micromark > debug",
25
25
  "@fumadocs/local-md > hast-util-to-jsx-runtime > style-to-js",
26
- "@fumadocs/local-md > remark > unified > extend",
26
+ "@fumadocs/local-md > remark-rehype > unified > extend",
27
27
  "@fumadocs/mdx-remote > @mdx-js/mdx > hast-util-to-jsx-runtime > style-to-js",
28
28
  "@fumadocs/mdx-remote > @mdx-js/mdx > remark-parse > mdast-util-from-markdown > micromark > debug",
29
29
  "@fumadocs/mdx-remote > @mdx-js/mdx > source-map",
@@ -41,8 +41,8 @@ var generated_default = {
41
41
  "fumadocs-mdx > picomatch",
42
42
  "fumadocs-mdx > unified > extend",
43
43
  "fumadocs-twoslash > mdast-util-from-markdown > micromark > debug",
44
- "fumadocs-typescript > hast-util-to-estree > mdast-util-mdx-expression > mdast-util-from-markdown > micromark > debug",
45
- "fumadocs-typescript > hast-util-to-estree > style-to-js",
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
46
  "fumadocs-typescript > ts-morph",
47
47
  "fumadocs-typescript > unified > extend"
48
48
  ],
@@ -39,10 +39,16 @@ async function loadConfig(core, build = false) {
39
39
  let exists;
40
40
  if (build) exists = await compileConfig(core);
41
41
  exists ??= await fs.access(core.configPath).then(() => true, () => false);
42
- if (!exists) return buildConfig({}, process.cwd());
42
+ if (!exists) return {
43
+ config: buildConfig({}, process.cwd()),
44
+ fromFile: false
45
+ };
43
46
  const url = pathToFileURL(core.getCompiledConfigPath());
44
47
  url.searchParams.set("hash", Date.now().toString());
45
- return buildConfig(await import(url.href), process.cwd());
48
+ return {
49
+ config: buildConfig(await import(url.href), process.cwd()),
50
+ fromFile: true
51
+ };
46
52
  }
47
53
  //#endregion
48
54
  export { loadConfig as t };
@@ -11,7 +11,7 @@ interface CreateMDXOptions extends Pick<CoreOptions, 'configPath' | 'outDir'> {
11
11
  macro?: MacroPluginOption;
12
12
  index?: IndexFilePluginOptions | false;
13
13
  }
14
- declare function createMDX(options?: CreateMDXOptions): (nextConfig?: NextConfig) => NextConfig;
14
+ declare function createMDX(options?: CreateMDXOptions): (nextConfig?: NextConfig) => NextConfig & PromiseLike<NextConfig>;
15
15
  declare function postInstall(options?: CreateMDXOptions): Promise<void>;
16
16
  //#endregion
17
17
  export { CreateMDXOptions, createMDX, postInstall };
@@ -1,5 +1,5 @@
1
1
  import { t as createCore } from "../core-BPlsDtvN.js";
2
- import { t as loadConfig } from "../load-from-file-DNDIyOo3.js";
2
+ import { t as loadConfig } from "../load-from-file-CIW3c2FZ.js";
3
3
  import { i as metaLoaderQueryGlob, n as metaLoaderFileGlob, t as mdxLoaderGlob } from "../loaders-DWC_Uwqq.js";
4
4
  import { n as createMacroMatcher, r as resolveMacroOptions } from "../options-BNnYUjkM.js";
5
5
  import { t as indexFile } from "../index-file-pX-fCn8l.js";
@@ -17,9 +17,13 @@ function createMDX(options = {}) {
17
17
  const core = createNextCore(options);
18
18
  const isDev = process.env.NODE_ENV === "development";
19
19
  const macro = resolveMacroOptions(options.macro);
20
+ let pending;
20
21
  if (process.env._FUMADOCS_MDX !== "1") {
21
22
  process.env._FUMADOCS_MDX = "1";
22
- init(isDev, core);
23
+ pending = init(isDev, core);
24
+ pending.catch((err) => {
25
+ console.error("[MDX] failed to generate files:", err);
26
+ });
23
27
  }
24
28
  function onLoaderOptions(type) {
25
29
  return {
@@ -69,7 +73,7 @@ function createMDX(options = {}) {
69
73
  }
70
74
  }
71
75
  };
72
- return {
76
+ const out = {
73
77
  ...nextConfig,
74
78
  turbopack,
75
79
  pageExtensions: nextConfig.pageExtensions ?? defaultPageExtensions,
@@ -108,12 +112,25 @@ function createMDX(options = {}) {
108
112
  return nextConfig.webpack?.(config, options) ?? config;
109
113
  }
110
114
  };
115
+ const ready = pending ?? Promise.resolve();
116
+ return Object.defineProperty(out, "then", {
117
+ enumerable: false,
118
+ configurable: true,
119
+ writable: true,
120
+ value(onFulfilled, onRejected) {
121
+ return ready.then(() => {
122
+ const { ...clean } = out;
123
+ return clean;
124
+ }).then(onFulfilled, onRejected);
125
+ }
126
+ });
111
127
  };
112
128
  }
113
- async function init(dev, core) {
129
+ function init(dev, core) {
114
130
  async function initOrReload() {
115
- await core.init({ config: loadConfig(core, true) });
116
- await core.emit({ write: true });
131
+ const { config, fromFile } = await loadConfig(core, true);
132
+ await core.init({ config });
133
+ if (fromFile) await core.emit({ write: true });
117
134
  }
118
135
  async function devServer() {
119
136
  const { FSWatcher } = await import("chokidar");
@@ -144,13 +161,17 @@ async function init(dev, core) {
144
161
  });
145
162
  await core.initServer({ watcher });
146
163
  }
147
- await initOrReload();
148
- if (dev) await devServer();
164
+ const ready = initOrReload();
165
+ if (dev) ready.then(devServer, () => {}).catch((err) => {
166
+ console.error("[MDX] failed to start dev server:", err);
167
+ });
168
+ return ready;
149
169
  }
150
170
  async function postInstall(options = {}) {
151
171
  const core = createNextCore(options);
152
- await core.init({ config: loadConfig(core, true) });
153
- await core.emit({ write: true });
172
+ const { config, fromFile } = await loadConfig(core, true);
173
+ await core.init({ config });
174
+ if (fromFile) await core.emit({ write: true });
154
175
  }
155
176
  function createNextCore({ outDir, configPath, index = {} }) {
156
177
  return createCore({
@@ -1,7 +1,7 @@
1
1
  import { t as createMdxLoader } from "../mdx-3XO-apdE.js";
2
2
  import { t as createCore } from "../core-BPlsDtvN.js";
3
3
  import { r as slash } from "../codegen-ESdi9CDJ.js";
4
- import { n as toNode, o as createStandaloneConfigLoader } from "../adapter-DvWJNDHu.js";
4
+ import { n as toNode, o as createStandaloneConfigLoader } from "../adapter-Bf3BetFi.js";
5
5
  import { t as createMetaLoader } from "../meta-DWvKGgBH.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";
@@ -1,6 +1,6 @@
1
1
  import { t as createMdxLoader } from "../mdx-3XO-apdE.js";
2
2
  import { t as createCore } from "../core-BPlsDtvN.js";
3
- import { n as toNode, o as createStandaloneConfigLoader } from "../adapter-DvWJNDHu.js";
3
+ import { n as toNode, o as createStandaloneConfigLoader } from "../adapter-Bf3BetFi.js";
4
4
  import { t as createMetaLoader } from "../meta-DWvKGgBH.js";
5
5
  import { r as metaLoaderGlob, t as mdxLoaderGlob } from "../loaders-DWC_Uwqq.js";
6
6
  //#region src/node/loader.ts
@@ -1,7 +1,7 @@
1
1
  import { t as createMdxLoader } from "../mdx-3XO-apdE.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
- import { a as createIntegratedConfigLoader, r as toVite } from "../adapter-DvWJNDHu.js";
4
+ import { a as createIntegratedConfigLoader, r as toVite } from "../adapter-Bf3BetFi.js";
5
5
  import { t as createMetaLoader } from "../meta-DWvKGgBH.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";
@@ -1,6 +1,6 @@
1
1
  import { t as createMdxLoader } from "../mdx-3XO-apdE.js";
2
2
  import { i as buildConfig, t as createCore } from "../core-BPlsDtvN.js";
3
- import { a as createIntegratedConfigLoader, r as toVite } from "../adapter-DvWJNDHu.js";
3
+ import { a as createIntegratedConfigLoader, r as toVite } from "../adapter-Bf3BetFi.js";
4
4
  import { t as createMetaLoader } from "../meta-DWvKGgBH.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";
@@ -109,11 +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-Dm0fXCC7.js");
112
+ const { getConfig } = await import("../dist-DaA0UDzw.js");
113
113
  return getConfig({ root: core.root });
114
114
  },
115
115
  async buildStart() {
116
- await managed.core.emit({ write: true });
116
+ if (forcedConfig || managed.watchConfig) await managed.core.emit({ write: true });
117
117
  },
118
118
  async configureServer(server) {
119
119
  const core = managed.core;
@@ -122,7 +122,7 @@ function mdx(forcedConfig, pluginOptions = {}) {
122
122
  const onChange = async (file) => {
123
123
  if (path.resolve(file) !== core.configPath) return;
124
124
  await managed.reload();
125
- await core.emit({ write: true });
125
+ if (managed.watchConfig) await core.emit({ write: true });
126
126
  };
127
127
  server.watcher.on("change", onChange);
128
128
  server.watcher.on("add", onChange);
@@ -168,7 +168,7 @@ async function loadCoreConfig(core, forcedConfig, { globalOptions } = {}) {
168
168
  async function postInstall(pluginOptions = {}) {
169
169
  const managed = createManagedCore(process.cwd(), void 0, pluginOptions);
170
170
  await managed.reload();
171
- await managed.core.emit({ write: true });
171
+ if (managed.watchConfig) await managed.core.emit({ write: true });
172
172
  }
173
173
  function createViteCore(root, { index = true, configPath, outDir }) {
174
174
  if (index === true) index = {};
@@ -1,5 +1,5 @@
1
1
  import { t as createMdxLoader } from "../mdx-3XO-apdE.js";
2
- import { i as toWebpack, o as createStandaloneConfigLoader } from "../adapter-DvWJNDHu.js";
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
5
5
  let instance;
@@ -1,4 +1,4 @@
1
- import { i as toWebpack, o as createStandaloneConfigLoader } from "../adapter-DvWJNDHu.js";
1
+ import { i as toWebpack, o as createStandaloneConfigLoader } from "../adapter-Bf3BetFi.js";
2
2
  import { t as createMetaLoader } from "../meta-DWvKGgBH.js";
3
3
  import { t as getCore } from "../webpack-BSog6pml.js";
4
4
  //#region src/webpack/meta.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-mdx",
3
- "version": "15.2.1",
3
+ "version": "15.2.2",
4
4
  "description": "The built-in source for Fumadocs",
5
5
  "keywords": [
6
6
  "Docs",
@@ -91,10 +91,10 @@
91
91
  "tsdown": "0.22.14",
92
92
  "vite": "^8.1.5",
93
93
  "webpack": "^5.109.2",
94
+ "@fumadocs/satteri": "0.3.1",
94
95
  "@fumadocs/vite": "0.1.0",
95
- "tsconfig": "0.0.0",
96
96
  "fumadocs-core": "16.14.0",
97
- "@fumadocs/satteri": "0.3.1"
97
+ "tsconfig": "0.0.0"
98
98
  },
99
99
  "peerDependencies": {
100
100
  "@fumadocs/satteri": "0.x.x",