fumadocs-mdx 10.0.0 → 10.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.
@@ -4,6 +4,7 @@ import fs from "node:fs";
4
4
 
5
5
  // src/config/load.ts
6
6
  import * as path from "node:path";
7
+ import { pathToFileURL } from "node:url";
7
8
  import { build } from "esbuild";
8
9
 
9
10
  // src/config/validate.ts
@@ -58,9 +59,10 @@ async function loadConfig(configPath) {
58
59
  if (transformed.errors.length > 0) {
59
60
  throw new Error("failed to compile configuration file");
60
61
  }
62
+ const url = pathToFileURL(outputPath);
61
63
  const [err, config] = validateConfig(
62
64
  // every call to `loadConfig` will cause the previous cache to be ignored
63
- await import(`${outputPath}?hash=${Date.now().toString()}`)
65
+ await import(`${url.toString()}?hash=${Date.now().toString()}`)
64
66
  );
65
67
  if (err !== null) throw new Error(err);
66
68
  return config;
@@ -88,7 +90,6 @@ async function getConfigHash(configPath) {
88
90
 
89
91
  // src/map/manifest.ts
90
92
  import fs2 from "node:fs";
91
- import { createHash as createHash2 } from "node:crypto";
92
93
  import path2 from "node:path";
93
94
 
94
95
  // src/utils/get-type-from-path.ts
@@ -102,8 +103,9 @@ function getTypeFromPath(path3) {
102
103
  }
103
104
 
104
105
  // src/map/manifest.ts
105
- function getKey(key) {
106
- return createHash2("sha256").update(key).digest("hex");
106
+ function getManifestEntryPath(originalPath) {
107
+ const toName = path2.relative(process.cwd(), originalPath).replaceAll(`..${path2.sep}`, "-").replaceAll(path2.sep, "_");
108
+ return path2.resolve(".next/cache/fumadocs", `${toName}.json`);
107
109
  }
108
110
  function writeManifest(to, config) {
109
111
  const output = { files: [] };
@@ -111,9 +113,7 @@ function writeManifest(to, config) {
111
113
  const type = config.collections.get(collection)?.type ?? getTypeFromPath(file);
112
114
  if (type === "meta") continue;
113
115
  try {
114
- const content = fs2.readFileSync(
115
- path2.resolve(".next/cache/fumadocs", `${getKey(file)}.json`)
116
- );
116
+ const content = fs2.readFileSync(getManifestEntryPath(file));
117
117
  const meta = JSON.parse(content.toString());
118
118
  output.files.push({
119
119
  ...meta,
@@ -132,6 +132,6 @@ export {
132
132
  loadConfigCached,
133
133
  getConfigHash,
134
134
  getTypeFromPath,
135
- getKey,
135
+ getManifestEntryPath,
136
136
  writeManifest
137
137
  };
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  getConfigHash,
3
- getKey,
3
+ getManifestEntryPath,
4
4
  loadConfigCached
5
- } from "./chunk-EKBKQCSU.mjs";
5
+ } from "./chunk-VW6REBOK.mjs";
6
6
  import {
7
7
  getDefaultMDXOptions
8
8
  } from "./chunk-LRV535YP.mjs";
@@ -192,7 +192,7 @@ async function loader(source, callback) {
192
192
  if (config.global?.generateManifest) {
193
193
  await fs2.mkdir(".next/cache/fumadocs", { recursive: true });
194
194
  await fs2.writeFile(
195
- path3.resolve(".next/cache/fumadocs", `${getKey(filePath)}.json`),
195
+ getManifestEntryPath(filePath),
196
196
  JSON.stringify({
197
197
  path: filePath,
198
198
  data: file.data
@@ -5,7 +5,7 @@ import {
5
5
  loadConfig,
6
6
  loadConfigCached,
7
7
  writeManifest
8
- } from "../chunk-EKBKQCSU.mjs";
8
+ } from "../chunk-VW6REBOK.mjs";
9
9
 
10
10
  // src/next/create.ts
11
11
  import path3 from "node:path";
@@ -91,11 +91,11 @@ async function generateJS(configPath, config, outputPath, hash) {
91
91
  return [...imports, ...sources].join("\n");
92
92
  }
93
93
  function toImportPath(file, dir) {
94
- let importPath = path.relative(dir, file).replaceAll(path.sep, "/");
95
- if (!importPath.startsWith(".")) {
94
+ let importPath = path.relative(dir, file);
95
+ if (!path.isAbsolute(importPath) && !importPath.startsWith(".")) {
96
96
  importPath = `./${importPath}`;
97
97
  }
98
- return importPath;
98
+ return importPath.replaceAll(path.sep, "/");
99
99
  }
100
100
  function generateTypes(configPath, config, outputPath) {
101
101
  const importPath = JSON.stringify(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-mdx",
3
- "version": "10.0.0",
3
+ "version": "10.0.2",
4
4
  "description": "The built-in source for Fumadocs",
5
5
  "keywords": [
6
6
  "NextJs",
@@ -60,11 +60,11 @@
60
60
  "@types/mdx": "^2.0.13",
61
61
  "@types/micromatch": "^4.0.9",
62
62
  "@types/react": "^18.3.5",
63
- "next": "^14.2.7",
63
+ "next": "^14.2.8",
64
64
  "unified": "^11.0.5",
65
65
  "webpack": "^5.90.3",
66
66
  "eslint-config-custom": "0.0.0",
67
- "fumadocs-core": "13.4.2",
67
+ "fumadocs-core": "13.4.8",
68
68
  "tsconfig": "0.0.0"
69
69
  },
70
70
  "peerDependencies": {