fumadocs-mdx 13.0.1 → 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
@@ -1486,12 +1506,12 @@ ${obj}
1486
1506
  }
1487
1507
  function doc(name, collection) {
1488
1508
  const patterns = getGlobPatterns(collection);
1489
- const base = getGlobBase(collection);
1509
+ const dir = getCollectionDir(collection);
1490
1510
  const docGlob = generateGlob(patterns, {
1491
1511
  query: {
1492
1512
  collection: name
1493
1513
  },
1494
- base
1514
+ base: dir
1495
1515
  });
1496
1516
  if (collection.async) {
1497
1517
  const headBlob = generateGlob(patterns, {
@@ -1500,32 +1520,32 @@ ${obj}
1500
1520
  collection: name
1501
1521
  },
1502
1522
  import: "frontmatter",
1503
- base
1523
+ base: dir
1504
1524
  });
1505
- return `create.docLazy("${name}", "${base}", ${headBlob}, ${docGlob})`;
1525
+ return `create.docLazy("${name}", "${dir}", ${headBlob}, ${docGlob})`;
1506
1526
  }
1507
- return `create.doc("${name}", "${base}", ${docGlob})`;
1527
+ return `create.doc("${name}", "${dir}", ${docGlob})`;
1508
1528
  }
1509
1529
  function meta(name, collection) {
1510
1530
  const patterns = getGlobPatterns(collection);
1511
- const base = getGlobBase(collection);
1512
- return `create.meta("${name}", "${base}", ${generateGlob(patterns, {
1531
+ const dir = getCollectionDir(collection);
1532
+ return `create.meta("${name}", "${dir}", ${generateGlob(patterns, {
1513
1533
  import: "default",
1514
- base,
1534
+ base: dir,
1515
1535
  query: {
1516
1536
  collection: name
1517
1537
  }
1518
1538
  })})`;
1519
1539
  }
1520
1540
  function generateGlob(patterns, options2) {
1521
- patterns = mapGlobPatterns(patterns);
1541
+ patterns = patterns.map(normalizeGlobPath);
1522
1542
  if (runtime === "node" || runtime === "bun") {
1523
1543
  return generateGlobImport(patterns, options2);
1524
1544
  } else {
1525
1545
  return `import.meta.glob(${JSON.stringify(patterns)}, ${JSON.stringify(
1526
1546
  {
1527
1547
  ...options2,
1528
- base: import_node_path10.default.relative(outDir, options2.base)
1548
+ base: normalizeGlobPath(import_node_path10.default.relative(outDir, options2.base))
1529
1549
  },
1530
1550
  null,
1531
1551
  2
@@ -1546,24 +1566,29 @@ ${obj}
1546
1566
  }
1547
1567
  return lines.join("\n");
1548
1568
  }
1549
- function mapGlobPatterns(patterns) {
1550
- return patterns.map(enforceRelative);
1551
- }
1552
- function enforceRelative(file) {
1569
+ function normalizeGlobPath(file) {
1570
+ file = slash(file);
1553
1571
  if (file.startsWith("./")) return file;
1554
1572
  if (file.startsWith("/")) return `.${file}`;
1555
1573
  return `./${file}`;
1556
1574
  }
1557
- function getGlobBase(collection) {
1558
- let dir = collection.dir;
1575
+ function getCollectionDir(collection) {
1576
+ const dir = collection.dir;
1559
1577
  if (Array.isArray(dir)) {
1560
1578
  if (dir.length !== 1)
1561
1579
  throw new Error(
1562
1580
  `[Fumadocs MDX] Vite Plugin doesn't support multiple \`dir\` for a collection at the moment.`
1563
1581
  );
1564
- dir = dir[0];
1582
+ return dir[0];
1583
+ }
1584
+ return dir;
1585
+ }
1586
+ function slash(path16) {
1587
+ const isExtendedLengthPath = path16.startsWith("\\\\?\\");
1588
+ if (isExtendedLengthPath) {
1589
+ return path16;
1565
1590
  }
1566
- return enforceRelative(dir);
1591
+ return path16.replaceAll("\\", "/");
1567
1592
  }
1568
1593
  var import_node_path10;
1569
1594
  var init_vite = __esm({
@@ -1681,7 +1706,9 @@ function createViteCore({
1681
1706
  outDir
1682
1707
  },
1683
1708
  [
1684
- generateIndexFile !== false && vite(typeof generateIndexFile === "object" ? generateIndexFile : {})
1709
+ vite({
1710
+ index: generateIndexFile
1711
+ })
1685
1712
  ]
1686
1713
  );
1687
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
@@ -913,12 +934,12 @@ ${obj}
913
934
  }
914
935
  function doc(name, collection) {
915
936
  const patterns = getGlobPatterns(collection);
916
- const base = getGlobBase(collection);
937
+ const dir = getCollectionDir(collection);
917
938
  const docGlob = generateGlob(patterns, {
918
939
  query: {
919
940
  collection: name
920
941
  },
921
- base
942
+ base: dir
922
943
  });
923
944
  if (collection.async) {
924
945
  const headBlob = generateGlob(patterns, {
@@ -927,32 +948,32 @@ ${obj}
927
948
  collection: name
928
949
  },
929
950
  import: "frontmatter",
930
- base
951
+ base: dir
931
952
  });
932
- return `create.docLazy("${name}", "${base}", ${headBlob}, ${docGlob})`;
953
+ return `create.docLazy("${name}", "${dir}", ${headBlob}, ${docGlob})`;
933
954
  }
934
- return `create.doc("${name}", "${base}", ${docGlob})`;
955
+ return `create.doc("${name}", "${dir}", ${docGlob})`;
935
956
  }
936
957
  function meta(name, collection) {
937
958
  const patterns = getGlobPatterns(collection);
938
- const base = getGlobBase(collection);
939
- return `create.meta("${name}", "${base}", ${generateGlob(patterns, {
959
+ const dir = getCollectionDir(collection);
960
+ return `create.meta("${name}", "${dir}", ${generateGlob(patterns, {
940
961
  import: "default",
941
- base,
962
+ base: dir,
942
963
  query: {
943
964
  collection: name
944
965
  }
945
966
  })})`;
946
967
  }
947
968
  function generateGlob(patterns, options2) {
948
- patterns = mapGlobPatterns(patterns);
969
+ patterns = patterns.map(normalizeGlobPath);
949
970
  if (runtime === "node" || runtime === "bun") {
950
971
  return generateGlobImport(patterns, options2);
951
972
  } else {
952
973
  return `import.meta.glob(${JSON.stringify(patterns)}, ${JSON.stringify(
953
974
  {
954
975
  ...options2,
955
- base: import_node_path8.default.relative(outDir, options2.base)
976
+ base: normalizeGlobPath(import_node_path8.default.relative(outDir, options2.base))
956
977
  },
957
978
  null,
958
979
  2
@@ -973,24 +994,29 @@ ${obj}
973
994
  }
974
995
  return lines.join("\n");
975
996
  }
976
- function mapGlobPatterns(patterns) {
977
- return patterns.map(enforceRelative);
978
- }
979
- function enforceRelative(file) {
997
+ function normalizeGlobPath(file) {
998
+ file = slash(file);
980
999
  if (file.startsWith("./")) return file;
981
1000
  if (file.startsWith("/")) return `.${file}`;
982
1001
  return `./${file}`;
983
1002
  }
984
- function getGlobBase(collection) {
985
- let dir = collection.dir;
1003
+ function getCollectionDir(collection) {
1004
+ const dir = collection.dir;
986
1005
  if (Array.isArray(dir)) {
987
1006
  if (dir.length !== 1)
988
1007
  throw new Error(
989
1008
  `[Fumadocs MDX] Vite Plugin doesn't support multiple \`dir\` for a collection at the moment.`
990
1009
  );
991
- dir = dir[0];
1010
+ return dir[0];
1011
+ }
1012
+ return dir;
1013
+ }
1014
+ function slash(path13) {
1015
+ const isExtendedLengthPath = path13.startsWith("\\\\?\\");
1016
+ if (isExtendedLengthPath) {
1017
+ return path13;
992
1018
  }
993
- return enforceRelative(dir);
1019
+ return path13.replaceAll("\\", "/");
994
1020
  }
995
1021
 
996
1022
  // src/core.ts
@@ -1167,7 +1193,9 @@ function createViteCore({
1167
1193
  outDir
1168
1194
  },
1169
1195
  [
1170
- generateIndexFile !== false && vite(typeof generateIndexFile === "object" ? generateIndexFile : {})
1196
+ vite({
1197
+ index: generateIndexFile
1198
+ })
1171
1199
  ]
1172
1200
  );
1173
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
@@ -98,12 +119,12 @@ ${obj}
98
119
  }
99
120
  function doc(name, collection) {
100
121
  const patterns = getGlobPatterns(collection);
101
- const base = getGlobBase(collection);
122
+ const dir = getCollectionDir(collection);
102
123
  const docGlob = generateGlob(patterns, {
103
124
  query: {
104
125
  collection: name
105
126
  },
106
- base
127
+ base: dir
107
128
  });
108
129
  if (collection.async) {
109
130
  const headBlob = generateGlob(patterns, {
@@ -112,32 +133,32 @@ ${obj}
112
133
  collection: name
113
134
  },
114
135
  import: "frontmatter",
115
- base
136
+ base: dir
116
137
  });
117
- return `create.docLazy("${name}", "${base}", ${headBlob}, ${docGlob})`;
138
+ return `create.docLazy("${name}", "${dir}", ${headBlob}, ${docGlob})`;
118
139
  }
119
- return `create.doc("${name}", "${base}", ${docGlob})`;
140
+ return `create.doc("${name}", "${dir}", ${docGlob})`;
120
141
  }
121
142
  function meta(name, collection) {
122
143
  const patterns = getGlobPatterns(collection);
123
- const base = getGlobBase(collection);
124
- return `create.meta("${name}", "${base}", ${generateGlob(patterns, {
144
+ const dir = getCollectionDir(collection);
145
+ return `create.meta("${name}", "${dir}", ${generateGlob(patterns, {
125
146
  import: "default",
126
- base,
147
+ base: dir,
127
148
  query: {
128
149
  collection: name
129
150
  }
130
151
  })})`;
131
152
  }
132
153
  function generateGlob(patterns, options2) {
133
- patterns = mapGlobPatterns(patterns);
154
+ patterns = patterns.map(normalizeGlobPath);
134
155
  if (runtime === "node" || runtime === "bun") {
135
156
  return generateGlobImport(patterns, options2);
136
157
  } else {
137
158
  return `import.meta.glob(${JSON.stringify(patterns)}, ${JSON.stringify(
138
159
  {
139
160
  ...options2,
140
- base: path2.relative(outDir, options2.base)
161
+ base: normalizeGlobPath(path2.relative(outDir, options2.base))
141
162
  },
142
163
  null,
143
164
  2
@@ -158,24 +179,29 @@ ${obj}
158
179
  }
159
180
  return lines.join("\n");
160
181
  }
161
- function mapGlobPatterns(patterns) {
162
- return patterns.map(enforceRelative);
163
- }
164
- function enforceRelative(file) {
182
+ function normalizeGlobPath(file) {
183
+ file = slash(file);
165
184
  if (file.startsWith("./")) return file;
166
185
  if (file.startsWith("/")) return `.${file}`;
167
186
  return `./${file}`;
168
187
  }
169
- function getGlobBase(collection) {
170
- let dir = collection.dir;
188
+ function getCollectionDir(collection) {
189
+ const dir = collection.dir;
171
190
  if (Array.isArray(dir)) {
172
191
  if (dir.length !== 1)
173
192
  throw new Error(
174
193
  `[Fumadocs MDX] Vite Plugin doesn't support multiple \`dir\` for a collection at the moment.`
175
194
  );
176
- dir = dir[0];
195
+ return dir[0];
196
+ }
197
+ return dir;
198
+ }
199
+ function slash(path4) {
200
+ const isExtendedLengthPath = path4.startsWith("\\\\?\\");
201
+ if (isExtendedLengthPath) {
202
+ return path4;
177
203
  }
178
- return enforceRelative(dir);
204
+ return path4.replaceAll("\\", "/");
179
205
  }
180
206
 
181
207
  // src/vite/index.ts
@@ -279,7 +305,9 @@ function createViteCore({
279
305
  outDir
280
306
  },
281
307
  [
282
- generateIndexFile !== false && vite(typeof generateIndexFile === "object" ? generateIndexFile : {})
308
+ vite({
309
+ index: generateIndexFile
310
+ })
283
311
  ]
284
312
  );
285
313
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-mdx",
3
- "version": "13.0.1",
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": {