fumadocs-mdx 13.0.2 → 13.0.3

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.
package/dist/bin.cjs CHANGED
@@ -454,17 +454,16 @@ function next() {
454
454
  name: "next",
455
455
  config(v) {
456
456
  config = v;
457
- shouldEmitOnChange = false;
458
- for (const collection of config.collections.values()) {
459
- if (collection.type === "doc" && collection.async || collection.type === "docs" && collection.docs.async) {
460
- shouldEmitOnChange = true;
457
+ shouldEmitOnChange = Array.from(config.collections.values()).some(
458
+ (collection) => {
459
+ return collection.type === "doc" && collection.async || collection.type === "docs" && collection.docs.async;
461
460
  }
462
- }
461
+ );
463
462
  },
464
463
  configureServer(server) {
465
464
  if (!server.watcher) return;
466
- server.watcher.on("all", async () => {
467
- if (!shouldEmitOnChange) return;
465
+ server.watcher.on("all", async (event) => {
466
+ if (event === "change" && !shouldEmitOnChange) return;
468
467
  await this.core.emitAndWrite({
469
468
  filterPlugin: (plugin) => plugin.name === "next"
470
469
  });
@@ -1447,27 +1446,48 @@ var init_glob_import = __esm({
1447
1446
  });
1448
1447
 
1449
1448
  // src/plugins/vite.ts
1450
- function vite(options) {
1449
+ function vite({
1450
+ index
1451
+ }) {
1451
1452
  let config;
1452
1453
  return {
1453
1454
  config(v) {
1454
1455
  config = v;
1455
1456
  },
1456
1457
  emit() {
1457
- return [
1458
- {
1459
- path: "index.ts",
1460
- content: indexFile2(this.configPath, this.outDir, config, options)
1461
- }
1462
- ];
1458
+ const out = [];
1459
+ if (index === false) return out;
1460
+ const indexOptions = typeof index === "object" ? index : {};
1461
+ const { browser = false } = indexOptions;
1462
+ if (browser) {
1463
+ out.push({
1464
+ path: "browser.ts",
1465
+ content: indexFile2(this, config, indexOptions, "browser")
1466
+ });
1467
+ }
1468
+ out.push({
1469
+ path: "index.ts",
1470
+ content: indexFile2(
1471
+ this,
1472
+ config,
1473
+ indexOptions,
1474
+ browser ? "server" : "all"
1475
+ )
1476
+ });
1477
+ return out;
1463
1478
  }
1464
1479
  };
1465
1480
  }
1466
- function indexFile2(configPath, outDir, config, options) {
1481
+ function indexFile2({ configPath, outDir }, config, options, environment) {
1467
1482
  const { addJsExtension = false, runtime } = options;
1483
+ const runtimePath = {
1484
+ all: "fumadocs-mdx/runtime/vite",
1485
+ server: "fumadocs-mdx/runtime/vite.server",
1486
+ browser: "fumadocs-mdx/runtime/vite.browser"
1487
+ }[environment];
1468
1488
  const lines = [
1469
1489
  '/// <reference types="vite/client" />',
1470
- `import { fromConfig } from 'fumadocs-mdx/runtime/vite';`,
1490
+ `import { fromConfig } from '${runtimePath}';`,
1471
1491
  `import type * as Config from '${toImportPath(configPath, {
1472
1492
  relativeTo: outDir,
1473
1493
  jsExtension: addJsExtension
@@ -1686,7 +1706,9 @@ function createViteCore({
1686
1706
  outDir
1687
1707
  },
1688
1708
  [
1689
- generateIndexFile !== false && vite(typeof generateIndexFile === "object" ? generateIndexFile : {})
1709
+ vite({
1710
+ index: generateIndexFile
1711
+ })
1690
1712
  ]
1691
1713
  );
1692
1714
  }
@@ -3,7 +3,7 @@ import { StructuredData } from 'fumadocs-core/mdx-plugins';
3
3
  import { TOCItemType } from 'fumadocs-core/toc';
4
4
  import { FC } from 'react';
5
5
  import { MDXProps } from 'mdx/types';
6
- import { E as ExtractedReference } from './core-B6j6Fxse.js';
6
+ import { E as ExtractedReference } from './core-DhfmVKRA.js';
7
7
 
8
8
  type Processor = ReturnType<typeof createProcessor>;
9
9
  interface CompilerOptions {
@@ -3,7 +3,7 @@ import { StructuredData } from 'fumadocs-core/mdx-plugins';
3
3
  import { TOCItemType } from 'fumadocs-core/toc';
4
4
  import { FC } from 'react';
5
5
  import { MDXProps } from 'mdx/types';
6
- import { E as ExtractedReference } from './core-B6j6Fxse.cjs';
6
+ import { E as ExtractedReference } from './core-DhfmVKRA.cjs';
7
7
 
8
8
  type Processor = ReturnType<typeof createProcessor>;
9
9
  interface CompilerOptions {
@@ -1,5 +1,5 @@
1
1
  import { BunPlugin } from 'bun';
2
- import { C as CoreOptions } from '../core-B6j6Fxse.cjs';
2
+ import { C as CoreOptions } from '../core-DhfmVKRA.cjs';
3
3
  import '@standard-schema/spec';
4
4
  import 'fumadocs-core/mdx-plugins';
5
5
  import '@mdx-js/mdx';
@@ -1,5 +1,5 @@
1
1
  import { BunPlugin } from 'bun';
2
- import { C as CoreOptions } from '../core-B6j6Fxse.js';
2
+ import { C as CoreOptions } from '../core-DhfmVKRA.js';
3
3
  import '@standard-schema/spec';
4
4
  import 'fumadocs-core/mdx-plugins';
5
5
  import '@mdx-js/mdx';
@@ -1,4 +1,4 @@
1
- export { A as AnyCollection, B as BaseCollection, a as CollectionSchema, D as DefaultMDXOptions, b as DocCollection, c as DocsCollection, G as GlobalConfig, M as MetaCollection, P as PostprocessOptions, d as defineCollections, f as defineConfig, e as defineDocs, h as frontmatterSchema, g as getDefaultMDXOptions, m as metaSchema } from '../core-B6j6Fxse.cjs';
1
+ export { A as AnyCollection, B as BaseCollection, a as CollectionSchema, D as DefaultMDXOptions, b as DocCollection, c as DocsCollection, G as GlobalConfig, M as MetaCollection, P as PostprocessOptions, d as defineCollections, f as defineConfig, e as defineDocs, h as frontmatterSchema, g as getDefaultMDXOptions, m as metaSchema } from '../core-DhfmVKRA.cjs';
2
2
  import { Processor, Transformer } from 'unified';
3
3
  import { Root } from 'mdast';
4
4
  import '@standard-schema/spec';
@@ -1,4 +1,4 @@
1
- export { A as AnyCollection, B as BaseCollection, a as CollectionSchema, D as DefaultMDXOptions, b as DocCollection, c as DocsCollection, G as GlobalConfig, M as MetaCollection, P as PostprocessOptions, d as defineCollections, f as defineConfig, e as defineDocs, h as frontmatterSchema, g as getDefaultMDXOptions, m as metaSchema } from '../core-B6j6Fxse.js';
1
+ export { A as AnyCollection, B as BaseCollection, a as CollectionSchema, D as DefaultMDXOptions, b as DocCollection, c as DocsCollection, G as GlobalConfig, M as MetaCollection, P as PostprocessOptions, d as defineCollections, f as defineConfig, e as defineDocs, h as frontmatterSchema, g as getDefaultMDXOptions, m as metaSchema } from '../core-DhfmVKRA.js';
2
2
  import { Processor, Transformer } from 'unified';
3
3
  import { Root } from 'mdast';
4
4
  import '@standard-schema/spec';
@@ -115,6 +115,8 @@ interface GlobalConfig {
115
115
  plugins?: PluginOption[];
116
116
  /**
117
117
  * Configure global MDX options
118
+ *
119
+ * @remarks `GlobalConfigMDXOptions`
118
120
  */
119
121
  mdxOptions?: GlobalConfigMDXOptions | (() => Promise<GlobalConfigMDXOptions>);
120
122
  /**
@@ -115,6 +115,8 @@ interface GlobalConfig {
115
115
  plugins?: PluginOption[];
116
116
  /**
117
117
  * Configure global MDX options
118
+ *
119
+ * @remarks `GlobalConfigMDXOptions`
118
120
  */
119
121
  mdxOptions?: GlobalConfigMDXOptions | (() => Promise<GlobalConfigMDXOptions>);
120
122
  /**
package/dist/index.d.cts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { StructuredData } from 'fumadocs-core/mdx-plugins';
2
2
  import { TOCItemType } from 'fumadocs-core/toc';
3
3
  import { MDXContent } from 'mdx/types';
4
- import { E as ExtractedReference } from './core-B6j6Fxse.cjs';
5
- export { p as Core, C as CoreOptions, j as EmitEntry, n as EmitOptions, i as Plugin, k as PluginContext, l as PluginOption, S as ServerContext, o as createCore } from './core-B6j6Fxse.cjs';
4
+ import { E as ExtractedReference } from './core-DhfmVKRA.cjs';
5
+ export { p as Core, C as CoreOptions, j as EmitEntry, n as EmitOptions, i as Plugin, k as PluginContext, l as PluginOption, S as ServerContext, o as createCore } from './core-DhfmVKRA.cjs';
6
6
  import { Root } from 'mdast';
7
- import { C as CompiledMDXProperties } from './build-mdx-D-r3_eQL.cjs';
7
+ import { C as CompiledMDXProperties } from './build-mdx-TtQzmq6W.cjs';
8
8
  import '@standard-schema/spec';
9
9
  import '@mdx-js/mdx';
10
10
  import 'unified';
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { StructuredData } from 'fumadocs-core/mdx-plugins';
2
2
  import { TOCItemType } from 'fumadocs-core/toc';
3
3
  import { MDXContent } from 'mdx/types';
4
- import { E as ExtractedReference } from './core-B6j6Fxse.js';
5
- export { p as Core, C as CoreOptions, j as EmitEntry, n as EmitOptions, i as Plugin, k as PluginContext, l as PluginOption, S as ServerContext, o as createCore } from './core-B6j6Fxse.js';
4
+ import { E as ExtractedReference } from './core-DhfmVKRA.js';
5
+ export { p as Core, C as CoreOptions, j as EmitEntry, n as EmitOptions, i as Plugin, k as PluginContext, l as PluginOption, S as ServerContext, o as createCore } from './core-DhfmVKRA.js';
6
6
  import { Root } from 'mdast';
7
- import { C as CompiledMDXProperties } from './build-mdx-CCNr86q6.js';
7
+ import { C as CompiledMDXProperties } from './build-mdx--WI4tf2-.js';
8
8
  import '@standard-schema/spec';
9
9
  import '@mdx-js/mdx';
10
10
  import 'unified';
@@ -422,17 +422,16 @@ function next() {
422
422
  name: "next",
423
423
  config(v) {
424
424
  config = v;
425
- shouldEmitOnChange = false;
426
- for (const collection of config.collections.values()) {
427
- if (collection.type === "doc" && collection.async || collection.type === "docs" && collection.docs.async) {
428
- shouldEmitOnChange = true;
425
+ shouldEmitOnChange = Array.from(config.collections.values()).some(
426
+ (collection) => {
427
+ return collection.type === "doc" && collection.async || collection.type === "docs" && collection.docs.async;
429
428
  }
430
- }
429
+ );
431
430
  },
432
431
  configureServer(server) {
433
432
  if (!server.watcher) return;
434
- server.watcher.on("all", async () => {
435
- if (!shouldEmitOnChange) return;
433
+ server.watcher.on("all", async (event) => {
434
+ if (event === "change" && !shouldEmitOnChange) return;
436
435
  await this.core.emitAndWrite({
437
436
  filterPlugin: (plugin) => plugin.name === "next"
438
437
  });
@@ -59,17 +59,16 @@ function next() {
59
59
  name: "next",
60
60
  config(v) {
61
61
  config = v;
62
- shouldEmitOnChange = false;
63
- for (const collection of config.collections.values()) {
64
- if (collection.type === "doc" && collection.async || collection.type === "docs" && collection.docs.async) {
65
- shouldEmitOnChange = true;
62
+ shouldEmitOnChange = Array.from(config.collections.values()).some(
63
+ (collection) => {
64
+ return collection.type === "doc" && collection.async || collection.type === "docs" && collection.docs.async;
66
65
  }
67
- }
66
+ );
68
67
  },
69
68
  configureServer(server) {
70
69
  if (!server.watcher) return;
71
- server.watcher.on("all", async () => {
72
- if (!shouldEmitOnChange) return;
70
+ server.watcher.on("all", async (event) => {
71
+ if (event === "change" && !shouldEmitOnChange) return;
73
72
  await this.core.emitAndWrite({
74
73
  filterPlugin: (plugin) => plugin.name === "next"
75
74
  });
@@ -1,4 +1,4 @@
1
- import { i as Plugin } from '../core-B6j6Fxse.cjs';
1
+ import { i as Plugin } from '../core-DhfmVKRA.cjs';
2
2
  import '@standard-schema/spec';
3
3
  import 'fumadocs-core/mdx-plugins';
4
4
  import '@mdx-js/mdx';
@@ -1,4 +1,4 @@
1
- import { i as Plugin } from '../core-B6j6Fxse.js';
1
+ import { i as Plugin } from '../core-DhfmVKRA.js';
2
2
  import '@standard-schema/spec';
3
3
  import 'fumadocs-core/mdx-plugins';
4
4
  import '@mdx-js/mdx';
@@ -1,5 +1,5 @@
1
- import { c as RuntimeAsync } from '../../types-DKGMoay5.cjs';
2
- import { L as LoadedConfig } from '../../core-B6j6Fxse.cjs';
1
+ import { c as RuntimeAsync } from '../../types-zrV4v6mp.cjs';
2
+ import { L as LoadedConfig } from '../../core-DhfmVKRA.cjs';
3
3
  import '@standard-schema/spec';
4
4
  import 'fumadocs-core/source';
5
5
  import '../../index.cjs';
@@ -7,7 +7,7 @@ import 'fumadocs-core/mdx-plugins';
7
7
  import 'fumadocs-core/toc';
8
8
  import 'mdx/types';
9
9
  import 'mdast';
10
- import '../../build-mdx-D-r3_eQL.cjs';
10
+ import '../../build-mdx-TtQzmq6W.cjs';
11
11
  import '@mdx-js/mdx';
12
12
  import 'react';
13
13
  import 'unified';
@@ -1,5 +1,5 @@
1
- import { c as RuntimeAsync } from '../../types-AGzTfBmf.js';
2
- import { L as LoadedConfig } from '../../core-B6j6Fxse.js';
1
+ import { c as RuntimeAsync } from '../../types-CMva20Zp.js';
2
+ import { L as LoadedConfig } from '../../core-DhfmVKRA.js';
3
3
  import '@standard-schema/spec';
4
4
  import 'fumadocs-core/source';
5
5
  import '../../index.js';
@@ -7,7 +7,7 @@ import 'fumadocs-core/mdx-plugins';
7
7
  import 'fumadocs-core/toc';
8
8
  import 'mdx/types';
9
9
  import 'mdast';
10
- import '../../build-mdx-CCNr86q6.js';
10
+ import '../../build-mdx--WI4tf2-.js';
11
11
  import '@mdx-js/mdx';
12
12
  import 'react';
13
13
  import 'unified';
@@ -1,9 +1,9 @@
1
1
  import { PageData, MetaData, Source, VirtualFile } from 'fumadocs-core/source';
2
- import { R as Runtime } from '../../types-DKGMoay5.cjs';
3
- export { b as AsyncDocOut, A as AsyncRuntimeFile, D as DocOut, M as MetaOut, c as RuntimeAsync, a as RuntimeFile } from '../../types-DKGMoay5.cjs';
2
+ import { R as Runtime } from '../../types-zrV4v6mp.cjs';
3
+ export { b as AsyncDocOut, A as AsyncRuntimeFile, D as DocOut, M as MetaOut, c as RuntimeAsync, a as RuntimeFile } from '../../types-zrV4v6mp.cjs';
4
4
  import { FileInfo } from '../../index.cjs';
5
5
  import '@standard-schema/spec';
6
- import '../../core-B6j6Fxse.cjs';
6
+ import '../../core-DhfmVKRA.cjs';
7
7
  import 'fumadocs-core/mdx-plugins';
8
8
  import '@mdx-js/mdx';
9
9
  import 'unified';
@@ -12,7 +12,7 @@ import 'chokidar';
12
12
  import 'fumadocs-core/toc';
13
13
  import 'mdx/types';
14
14
  import 'mdast';
15
- import '../../build-mdx-D-r3_eQL.cjs';
15
+ import '../../build-mdx-TtQzmq6W.cjs';
16
16
  import 'react';
17
17
 
18
18
  declare const _runtime: Runtime;
@@ -1,9 +1,9 @@
1
1
  import { PageData, MetaData, Source, VirtualFile } from 'fumadocs-core/source';
2
- import { R as Runtime } from '../../types-AGzTfBmf.js';
3
- export { b as AsyncDocOut, A as AsyncRuntimeFile, D as DocOut, M as MetaOut, c as RuntimeAsync, a as RuntimeFile } from '../../types-AGzTfBmf.js';
2
+ import { R as Runtime } from '../../types-CMva20Zp.js';
3
+ export { b as AsyncDocOut, A as AsyncRuntimeFile, D as DocOut, M as MetaOut, c as RuntimeAsync, a as RuntimeFile } from '../../types-CMva20Zp.js';
4
4
  import { FileInfo } from '../../index.js';
5
5
  import '@standard-schema/spec';
6
- import '../../core-B6j6Fxse.js';
6
+ import '../../core-DhfmVKRA.js';
7
7
  import 'fumadocs-core/mdx-plugins';
8
8
  import '@mdx-js/mdx';
9
9
  import 'unified';
@@ -12,7 +12,7 @@ import 'chokidar';
12
12
  import 'fumadocs-core/toc';
13
13
  import 'mdx/types';
14
14
  import 'mdast';
15
- import '../../build-mdx-CCNr86q6.js';
15
+ import '../../build-mdx--WI4tf2-.js';
16
16
  import 'react';
17
17
 
18
18
  declare const _runtime: Runtime;
@@ -1,6 +1,6 @@
1
- import { b as DocCollection, c as DocsCollection, M as MetaCollection } from '../../core-B6j6Fxse.cjs';
1
+ import { b as DocCollection, c as DocsCollection, M as MetaCollection } from '../../core-DhfmVKRA.cjs';
2
2
  import { StandardSchemaV1 } from '@standard-schema/spec';
3
- import { C as CompiledMDXProperties } from '../../build-mdx-D-r3_eQL.cjs';
3
+ import { C as CompiledMDXProperties } from '../../build-mdx-TtQzmq6W.cjs';
4
4
  import { ReactNode, FC } from 'react';
5
5
  import 'fumadocs-core/mdx-plugins';
6
6
  import '@mdx-js/mdx';
@@ -1,6 +1,6 @@
1
- import { b as DocCollection, c as DocsCollection, M as MetaCollection } from '../../core-B6j6Fxse.js';
1
+ import { b as DocCollection, c as DocsCollection, M as MetaCollection } from '../../core-DhfmVKRA.js';
2
2
  import { StandardSchemaV1 } from '@standard-schema/spec';
3
- import { C as CompiledMDXProperties } from '../../build-mdx-CCNr86q6.js';
3
+ import { C as CompiledMDXProperties } from '../../build-mdx--WI4tf2-.js';
4
4
  import { ReactNode, FC } from 'react';
5
5
  import 'fumadocs-core/mdx-plugins';
6
6
  import '@mdx-js/mdx';
@@ -2,14 +2,14 @@ import { PageData, MetaData, Source } from 'fumadocs-core/source';
2
2
  import { BaseCreate, DocMap, MetaMap, LazyDocMap } from './browser.cjs';
3
3
  export { ClientLoader, ClientLoaderOptions, CompiledMDXFile, createClientLoader, fromConfig as fromConfigBase, toClientRenderer } from './browser.cjs';
4
4
  import { DocCollectionEntry, MetaCollectionEntry, AsyncDocCollectionEntry } from '../../index.cjs';
5
- import '../../core-B6j6Fxse.cjs';
5
+ import '../../core-DhfmVKRA.cjs';
6
6
  import '@standard-schema/spec';
7
7
  import 'fumadocs-core/mdx-plugins';
8
8
  import '@mdx-js/mdx';
9
9
  import 'unified';
10
10
  import 'zod';
11
11
  import 'chokidar';
12
- import '../../build-mdx-D-r3_eQL.cjs';
12
+ import '../../build-mdx-TtQzmq6W.cjs';
13
13
  import 'fumadocs-core/toc';
14
14
  import 'react';
15
15
  import 'mdx/types';
@@ -2,14 +2,14 @@ import { PageData, MetaData, Source } from 'fumadocs-core/source';
2
2
  import { BaseCreate, DocMap, MetaMap, LazyDocMap } from './browser.js';
3
3
  export { ClientLoader, ClientLoaderOptions, CompiledMDXFile, createClientLoader, fromConfig as fromConfigBase, toClientRenderer } from './browser.js';
4
4
  import { DocCollectionEntry, MetaCollectionEntry, AsyncDocCollectionEntry } from '../../index.js';
5
- import '../../core-B6j6Fxse.js';
5
+ import '../../core-DhfmVKRA.js';
6
6
  import '@standard-schema/spec';
7
7
  import 'fumadocs-core/mdx-plugins';
8
8
  import '@mdx-js/mdx';
9
9
  import 'unified';
10
10
  import 'zod';
11
11
  import 'chokidar';
12
- import '../../build-mdx-CCNr86q6.js';
12
+ import '../../build-mdx--WI4tf2-.js';
13
13
  import 'fumadocs-core/toc';
14
14
  import 'react';
15
15
  import 'mdx/types';
@@ -1,6 +1,6 @@
1
1
  import { StandardSchemaV1 } from '@standard-schema/spec';
2
2
  import { Source, PageData, MetaData } from 'fumadocs-core/source';
3
- import { L as LoadedConfig, b as DocCollection, c as DocsCollection, M as MetaCollection } from './core-B6j6Fxse.js';
3
+ import { L as LoadedConfig, b as DocCollection, c as DocsCollection, M as MetaCollection } from './core-DhfmVKRA.js';
4
4
  import { FileInfo, AsyncDocCollectionEntry, MetaCollectionEntry, DocCollectionEntry } from './index.js';
5
5
 
6
6
  interface RuntimeFile {
@@ -1,6 +1,6 @@
1
1
  import { StandardSchemaV1 } from '@standard-schema/spec';
2
2
  import { Source, PageData, MetaData } from 'fumadocs-core/source';
3
- import { L as LoadedConfig, b as DocCollection, c as DocsCollection, M as MetaCollection } from './core-B6j6Fxse.cjs';
3
+ import { L as LoadedConfig, b as DocCollection, c as DocsCollection, M as MetaCollection } from './core-DhfmVKRA.cjs';
4
4
  import { FileInfo, AsyncDocCollectionEntry, MetaCollectionEntry, DocCollectionEntry } from './index.cjs';
5
5
 
6
6
  interface RuntimeFile {
@@ -874,27 +874,48 @@ function generateGlobImport(patterns, options) {
874
874
 
875
875
  // src/plugins/vite.ts
876
876
  var import_node_path8 = __toESM(require("path"), 1);
877
- function vite(options) {
877
+ function vite({
878
+ index
879
+ }) {
878
880
  let config;
879
881
  return {
880
882
  config(v) {
881
883
  config = v;
882
884
  },
883
885
  emit() {
884
- return [
885
- {
886
- path: "index.ts",
887
- content: indexFile(this.configPath, this.outDir, config, options)
888
- }
889
- ];
886
+ const out = [];
887
+ if (index === false) return out;
888
+ const indexOptions = typeof index === "object" ? index : {};
889
+ const { browser = false } = indexOptions;
890
+ if (browser) {
891
+ out.push({
892
+ path: "browser.ts",
893
+ content: indexFile(this, config, indexOptions, "browser")
894
+ });
895
+ }
896
+ out.push({
897
+ path: "index.ts",
898
+ content: indexFile(
899
+ this,
900
+ config,
901
+ indexOptions,
902
+ browser ? "server" : "all"
903
+ )
904
+ });
905
+ return out;
890
906
  }
891
907
  };
892
908
  }
893
- function indexFile(configPath, outDir, config, options) {
909
+ function indexFile({ configPath, outDir }, config, options, environment) {
894
910
  const { addJsExtension = false, runtime } = options;
911
+ const runtimePath = {
912
+ all: "fumadocs-mdx/runtime/vite",
913
+ server: "fumadocs-mdx/runtime/vite.server",
914
+ browser: "fumadocs-mdx/runtime/vite.browser"
915
+ }[environment];
895
916
  const lines = [
896
917
  '/// <reference types="vite/client" />',
897
- `import { fromConfig } from 'fumadocs-mdx/runtime/vite';`,
918
+ `import { fromConfig } from '${runtimePath}';`,
898
919
  `import type * as Config from '${toImportPath(configPath, {
899
920
  relativeTo: outDir,
900
921
  jsExtension: addJsExtension
@@ -1172,7 +1193,9 @@ function createViteCore({
1172
1193
  outDir
1173
1194
  },
1174
1195
  [
1175
- generateIndexFile !== false && vite(typeof generateIndexFile === "object" ? generateIndexFile : {})
1196
+ vite({
1197
+ index: generateIndexFile
1198
+ })
1176
1199
  ]
1177
1200
  );
1178
1201
  }
@@ -13,6 +13,10 @@ interface IndexFileOptions {
13
13
  * add `.js` extensions to imports, needed for ESM without bundler resolution
14
14
  */
15
15
  addJsExtension?: boolean;
16
+ /**
17
+ * Generate entry point for browser environment
18
+ */
19
+ browser?: boolean;
16
20
  }
17
21
 
18
22
  interface PluginOptions {
@@ -13,6 +13,10 @@ interface IndexFileOptions {
13
13
  * add `.js` extensions to imports, needed for ESM without bundler resolution
14
14
  */
15
15
  addJsExtension?: boolean;
16
+ /**
17
+ * Generate entry point for browser environment
18
+ */
19
+ browser?: boolean;
16
20
  }
17
21
 
18
22
  interface PluginOptions {
@@ -59,27 +59,48 @@ function generateGlobImport(patterns, options) {
59
59
 
60
60
  // src/plugins/vite.ts
61
61
  import path2 from "path";
62
- function vite(options) {
62
+ function vite({
63
+ index
64
+ }) {
63
65
  let config;
64
66
  return {
65
67
  config(v) {
66
68
  config = v;
67
69
  },
68
70
  emit() {
69
- return [
70
- {
71
- path: "index.ts",
72
- content: indexFile(this.configPath, this.outDir, config, options)
73
- }
74
- ];
71
+ const out = [];
72
+ if (index === false) return out;
73
+ const indexOptions = typeof index === "object" ? index : {};
74
+ const { browser = false } = indexOptions;
75
+ if (browser) {
76
+ out.push({
77
+ path: "browser.ts",
78
+ content: indexFile(this, config, indexOptions, "browser")
79
+ });
80
+ }
81
+ out.push({
82
+ path: "index.ts",
83
+ content: indexFile(
84
+ this,
85
+ config,
86
+ indexOptions,
87
+ browser ? "server" : "all"
88
+ )
89
+ });
90
+ return out;
75
91
  }
76
92
  };
77
93
  }
78
- function indexFile(configPath, outDir, config, options) {
94
+ function indexFile({ configPath, outDir }, config, options, environment) {
79
95
  const { addJsExtension = false, runtime } = options;
96
+ const runtimePath = {
97
+ all: "fumadocs-mdx/runtime/vite",
98
+ server: "fumadocs-mdx/runtime/vite.server",
99
+ browser: "fumadocs-mdx/runtime/vite.browser"
100
+ }[environment];
80
101
  const lines = [
81
102
  '/// <reference types="vite/client" />',
82
- `import { fromConfig } from 'fumadocs-mdx/runtime/vite';`,
103
+ `import { fromConfig } from '${runtimePath}';`,
83
104
  `import type * as Config from '${toImportPath(configPath, {
84
105
  relativeTo: outDir,
85
106
  jsExtension: addJsExtension
@@ -284,7 +305,9 @@ function createViteCore({
284
305
  outDir
285
306
  },
286
307
  [
287
- generateIndexFile !== false && vite(typeof generateIndexFile === "object" ? generateIndexFile : {})
308
+ vite({
309
+ index: generateIndexFile
310
+ })
288
311
  ]
289
312
  );
290
313
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-mdx",
3
- "version": "13.0.2",
3
+ "version": "13.0.3",
4
4
  "description": "The built-in source for Fumadocs",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -78,7 +78,7 @@
78
78
  "@standard-schema/spec": "^1.0.0",
79
79
  "chokidar": "^4.0.3",
80
80
  "esbuild": "^0.25.11",
81
- "estree-util-value-to-estree": "^3.4.1",
81
+ "estree-util-value-to-estree": "^3.5.0",
82
82
  "js-yaml": "^4.1.0",
83
83
  "lru-cache": "^11.2.2",
84
84
  "mdast-util-to-markdown": "^2.1.2",
@@ -93,27 +93,27 @@
93
93
  "zod": "^4.1.12"
94
94
  },
95
95
  "devDependencies": {
96
- "@types/bun": "^1.3.0",
96
+ "@types/bun": "^1.3.1",
97
97
  "@types/js-yaml": "^4.0.9",
98
98
  "@types/mdast": "^4.0.4",
99
99
  "@types/mdx": "^2.0.13",
100
- "@types/node": "^24.9.1",
100
+ "@types/node": "^24.9.2",
101
101
  "@types/picomatch": "^4.0.2",
102
102
  "@types/react": "^19.2.2",
103
103
  "mdast-util-directive": "^3.1.0",
104
104
  "mdast-util-mdx-jsx": "^3.2.0",
105
- "next": "16.0.0",
105
+ "next": "16.0.1",
106
106
  "react": "^19.2.0",
107
107
  "remark": "^15.0.1",
108
108
  "remark-directive": "^4.0.0",
109
109
  "remark-stringify": "^11.0.0",
110
110
  "rollup": "^4.52.5",
111
111
  "vfile": "^6.0.3",
112
- "vite": "^7.1.11",
112
+ "vite": "^7.1.12",
113
113
  "webpack": "^5.102.1",
114
114
  "@fumadocs/mdx-remote": "1.4.3",
115
115
  "eslint-config-custom": "0.0.0",
116
- "fumadocs-core": "16.0.3",
116
+ "fumadocs-core": "16.0.6",
117
117
  "tsconfig": "0.0.0"
118
118
  },
119
119
  "peerDependencies": {