fumadocs-mdx 15.0.1 → 15.0.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.
- package/dist/{adapter-DK590Mfe.mjs → adapter-BketAUOZ.js} +2 -2
- package/dist/{bin.mjs → bin.js} +2 -3
- package/dist/{build-C6DvTt9a.mjs → build-DPafU2lu.js} +1 -1
- package/dist/{build-mdx-YbGh3ny7.mjs → build-mdx-DeW1GoVI.js} +2 -2
- package/dist/bun/{index.d.mts → index.d.ts} +1 -1
- package/dist/bun/{index.mjs → index.js} +5 -5
- package/dist/config/{index.d.mts → index.d.ts} +1 -1
- package/dist/config/{index.mjs → index.js} +2 -2
- package/dist/{core-xVRMIMfX.d.mts → core-BOs29Mj7.d.ts} +1 -1
- package/dist/{core-CA-_77fa.mjs → core-Wd5WdPN4.js} +1 -1
- package/dist/{index-file-Bay9epxY.mjs → index-file-CyGG-8n8.js} +5 -6
- package/dist/{index.d.mts → index.d.ts} +2 -2
- package/dist/index.js +0 -0
- package/dist/{load-from-file-f1KkukxD.mjs → load-from-file--MfW8a2Z.js} +4 -2
- package/dist/{mdx-BGXFjg1w.mjs → mdx-swV6_ZR5.js} +2 -2
- package/dist/{meta-Bq8wKcQi.mjs → meta-B6guI74I.js} +1 -1
- package/dist/next/{index.d.mts → index.d.ts} +1 -1
- package/dist/next/{index.mjs → index.js} +4 -4
- package/dist/node/{_loader.d.mts → _loader.d.ts} +1 -1
- package/dist/node/{_loader.mjs → _loader.js} +4 -4
- package/dist/node/{index.d.mts → index.d.ts} +1 -1
- package/dist/node/{loader.mjs → loader.js} +4 -4
- package/dist/plugins/{index-file.d.mts → index-file.d.ts} +1 -1
- package/dist/plugins/index-file.js +2 -0
- package/dist/plugins/{json-schema.d.mts → json-schema.d.ts} +1 -1
- package/dist/plugins/{last-modified.d.mts → last-modified.d.ts} +1 -1
- package/dist/plugins/{last-modified.mjs → last-modified.js} +1 -1
- package/dist/rolldown-runtime-CiIaOW0V.js +13 -0
- package/dist/runtime/{browser.d.mts → browser.d.ts} +3 -3
- package/dist/runtime/{dynamic.d.mts → dynamic.d.ts} +2 -2
- package/dist/runtime/{dynamic.mjs → dynamic.js} +4 -4
- package/dist/runtime/{server.d.mts → server.d.ts} +1 -1
- package/dist/runtime/{types.d.mts → types.d.ts} +1 -1
- package/dist/runtime/types.js +0 -0
- package/dist/vite/{index.d.mts → index.d.ts} +1 -1
- package/dist/vite/index.js +80 -0
- package/dist/webpack/{mdx.d.mts → mdx.d.ts} +1 -1
- package/dist/webpack/{mdx.mjs → mdx.js} +3 -3
- package/dist/webpack/{meta.d.mts → meta.d.ts} +1 -1
- package/dist/webpack/{meta.mjs → meta.js} +3 -3
- package/dist/{webpack-FvZlu_1G.mjs → webpack-CBlMzMlJ.js} +1 -1
- package/package.json +21 -24
- package/dist/index.mjs +0 -1
- package/dist/load-from-file-D0UVwCFc.mjs +0 -2
- package/dist/plugins/index-file.mjs +0 -2
- package/dist/runtime/types.mjs +0 -1
- package/dist/vite/index.mjs +0 -330
- /package/dist/{bin.d.mts → bin.d.ts} +0 -0
- /package/dist/{build-mdx-D96HeA9c.d.mts → build-mdx-YyRh-ZGV.d.ts} +0 -0
- /package/dist/{codegen-CWSx5M_o.mjs → codegen-B8EhLmbU.js} +0 -0
- /package/dist/{index-BbjEFpj3.d.mts → index-BIbaPT3v.d.ts} +0 -0
- /package/dist/{loaders-Bx2E0Ksu.mjs → loaders-ezSYYkT7.js} +0 -0
- /package/dist/node/{index.mjs → index.js} +0 -0
- /package/dist/node/{loader.d.mts → loader.d.ts} +0 -0
- /package/dist/plugins/{json-schema.mjs → json-schema.js} +0 -0
- /package/dist/{preset-2RxDTDuQ.mjs → preset-B0H8HalE.js} +0 -0
- /package/dist/{remark-include-D7W3bva3.mjs → remark-include-VDoXZSBN.js} +0 -0
- /package/dist/runtime/{browser.mjs → browser.js} +0 -0
- /package/dist/runtime/{server.mjs → server.js} +0 -0
- /package/dist/{types-DzvjnGdV.d.mts → types-hAduruLB.d.ts} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as ValidationError } from "./core-
|
|
2
|
-
import { t as loadConfig } from "./load-from-file
|
|
1
|
+
import { r as ValidationError } from "./core-Wd5WdPN4.js";
|
|
2
|
+
import { t as loadConfig } from "./load-from-file--MfW8a2Z.js";
|
|
3
3
|
import { readFileSync } from "node:fs";
|
|
4
4
|
import fs from "node:fs/promises";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
package/dist/{bin.mjs → bin.js}
RENAMED
|
@@ -4,13 +4,13 @@ import { existsSync } from "node:fs";
|
|
|
4
4
|
async function start() {
|
|
5
5
|
const [configPath, outDir] = process.argv.slice(2);
|
|
6
6
|
if (existsSync("next.config.js") || existsSync("next.config.mjs") || existsSync("next.config.mts") || existsSync("next.config.ts")) {
|
|
7
|
-
const { postInstall } = await import("./next/index.
|
|
7
|
+
const { postInstall } = await import("./next/index.js");
|
|
8
8
|
await postInstall({
|
|
9
9
|
configPath,
|
|
10
10
|
outDir
|
|
11
11
|
});
|
|
12
12
|
} else {
|
|
13
|
-
const { postInstall } = await import("./vite/index.
|
|
13
|
+
const { postInstall } = await import("./vite/index.js");
|
|
14
14
|
await postInstall({
|
|
15
15
|
configPath,
|
|
16
16
|
outDir
|
|
@@ -19,4 +19,3 @@ async function start() {
|
|
|
19
19
|
}
|
|
20
20
|
start();
|
|
21
21
|
//#endregion
|
|
22
|
-
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-CiIaOW0V.js";
|
|
2
|
+
import { n as flattenNode, t as remarkInclude } from "./remark-include-VDoXZSBN.js";
|
|
3
3
|
import { visit } from "unist-util-visit";
|
|
4
4
|
import { VFile } from "vfile";
|
|
5
5
|
import { createProcessor } from "@mdx-js/mdx";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as createMdxLoader } from "../mdx-
|
|
2
|
-
import { t as buildConfig } from "../build-
|
|
3
|
-
import { n as createCore, t as _Defaults } from "../core-
|
|
4
|
-
import { a as createIntegratedConfigLoader, t as toBun } from "../adapter-
|
|
5
|
-
import { t as createMetaLoader } from "../meta-
|
|
1
|
+
import { t as createMdxLoader } from "../mdx-swV6_ZR5.js";
|
|
2
|
+
import { t as buildConfig } from "../build-DPafU2lu.js";
|
|
3
|
+
import { n as createCore, t as _Defaults } from "../core-Wd5WdPN4.js";
|
|
4
|
+
import { a as createIntegratedConfigLoader, t as toBun } from "../adapter-BketAUOZ.js";
|
|
5
|
+
import { t as createMetaLoader } from "../meta-B6guI74I.js";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
|
7
7
|
//#region src/bun/index.ts
|
|
8
8
|
function createMdxPlugin(options = {}) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as DocCollection, B as MDXPresetOptions, D as AnyCollection, E as remarkInclude, F as defineConfig, I as defineDocs, M as GlobalConfig, N as MetaCollection, O as BaseCollection, P as defineCollections, R as PostprocessOptions, T as metaSchema, V as applyMdxPreset, j as DocsCollection, k as CollectionSchema, w as frontmatterSchema, z as DefaultMDXOptions } from "../core-
|
|
1
|
+
import { A as DocCollection, B as MDXPresetOptions, D as AnyCollection, E as remarkInclude, F as defineConfig, I as defineDocs, M as GlobalConfig, N as MetaCollection, O as BaseCollection, P as defineCollections, R as PostprocessOptions, T as metaSchema, V as applyMdxPreset, j as DocsCollection, k as CollectionSchema, w as frontmatterSchema, z as DefaultMDXOptions } from "../core-BOs29Mj7.js";
|
|
2
2
|
export { AnyCollection, BaseCollection, CollectionSchema, DefaultMDXOptions, DocCollection, DocsCollection, GlobalConfig, MDXPresetOptions, MetaCollection, PostprocessOptions, applyMdxPreset, defineCollections, defineConfig, defineDocs, frontmatterSchema, metaSchema, remarkInclude };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as applyMdxPreset } from "../preset-
|
|
2
|
-
import { t as remarkInclude } from "../remark-include-
|
|
1
|
+
import { t as applyMdxPreset } from "../preset-B0H8HalE.js";
|
|
2
|
+
import { t as remarkInclude } from "../remark-include-VDoXZSBN.js";
|
|
3
3
|
import { metaSchema as metaSchema$1, pageSchema } from "fumadocs-core/source/schema";
|
|
4
4
|
//#region src/config/define.ts
|
|
5
5
|
function defineCollections(options) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as MetaMethods, i as InternalTypeConfig, n as DocMethods, t as DocData } from "./types-
|
|
1
|
+
import { a as MetaMethods, i as InternalTypeConfig, n as DocMethods, t as DocData } from "./types-hAduruLB.js";
|
|
2
2
|
import * as _$zod from "zod";
|
|
3
3
|
import * as _$fumadocs_core_source_schema0 from "fumadocs-core/source/schema";
|
|
4
4
|
import { metaSchema, pageSchema } from "fumadocs-core/source/schema";
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { n as ident, r as slash, t as createCodegen } from "./codegen-
|
|
1
|
+
import { n as ident, r as slash, t as createCodegen } from "./codegen-B8EhLmbU.js";
|
|
2
2
|
import { frontmatter } from "fumadocs-core/content/md/frontmatter";
|
|
3
3
|
import fs from "node:fs/promises";
|
|
4
4
|
import path from "node:path";
|
|
5
|
+
import { createHash } from "node:crypto";
|
|
5
6
|
import { glob } from "tinyglobby";
|
|
6
|
-
import path$1 from "path";
|
|
7
|
-
import { createHash } from "crypto";
|
|
8
7
|
//#region src/utils/fs-cache.ts
|
|
9
8
|
const map = /* @__PURE__ */ new Map();
|
|
10
9
|
function createFSCache() {
|
|
@@ -154,7 +153,7 @@ async function generateDynamicIndexFile(ctx) {
|
|
|
154
153
|
outDir
|
|
155
154
|
};
|
|
156
155
|
async function generateCollectionObjectEntry(collection, absolutePath) {
|
|
157
|
-
const fullPath = path
|
|
156
|
+
const fullPath = path.relative(process.cwd(), absolutePath);
|
|
158
157
|
const content = await indexFileCache.read(fullPath).catch(() => "");
|
|
159
158
|
const parsed = frontmatter(content);
|
|
160
159
|
const data = await core.transformFrontmatter({
|
|
@@ -167,7 +166,7 @@ async function generateDynamicIndexFile(ctx) {
|
|
|
167
166
|
for (const [k, v] of Object.entries({
|
|
168
167
|
info: {
|
|
169
168
|
fullPath,
|
|
170
|
-
path: path
|
|
169
|
+
path: path.relative(collection.dir, absolutePath)
|
|
171
170
|
},
|
|
172
171
|
data,
|
|
173
172
|
hash
|
|
@@ -223,7 +222,7 @@ async function generateBrowserIndexFile(ctx) {
|
|
|
223
222
|
codegen.lines.push("};", "export default browserCollections;");
|
|
224
223
|
}
|
|
225
224
|
function getBase(collection) {
|
|
226
|
-
return slash(path
|
|
225
|
+
return slash(path.relative(process.cwd(), collection.dir));
|
|
227
226
|
}
|
|
228
227
|
function generateDocCollectionFrontmatterGlob({ codegen, workspace }, collection, eager = false) {
|
|
229
228
|
return codegen.generateGlobImport(collection.patterns, {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { L as ExtractedReference, a as EmitOptions, c as PluginContext, d as TransformOptions, i as EmitEntry, l as PluginOption, n as Core, o as EmitOutput, r as CoreOptions, s as Plugin, t as CompilationContext, u as ServerContext } from "./core-
|
|
2
|
-
import { t as CompiledMDXProperties } from "./build-mdx-
|
|
1
|
+
import { L as ExtractedReference, a as EmitOptions, c as PluginContext, d as TransformOptions, i as EmitEntry, l as PluginOption, n as Core, o as EmitOutput, r as CoreOptions, s as Plugin, t as CompilationContext, u as ServerContext } from "./core-BOs29Mj7.js";
|
|
2
|
+
import { t as CompiledMDXProperties } from "./build-mdx-YyRh-ZGV.js";
|
|
3
3
|
export { type CompilationContext, type CompiledMDXProperties, type Core, type CoreOptions, type EmitEntry, type EmitOptions, type EmitOutput, type ExtractedReference, type Plugin, type PluginContext, type PluginOption, type ServerContext, type TransformOptions };
|
package/dist/index.js
ADDED
|
File without changes
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { t as
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-CiIaOW0V.js";
|
|
2
|
+
import { t as buildConfig } from "./build-DPafU2lu.js";
|
|
2
3
|
import { pathToFileURL } from "node:url";
|
|
3
4
|
//#region src/config/load-from-file.ts
|
|
5
|
+
var load_from_file_exports = /* @__PURE__ */ __exportAll({ loadConfig: () => loadConfig });
|
|
4
6
|
async function compileConfig(core) {
|
|
5
7
|
const { build } = await import("esbuild");
|
|
6
8
|
const { configPath, outDir } = core.getOptions();
|
|
@@ -32,4 +34,4 @@ async function loadConfig(core, build = false) {
|
|
|
32
34
|
return buildConfig(await import(url.href));
|
|
33
35
|
}
|
|
34
36
|
//#endregion
|
|
35
|
-
export { loadConfig as t };
|
|
37
|
+
export { load_from_file_exports as n, loadConfig as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as mdxLoaderGlob } from "./loaders-
|
|
1
|
+
import { t as mdxLoaderGlob } from "./loaders-ezSYYkT7.js";
|
|
2
2
|
import { frontmatter } from "fumadocs-core/content/md/frontmatter";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import fs from "node:fs/promises";
|
|
@@ -58,7 +58,7 @@ function createMdxLoader({ getCore }) {
|
|
|
58
58
|
code: `export const frontmatter = ${JSON.stringify(matter.data)}`,
|
|
59
59
|
map: null
|
|
60
60
|
};
|
|
61
|
-
const { buildMDX } = await import("./build-mdx-
|
|
61
|
+
const { buildMDX } = await import("./build-mdx-DeW1GoVI.js").then((n) => n.n);
|
|
62
62
|
const compiled = await buildMDX(core, docCollection, {
|
|
63
63
|
isDevelopment,
|
|
64
64
|
source: "\n".repeat(countLines(matter.matter)) + matter.content,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as metaLoaderGlob, t as mdxLoaderGlob } from "../loaders-
|
|
2
|
-
import { n as createCore, t as _Defaults } from "../core-
|
|
3
|
-
import { t as loadConfig } from "../load-from-file
|
|
4
|
-
import { t as indexFile } from "../index-file-
|
|
1
|
+
import { n as metaLoaderGlob, t as mdxLoaderGlob } from "../loaders-ezSYYkT7.js";
|
|
2
|
+
import { n as createCore, t as _Defaults } from "../core-Wd5WdPN4.js";
|
|
3
|
+
import { t as loadConfig } from "../load-from-file--MfW8a2Z.js";
|
|
4
|
+
import { t as indexFile } from "../index-file-CyGG-8n8.js";
|
|
5
5
|
import * as path$1 from "node:path";
|
|
6
6
|
//#region src/next/index.ts
|
|
7
7
|
const defaultPageExtensions = [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as createMdxLoader } from "../mdx-
|
|
2
|
-
import { n as createCore, t as _Defaults } from "../core-
|
|
3
|
-
import { n as toNode, o as createStandaloneConfigLoader } from "../adapter-
|
|
4
|
-
import { t as createMetaLoader } from "../meta-
|
|
1
|
+
import { t as createMdxLoader } from "../mdx-swV6_ZR5.js";
|
|
2
|
+
import { n as createCore, t as _Defaults } from "../core-Wd5WdPN4.js";
|
|
3
|
+
import { n as toNode, o as createStandaloneConfigLoader } from "../adapter-BketAUOZ.js";
|
|
4
|
+
import { t as createMetaLoader } from "../meta-B6guI74I.js";
|
|
5
5
|
//#region src/node/_loader.ts
|
|
6
6
|
let cachedLoaders;
|
|
7
7
|
const initialize = (options) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as createMdxLoader } from "../mdx-
|
|
2
|
-
import { n as createCore, t as _Defaults } from "../core-
|
|
3
|
-
import { n as toNode, o as createStandaloneConfigLoader } from "../adapter-
|
|
4
|
-
import { t as createMetaLoader } from "../meta-
|
|
1
|
+
import { t as createMdxLoader } from "../mdx-swV6_ZR5.js";
|
|
2
|
+
import { n as createCore, t as _Defaults } from "../core-Wd5WdPN4.js";
|
|
3
|
+
import { n as toNode, o as createStandaloneConfigLoader } from "../adapter-BketAUOZ.js";
|
|
4
|
+
import { t as createMetaLoader } from "../meta-B6guI74I.js";
|
|
5
5
|
//#region src/node/loader.ts
|
|
6
6
|
const configLoader = createStandaloneConfigLoader({
|
|
7
7
|
core: createCore({
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { f as IndexFilePlugin, m as indexFile, p as IndexFilePluginOptions } from "../core-
|
|
1
|
+
import { f as IndexFilePlugin, m as indexFile, p as IndexFilePluginOptions } from "../core-BOs29Mj7.js";
|
|
2
2
|
export { IndexFilePlugin, IndexFilePluginOptions, indexFile as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
+
return target;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { __exportAll as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as DocCollection, j as DocsCollection } from "../core-
|
|
2
|
-
import { i as InternalTypeConfig } from "../types-
|
|
3
|
-
import { t as CompiledMDXProperties } from "../build-mdx-
|
|
1
|
+
import { A as DocCollection, j as DocsCollection } from "../core-BOs29Mj7.js";
|
|
2
|
+
import { i as InternalTypeConfig } from "../types-hAduruLB.js";
|
|
3
|
+
import { t as CompiledMDXProperties } from "../build-mdx-YyRh-ZGV.js";
|
|
4
4
|
import { FC, ReactNode } from "react";
|
|
5
5
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
6
6
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as DocCollection, g as AsyncDocsCollectionEntry, h as AsyncDocCollectionEntry, j as DocsCollection, r as CoreOptions, x as ServerOptions } from "../core-
|
|
2
|
-
import { i as InternalTypeConfig, r as FileInfo } from "../types-
|
|
1
|
+
import { A as DocCollection, g as AsyncDocsCollectionEntry, h as AsyncDocCollectionEntry, j as DocsCollection, r as CoreOptions, x as ServerOptions } from "../core-BOs29Mj7.js";
|
|
2
|
+
import { i as InternalTypeConfig, r as FileInfo } from "../types-hAduruLB.js";
|
|
3
3
|
import * as _$_standard_schema_spec0 from "@standard-schema/spec";
|
|
4
4
|
import * as _$fumadocs_core_source0 from "fumadocs-core/source";
|
|
5
5
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as buildConfig } from "../build-
|
|
2
|
-
import { n as createCore } from "../core-
|
|
3
|
-
import { t as buildMDX } from "../build-mdx-
|
|
4
|
-
import { server } from "./server.
|
|
1
|
+
import { t as buildConfig } from "../build-DPafU2lu.js";
|
|
2
|
+
import { n as createCore } from "../core-Wd5WdPN4.js";
|
|
3
|
+
import { t as buildMDX } from "../build-mdx-DeW1GoVI.js";
|
|
4
|
+
import { server } from "./server.js";
|
|
5
5
|
import { frontmatter } from "fumadocs-core/content/md/frontmatter";
|
|
6
6
|
import fs from "node:fs/promises";
|
|
7
7
|
import { pathToFileURL } from "node:url";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as toFumadocsSource, S as server, _ as DocCollectionEntry, b as ServerCreate, g as AsyncDocsCollectionEntry, h as AsyncDocCollectionEntry, v as DocsCollectionEntry, x as ServerOptions, y as MetaCollectionEntry } from "../core-
|
|
1
|
+
import { C as toFumadocsSource, S as server, _ as DocCollectionEntry, b as ServerCreate, g as AsyncDocsCollectionEntry, h as AsyncDocCollectionEntry, v as DocsCollectionEntry, x as ServerOptions, y as MetaCollectionEntry } from "../core-BOs29Mj7.js";
|
|
2
2
|
export { AsyncDocCollectionEntry, AsyncDocsCollectionEntry, DocCollectionEntry, DocsCollectionEntry, MetaCollectionEntry, ServerCreate, ServerOptions, server, toFumadocsSource };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as MetaMethods, i as InternalTypeConfig, n as DocMethods, r as FileInfo, t as DocData } from "../types-
|
|
1
|
+
import { a as MetaMethods, i as InternalTypeConfig, n as DocMethods, r as FileInfo, t as DocData } from "../types-hAduruLB.js";
|
|
2
2
|
export { DocData, DocMethods, FileInfo, InternalTypeConfig, MetaMethods };
|
|
File without changes
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { t as createMdxLoader } from "../mdx-swV6_ZR5.js";
|
|
2
|
+
import { t as buildConfig } from "../build-DPafU2lu.js";
|
|
3
|
+
import { n as createCore, r as ValidationError, t as _Defaults } from "../core-Wd5WdPN4.js";
|
|
4
|
+
import { a as createIntegratedConfigLoader, r as toVite } from "../adapter-BketAUOZ.js";
|
|
5
|
+
import { t as createMetaLoader } from "../meta-B6guI74I.js";
|
|
6
|
+
import { t as indexFile } from "../index-file-CyGG-8n8.js";
|
|
7
|
+
import { runnerImport } from "vite";
|
|
8
|
+
import { crawlFrameworkPkgs } from "vitefu";
|
|
9
|
+
//#region src/vite/index.ts
|
|
10
|
+
async function mdx(_config, pluginOptions = {}) {
|
|
11
|
+
const options = applyDefaults(pluginOptions);
|
|
12
|
+
const core = createViteCore(options);
|
|
13
|
+
const config = await _config ?? (await runnerImport(options.configPath)).module;
|
|
14
|
+
await core.init({ config: buildConfig(config) });
|
|
15
|
+
const configLoader = createIntegratedConfigLoader(core);
|
|
16
|
+
const mdxLoader = toVite(createMdxLoader(configLoader));
|
|
17
|
+
const metaLoader = toVite(createMetaLoader(configLoader, { json: "json" }));
|
|
18
|
+
return {
|
|
19
|
+
name: "fumadocs-mdx",
|
|
20
|
+
enforce: "pre",
|
|
21
|
+
async config(config, { command }) {
|
|
22
|
+
if (!options.updateViteConfig) return config;
|
|
23
|
+
const out = await crawlFrameworkPkgs({
|
|
24
|
+
root: process.cwd(),
|
|
25
|
+
isBuild: command === "build",
|
|
26
|
+
isFrameworkPkgByName(pkgName) {
|
|
27
|
+
if (pkgName.startsWith("@fumapress/") || pkgName.startsWith("@fumadocs/") || pkgName.startsWith("fumadocs-") || pkgName === "fumapress") return true;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
ssr: { noExternal: out.ssr.noExternal },
|
|
32
|
+
optimizeDeps: out.optimizeDeps
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
async buildStart() {
|
|
36
|
+
await core.emit({ write: true });
|
|
37
|
+
},
|
|
38
|
+
async configureServer(server) {
|
|
39
|
+
await core.initServer({ watcher: server.watcher });
|
|
40
|
+
},
|
|
41
|
+
async transform(value, id) {
|
|
42
|
+
if (id.includes("virtual:vite-rsc")) return null;
|
|
43
|
+
try {
|
|
44
|
+
if (metaLoader.filter(id)) return await metaLoader.transform.call(this, value, id);
|
|
45
|
+
if (mdxLoader.filter(id)) return await mdxLoader.transform.call(this, value, id);
|
|
46
|
+
} catch (e) {
|
|
47
|
+
if (e instanceof ValidationError) throw new Error(await e.toStringFormatted(), { cause: e });
|
|
48
|
+
throw e;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
async function postInstall(pluginOptions = {}) {
|
|
54
|
+
const { loadConfig } = await import("../load-from-file--MfW8a2Z.js").then((n) => n.n);
|
|
55
|
+
const core = createViteCore(applyDefaults(pluginOptions));
|
|
56
|
+
await core.init({ config: loadConfig(core, true) });
|
|
57
|
+
await core.emit({ write: true });
|
|
58
|
+
}
|
|
59
|
+
function createViteCore({ index, configPath, outDir }) {
|
|
60
|
+
if (index === true) index = {};
|
|
61
|
+
return createCore({
|
|
62
|
+
environment: "vite",
|
|
63
|
+
configPath,
|
|
64
|
+
outDir,
|
|
65
|
+
plugins: [index && indexFile({
|
|
66
|
+
...index,
|
|
67
|
+
target: index.target ?? "vite"
|
|
68
|
+
})]
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function applyDefaults(options) {
|
|
72
|
+
return {
|
|
73
|
+
updateViteConfig: options.updateViteConfig ?? true,
|
|
74
|
+
index: options.index ?? true,
|
|
75
|
+
configPath: options.configPath ?? _Defaults.configPath,
|
|
76
|
+
outDir: options.outDir ?? _Defaults.outDir
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
export { mdx as default, postInstall };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as createMdxLoader } from "../mdx-
|
|
2
|
-
import { i as toWebpack, o as createStandaloneConfigLoader } from "../adapter-
|
|
3
|
-
import { t as getCore } from "../webpack-
|
|
1
|
+
import { t as createMdxLoader } from "../mdx-swV6_ZR5.js";
|
|
2
|
+
import { i as toWebpack, o as createStandaloneConfigLoader } from "../adapter-BketAUOZ.js";
|
|
3
|
+
import { t as getCore } from "../webpack-CBlMzMlJ.js";
|
|
4
4
|
//#region src/webpack/mdx.ts
|
|
5
5
|
let instance;
|
|
6
6
|
const loader = function loader(source) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as toWebpack, o as createStandaloneConfigLoader } from "../adapter-
|
|
2
|
-
import { t as createMetaLoader } from "../meta-
|
|
3
|
-
import { t as getCore } from "../webpack-
|
|
1
|
+
import { i as toWebpack, o as createStandaloneConfigLoader } from "../adapter-BketAUOZ.js";
|
|
2
|
+
import { t as createMetaLoader } from "../meta-B6guI74I.js";
|
|
3
|
+
import { t as getCore } from "../webpack-CBlMzMlJ.js";
|
|
4
4
|
//#region src/webpack/meta.ts
|
|
5
5
|
let instance;
|
|
6
6
|
const loader = function(source) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fumadocs-mdx",
|
|
3
|
-
"version": "15.0.
|
|
3
|
+
"version": "15.0.2",
|
|
4
4
|
"description": "The built-in source for Fumadocs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Docs",
|
|
@@ -11,31 +11,31 @@
|
|
|
11
11
|
"author": "Fuma Nama",
|
|
12
12
|
"repository": "github:fuma-nama/fumadocs",
|
|
13
13
|
"bin": {
|
|
14
|
-
"fumadocs-mdx": "./dist/bin.
|
|
14
|
+
"fumadocs-mdx": "./dist/bin.js"
|
|
15
15
|
},
|
|
16
16
|
"files": [
|
|
17
17
|
"dist"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
20
|
"exports": {
|
|
21
|
-
".": "./dist/index.
|
|
22
|
-
"./bin": "./dist/bin.
|
|
23
|
-
"./bun": "./dist/bun/index.
|
|
24
|
-
"./config": "./dist/config/index.
|
|
25
|
-
"./next": "./dist/next/index.
|
|
26
|
-
"./node": "./dist/node/index.
|
|
27
|
-
"./node/_loader": "./dist/node/_loader.
|
|
28
|
-
"./node/loader": "./dist/node/loader.
|
|
29
|
-
"./plugins/index-file": "./dist/plugins/index-file.
|
|
30
|
-
"./plugins/json-schema": "./dist/plugins/json-schema.
|
|
31
|
-
"./plugins/last-modified": "./dist/plugins/last-modified.
|
|
32
|
-
"./runtime/browser": "./dist/runtime/browser.
|
|
33
|
-
"./runtime/dynamic": "./dist/runtime/dynamic.
|
|
34
|
-
"./runtime/server": "./dist/runtime/server.
|
|
35
|
-
"./runtime/types": "./dist/runtime/types.
|
|
36
|
-
"./vite": "./dist/vite/index.
|
|
37
|
-
"./webpack/mdx": "./dist/webpack/mdx.
|
|
38
|
-
"./webpack/meta": "./dist/webpack/meta.
|
|
21
|
+
".": "./dist/index.js",
|
|
22
|
+
"./bin": "./dist/bin.js",
|
|
23
|
+
"./bun": "./dist/bun/index.js",
|
|
24
|
+
"./config": "./dist/config/index.js",
|
|
25
|
+
"./next": "./dist/next/index.js",
|
|
26
|
+
"./node": "./dist/node/index.js",
|
|
27
|
+
"./node/_loader": "./dist/node/_loader.js",
|
|
28
|
+
"./node/loader": "./dist/node/loader.js",
|
|
29
|
+
"./plugins/index-file": "./dist/plugins/index-file.js",
|
|
30
|
+
"./plugins/json-schema": "./dist/plugins/json-schema.js",
|
|
31
|
+
"./plugins/last-modified": "./dist/plugins/last-modified.js",
|
|
32
|
+
"./runtime/browser": "./dist/runtime/browser.js",
|
|
33
|
+
"./runtime/dynamic": "./dist/runtime/dynamic.js",
|
|
34
|
+
"./runtime/server": "./dist/runtime/server.js",
|
|
35
|
+
"./runtime/types": "./dist/runtime/types.js",
|
|
36
|
+
"./vite": "./dist/vite/index.js",
|
|
37
|
+
"./webpack/mdx": "./dist/webpack/mdx.js",
|
|
38
|
+
"./webpack/meta": "./dist/webpack/meta.js",
|
|
39
39
|
"./package.json": "./package.json"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
"unist-util-remove-position": "^5.0.0",
|
|
58
58
|
"unist-util-visit": "^5.1.0",
|
|
59
59
|
"vfile": "^6.0.3",
|
|
60
|
+
"vitefu": "^1.1.3",
|
|
60
61
|
"zod": "^4.4.3"
|
|
61
62
|
},
|
|
62
63
|
"devDependencies": {
|
|
@@ -76,7 +77,6 @@
|
|
|
76
77
|
"rolldown": "1.0.0",
|
|
77
78
|
"tsdown": "0.22.0",
|
|
78
79
|
"vite": "^8.0.11",
|
|
79
|
-
"vitefu": "^1.1.3",
|
|
80
80
|
"webpack": "^5.106.2",
|
|
81
81
|
"tsconfig": "0.0.0",
|
|
82
82
|
"fumadocs-core": "16.8.9"
|
|
@@ -114,9 +114,6 @@
|
|
|
114
114
|
"optional": true
|
|
115
115
|
}
|
|
116
116
|
},
|
|
117
|
-
"inlinedDependencies": {
|
|
118
|
-
"vitefu": "1.1.3"
|
|
119
|
-
},
|
|
120
117
|
"scripts": {
|
|
121
118
|
"build": "tsdown",
|
|
122
119
|
"clean": "rimraf dist",
|
package/dist/index.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/runtime/types.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/vite/index.mjs
DELETED
|
@@ -1,330 +0,0 @@
|
|
|
1
|
-
import { t as createMdxLoader } from "../mdx-BGXFjg1w.mjs";
|
|
2
|
-
import { t as buildConfig } from "../build-C6DvTt9a.mjs";
|
|
3
|
-
import { n as createCore, r as ValidationError, t as _Defaults } from "../core-CA-_77fa.mjs";
|
|
4
|
-
import { a as createIntegratedConfigLoader, r as toVite } from "../adapter-DK590Mfe.mjs";
|
|
5
|
-
import { t as createMetaLoader } from "../meta-Bq8wKcQi.mjs";
|
|
6
|
-
import { t as indexFile } from "../index-file-Bay9epxY.mjs";
|
|
7
|
-
import { createRequire } from "node:module";
|
|
8
|
-
import fsSync from "node:fs";
|
|
9
|
-
import fs from "node:fs/promises";
|
|
10
|
-
import path from "node:path";
|
|
11
|
-
import { runnerImport } from "vite";
|
|
12
|
-
//#region \0rolldown/runtime.js
|
|
13
|
-
var __defProp = Object.defineProperty;
|
|
14
|
-
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
15
|
-
var __exportAll = (all, no_symbols) => {
|
|
16
|
-
let target = {};
|
|
17
|
-
for (var name in all) __defProp(target, name, {
|
|
18
|
-
get: all[name],
|
|
19
|
-
enumerable: true
|
|
20
|
-
});
|
|
21
|
-
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
22
|
-
return target;
|
|
23
|
-
};
|
|
24
|
-
//#endregion
|
|
25
|
-
//#region ../../node_modules/.pnpm/vitefu@1.1.3_vite@8.0.11_@types+node@25.6.2_esbuild@0.28.0_jiti@2.7.0_terser@5.47.1_tsx@4.21.0_yaml@2.8.4_/node_modules/vitefu/src/index.js
|
|
26
|
-
var import_sync = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
27
|
-
/** @type {import('./index.d.ts').isDepIncluded} */
|
|
28
|
-
function isDepIncluded(dep, optimizeDepsInclude) {
|
|
29
|
-
return optimizeDepsInclude.some((id) => parseIncludeStr(id) === dep);
|
|
30
|
-
}
|
|
31
|
-
/** @type {import('./index.d.ts').isDepExcluded} */
|
|
32
|
-
function isDepExcluded(dep, optimizeDepsExclude) {
|
|
33
|
-
dep = parseIncludeStr(dep);
|
|
34
|
-
return optimizeDepsExclude.some((id) => id === dep || dep.startsWith(`${id}/`));
|
|
35
|
-
}
|
|
36
|
-
/** @type {import('./index.d.ts').isDepNoExternaled} */
|
|
37
|
-
function isDepNoExternaled(dep, ssrNoExternal) {
|
|
38
|
-
if (ssrNoExternal === true) return true;
|
|
39
|
-
else return isMatch(dep, ssrNoExternal);
|
|
40
|
-
}
|
|
41
|
-
/** @type {import('./index.d.ts').isDepExternaled} */
|
|
42
|
-
function isDepExternaled(dep, ssrExternal) {
|
|
43
|
-
if (ssrExternal === true) return false;
|
|
44
|
-
else return ssrExternal.includes(dep);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* @param {string} raw could be "foo" or "foo > bar" etc
|
|
48
|
-
*/
|
|
49
|
-
function parseIncludeStr(raw) {
|
|
50
|
-
const lastArrow = raw.lastIndexOf(">");
|
|
51
|
-
return lastArrow === -1 ? raw : raw.slice(lastArrow + 1).trim();
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* @param {string} target
|
|
55
|
-
* @param {string | RegExp | (string | RegExp)[]} pattern
|
|
56
|
-
*/
|
|
57
|
-
function isMatch(target, pattern) {
|
|
58
|
-
if (Array.isArray(pattern)) return pattern.some((p) => isMatch(target, p));
|
|
59
|
-
else if (typeof pattern === "string") return target === pattern;
|
|
60
|
-
else if (pattern instanceof RegExp) return pattern.test(target);
|
|
61
|
-
}
|
|
62
|
-
module.exports = {
|
|
63
|
-
isDepIncluded,
|
|
64
|
-
isDepExcluded,
|
|
65
|
-
isDepNoExternaled,
|
|
66
|
-
isDepExternaled
|
|
67
|
-
};
|
|
68
|
-
})))();
|
|
69
|
-
/** @type {import('pnpapi')} */
|
|
70
|
-
let pnp;
|
|
71
|
-
/** @type {Array<{ name: string; reference: string; }>} */
|
|
72
|
-
let pnpWorkspaceLocators;
|
|
73
|
-
if (process.versions.pnp) try {
|
|
74
|
-
pnp = createRequire(import.meta.url)("pnpapi");
|
|
75
|
-
pnpWorkspaceLocators = pnp.getDependencyTreeRoots();
|
|
76
|
-
} catch {}
|
|
77
|
-
/** @type {import('./index.d.ts').crawlFrameworkPkgs} */
|
|
78
|
-
async function crawlFrameworkPkgs(options) {
|
|
79
|
-
const pkgJsonPath = await findClosestPkgJsonPath(options.root);
|
|
80
|
-
if (!pkgJsonPath) return {
|
|
81
|
-
optimizeDeps: {
|
|
82
|
-
include: [],
|
|
83
|
-
exclude: []
|
|
84
|
-
},
|
|
85
|
-
ssr: {
|
|
86
|
-
noExternal: [],
|
|
87
|
-
external: []
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
const pkgJson = await readJson(pkgJsonPath).catch((e) => {
|
|
91
|
-
throw new Error(`Unable to read ${pkgJsonPath}`, { cause: e });
|
|
92
|
-
});
|
|
93
|
-
/** @type {string[]} */
|
|
94
|
-
let optimizeDepsInclude = [];
|
|
95
|
-
/** @type {string[]} */
|
|
96
|
-
let optimizeDepsExclude = [];
|
|
97
|
-
/** @type {string[]} */
|
|
98
|
-
let ssrNoExternal = [];
|
|
99
|
-
/** @type {string[]} */
|
|
100
|
-
let ssrExternal = [];
|
|
101
|
-
await crawl(pkgJsonPath, pkgJson);
|
|
102
|
-
if (options.viteUserConfig) {
|
|
103
|
-
const _optimizeDepsExclude = options.viteUserConfig?.optimizeDeps?.exclude;
|
|
104
|
-
if (_optimizeDepsExclude) optimizeDepsInclude = optimizeDepsInclude.filter((dep) => !(0, import_sync.isDepExcluded)(dep, _optimizeDepsExclude));
|
|
105
|
-
const _optimizeDepsInclude = options.viteUserConfig?.optimizeDeps?.include;
|
|
106
|
-
if (_optimizeDepsInclude) optimizeDepsExclude = optimizeDepsExclude.filter((dep) => !(0, import_sync.isDepIncluded)(dep, _optimizeDepsInclude));
|
|
107
|
-
const _ssrExternal = options.viteUserConfig?.ssr?.external;
|
|
108
|
-
if (_ssrExternal) ssrNoExternal = ssrNoExternal.filter((dep) => !(0, import_sync.isDepExternaled)(dep, _ssrExternal));
|
|
109
|
-
const _ssrNoExternal = options.viteUserConfig?.ssr?.noExternal;
|
|
110
|
-
if (_ssrNoExternal) ssrExternal = ssrExternal.filter((dep) => !(0, import_sync.isDepNoExternaled)(dep, _ssrNoExternal));
|
|
111
|
-
}
|
|
112
|
-
optimizeDepsInclude.sort();
|
|
113
|
-
optimizeDepsExclude.sort();
|
|
114
|
-
ssrExternal.sort();
|
|
115
|
-
ssrNoExternal.sort();
|
|
116
|
-
return {
|
|
117
|
-
optimizeDeps: {
|
|
118
|
-
include: optimizeDepsInclude,
|
|
119
|
-
exclude: optimizeDepsExclude
|
|
120
|
-
},
|
|
121
|
-
ssr: {
|
|
122
|
-
noExternal: ssrNoExternal,
|
|
123
|
-
external: ssrExternal
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
/**
|
|
127
|
-
* crawl the package.json dependencies for framework packages. rules:
|
|
128
|
-
* 1. a framework package should be `optimizeDeps.exclude` and `ssr.noExternal`.
|
|
129
|
-
* 2. the deps of the framework package should be `optimizeDeps.include` and `ssr.external`
|
|
130
|
-
* unless the dep is also a framework package, in which case do no1 & no2 recursively.
|
|
131
|
-
* 3. any non-framework packages that aren't imported by a framework package can be skipped entirely.
|
|
132
|
-
* 4. a semi-framework package is like a framework package, except it isn't `optimizeDeps.exclude`,
|
|
133
|
-
* but only applies `ssr.noExternal`.
|
|
134
|
-
* @param {string} pkgJsonPath
|
|
135
|
-
* @param {Record<string, any>} pkgJson
|
|
136
|
-
* @param {string[]} [parentDepNames]
|
|
137
|
-
*/
|
|
138
|
-
async function crawl(pkgJsonPath, pkgJson, parentDepNames = []) {
|
|
139
|
-
const isRoot = parentDepNames.length === 0;
|
|
140
|
-
const crawlDevDependencies = isRoot || isPrivateWorkspacePackage(pkgJsonPath, pkgJson, options.workspaceRoot);
|
|
141
|
-
/** @type {string[]} */
|
|
142
|
-
let deps = [...Object.keys(pkgJson.dependencies || {}), ...crawlDevDependencies ? Object.keys(pkgJson.devDependencies || {}) : []];
|
|
143
|
-
deps = deps.filter((dep) => {
|
|
144
|
-
if (parentDepNames.includes(dep)) return false;
|
|
145
|
-
const isFrameworkPkg = options.isFrameworkPkgByName?.(dep);
|
|
146
|
-
const isSemiFrameworkPkg = options.isSemiFrameworkPkgByName?.(dep);
|
|
147
|
-
if (isFrameworkPkg) {
|
|
148
|
-
optimizeDepsExclude.push(dep);
|
|
149
|
-
ssrNoExternal.push(dep);
|
|
150
|
-
} else if (isSemiFrameworkPkg) ssrNoExternal.push(dep);
|
|
151
|
-
if (isFrameworkPkg === false || isSemiFrameworkPkg === false) return false;
|
|
152
|
-
else return true;
|
|
153
|
-
});
|
|
154
|
-
const promises = deps.map(async (dep) => {
|
|
155
|
-
const depPkgJsonPath = await _findDepPkgJsonPath(dep, pkgJsonPath, !!options.workspaceRoot);
|
|
156
|
-
if (!depPkgJsonPath) return;
|
|
157
|
-
const depPkgJson = await readJson(depPkgJsonPath).catch(() => {});
|
|
158
|
-
if (!depPkgJson) return;
|
|
159
|
-
if (ssrNoExternal.includes(dep)) return crawl(depPkgJsonPath, depPkgJson, parentDepNames.concat(dep));
|
|
160
|
-
const isFrameworkPkg = options.isFrameworkPkgByJson?.(depPkgJson);
|
|
161
|
-
const isSemiFrameworkPkg = options.isSemiFrameworkPkgByJson?.(depPkgJson);
|
|
162
|
-
if (isFrameworkPkg || isSemiFrameworkPkg) {
|
|
163
|
-
if (isFrameworkPkg) {
|
|
164
|
-
optimizeDepsExclude.push(dep);
|
|
165
|
-
ssrNoExternal.push(dep);
|
|
166
|
-
} else if (isSemiFrameworkPkg) ssrNoExternal.push(dep);
|
|
167
|
-
return crawl(depPkgJsonPath, depPkgJson, parentDepNames.concat(dep));
|
|
168
|
-
}
|
|
169
|
-
if (!isRoot) {
|
|
170
|
-
if (await pkgNeedsOptimization(depPkgJson, depPkgJsonPath)) optimizeDepsInclude.push(parentDepNames.concat(dep).join(" > "));
|
|
171
|
-
if (!options.isBuild && !ssrExternal.includes(dep)) ssrExternal.push(dep);
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
await Promise.all(promises);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* internal implementation to avoid exposing the usePnpWorkspaceLocators flag
|
|
179
|
-
*
|
|
180
|
-
* @param {string} dep
|
|
181
|
-
* @param {string} parent
|
|
182
|
-
* @param {boolean} usePnpWorkspaceLocators
|
|
183
|
-
* @returns {Promise<undefined|string>}
|
|
184
|
-
* @private
|
|
185
|
-
*/
|
|
186
|
-
async function _findDepPkgJsonPath(dep, parent, usePnpWorkspaceLocators) {
|
|
187
|
-
if (pnp) {
|
|
188
|
-
if (usePnpWorkspaceLocators) try {
|
|
189
|
-
const locator = pnpWorkspaceLocators.find((root) => root.name === dep);
|
|
190
|
-
if (locator) {
|
|
191
|
-
const pkgPath = pnp.getPackageInformation(locator).packageLocation;
|
|
192
|
-
return path.resolve(pkgPath, "package.json");
|
|
193
|
-
}
|
|
194
|
-
} catch {}
|
|
195
|
-
try {
|
|
196
|
-
const depRoot = pnp.resolveToUnqualified(dep, parent);
|
|
197
|
-
if (!depRoot) return void 0;
|
|
198
|
-
return path.join(depRoot, "package.json");
|
|
199
|
-
} catch {
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
let root = parent;
|
|
204
|
-
while (root) {
|
|
205
|
-
const pkg = path.join(root, "node_modules", dep, "package.json");
|
|
206
|
-
try {
|
|
207
|
-
await fs.access(pkg);
|
|
208
|
-
return fsSync.realpathSync(pkg);
|
|
209
|
-
} catch {}
|
|
210
|
-
const nextRoot = path.dirname(root);
|
|
211
|
-
if (nextRoot === root) break;
|
|
212
|
-
root = nextRoot;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
/** @type {import('./index.d.ts').findClosestPkgJsonPath} */
|
|
216
|
-
async function findClosestPkgJsonPath(dir, predicate = void 0) {
|
|
217
|
-
if (dir.endsWith("package.json")) dir = path.dirname(dir);
|
|
218
|
-
while (dir) {
|
|
219
|
-
const pkg = path.join(dir, "package.json");
|
|
220
|
-
try {
|
|
221
|
-
if ((await fs.stat(pkg)).isFile() && (!predicate || await predicate(pkg))) return pkg;
|
|
222
|
-
} catch {}
|
|
223
|
-
const nextDir = path.dirname(dir);
|
|
224
|
-
if (nextDir === dir) break;
|
|
225
|
-
dir = nextDir;
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
/** @type {import('./index.d.ts').pkgNeedsOptimization} */
|
|
229
|
-
async function pkgNeedsOptimization(pkgJson, pkgJsonPath) {
|
|
230
|
-
if (pkgJson.module || pkgJson.exports) return false;
|
|
231
|
-
if (pkgJson.main) {
|
|
232
|
-
const entryExt = path.extname(pkgJson.main);
|
|
233
|
-
return !entryExt || entryExt === ".js" || entryExt === ".cjs";
|
|
234
|
-
}
|
|
235
|
-
try {
|
|
236
|
-
await fs.access(path.join(path.dirname(pkgJsonPath), "index.js"));
|
|
237
|
-
return true;
|
|
238
|
-
} catch {
|
|
239
|
-
return false;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* @param {string} findDepPkgJsonPath
|
|
244
|
-
* @returns {Promise<Record<string, any>>}
|
|
245
|
-
*/
|
|
246
|
-
async function readJson(findDepPkgJsonPath) {
|
|
247
|
-
return JSON.parse(await fs.readFile(findDepPkgJsonPath, "utf8"));
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
*
|
|
251
|
-
* @param {string} pkgJsonPath
|
|
252
|
-
* @param {Record<string,any>} pkgJson
|
|
253
|
-
* @param {string} [workspaceRoot]
|
|
254
|
-
* @returns {boolean}
|
|
255
|
-
*/
|
|
256
|
-
function isPrivateWorkspacePackage(pkgJsonPath, pkgJson, workspaceRoot = void 0) {
|
|
257
|
-
return !!(workspaceRoot && pkgJson.private && !pkgJsonPath.match(/[/\\]node_modules[/\\]/) && !path.relative(workspaceRoot, pkgJsonPath).startsWith(".."));
|
|
258
|
-
}
|
|
259
|
-
//#endregion
|
|
260
|
-
//#region src/vite/index.ts
|
|
261
|
-
async function mdx(_config, pluginOptions = {}) {
|
|
262
|
-
const options = applyDefaults(pluginOptions);
|
|
263
|
-
const core = createViteCore(options);
|
|
264
|
-
const config = await _config ?? (await runnerImport(options.configPath)).module;
|
|
265
|
-
await core.init({ config: buildConfig(config) });
|
|
266
|
-
const configLoader = createIntegratedConfigLoader(core);
|
|
267
|
-
const mdxLoader = toVite(createMdxLoader(configLoader));
|
|
268
|
-
const metaLoader = toVite(createMetaLoader(configLoader, { json: "json" }));
|
|
269
|
-
return {
|
|
270
|
-
name: "fumadocs-mdx",
|
|
271
|
-
enforce: "pre",
|
|
272
|
-
async config(config, { command }) {
|
|
273
|
-
if (!options.updateViteConfig) return config;
|
|
274
|
-
const out = await crawlFrameworkPkgs({
|
|
275
|
-
root: process.cwd(),
|
|
276
|
-
isBuild: command === "build",
|
|
277
|
-
isFrameworkPkgByName(pkgName) {
|
|
278
|
-
if (pkgName.startsWith("@fumapress/") || pkgName.startsWith("@fumadocs/") || pkgName.startsWith("fumadocs-") || pkgName === "fumapress") return true;
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
return {
|
|
282
|
-
ssr: { noExternal: out.ssr.noExternal },
|
|
283
|
-
optimizeDeps: out.optimizeDeps
|
|
284
|
-
};
|
|
285
|
-
},
|
|
286
|
-
async buildStart() {
|
|
287
|
-
await core.emit({ write: true });
|
|
288
|
-
},
|
|
289
|
-
async configureServer(server) {
|
|
290
|
-
await core.initServer({ watcher: server.watcher });
|
|
291
|
-
},
|
|
292
|
-
async transform(value, id) {
|
|
293
|
-
try {
|
|
294
|
-
if (metaLoader.filter(id)) return await metaLoader.transform.call(this, value, id);
|
|
295
|
-
if (mdxLoader.filter(id)) return await mdxLoader.transform.call(this, value, id);
|
|
296
|
-
} catch (e) {
|
|
297
|
-
if (e instanceof ValidationError) throw new Error(await e.toStringFormatted(), { cause: e });
|
|
298
|
-
throw e;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
async function postInstall(pluginOptions = {}) {
|
|
304
|
-
const { loadConfig } = await import("../load-from-file-D0UVwCFc.mjs");
|
|
305
|
-
const core = createViteCore(applyDefaults(pluginOptions));
|
|
306
|
-
await core.init({ config: loadConfig(core, true) });
|
|
307
|
-
await core.emit({ write: true });
|
|
308
|
-
}
|
|
309
|
-
function createViteCore({ index, configPath, outDir }) {
|
|
310
|
-
if (index === true) index = {};
|
|
311
|
-
return createCore({
|
|
312
|
-
environment: "vite",
|
|
313
|
-
configPath,
|
|
314
|
-
outDir,
|
|
315
|
-
plugins: [index && indexFile({
|
|
316
|
-
...index,
|
|
317
|
-
target: index.target ?? "vite"
|
|
318
|
-
})]
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
function applyDefaults(options) {
|
|
322
|
-
return {
|
|
323
|
-
updateViteConfig: options.updateViteConfig ?? true,
|
|
324
|
-
index: options.index ?? true,
|
|
325
|
-
configPath: options.configPath ?? _Defaults.configPath,
|
|
326
|
-
outDir: options.outDir ?? _Defaults.outDir
|
|
327
|
-
};
|
|
328
|
-
}
|
|
329
|
-
//#endregion
|
|
330
|
-
export { mdx as default, postInstall, __exportAll as t };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|