fumadocs-mdx 12.0.3 → 13.0.1
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 +1116 -359
- package/dist/bin.js +4 -4
- package/dist/build-mdx-CCNr86q6.d.ts +53 -0
- package/dist/build-mdx-D-r3_eQL.d.cts +53 -0
- package/dist/bun/index.cjs +196 -52
- package/dist/bun/index.d.cts +8 -3
- package/dist/bun/index.d.ts +8 -3
- package/dist/bun/index.js +19 -10
- package/dist/{chunk-QAUWMR5D.js → chunk-3J3WL7WN.js} +23 -5
- package/dist/{chunk-6Y5JDZHD.js → chunk-CXA4JO4Z.js} +1 -21
- package/dist/chunk-EELYB2XC.js +207 -0
- package/dist/{chunk-46UPKP5R.js → chunk-II3H5ZVZ.js} +5 -5
- package/dist/{chunk-LGYVNESJ.js → chunk-JVZFH6ND.js} +6 -22
- package/dist/{chunk-LMG6UWCL.js → chunk-K5ZLPEIQ.js} +56 -16
- package/dist/{chunk-OMAMTKDE.js → chunk-KILFIBVW.js} +3 -12
- package/dist/chunk-NVRDCY6Z.js +30 -0
- package/dist/{chunk-RMDXSZYE.js → chunk-XQ5O7IPO.js} +31 -24
- package/dist/chunk-XZY2AWJI.js +81 -0
- package/dist/{chunk-VXEBLM4X.js → chunk-YVCR6FUH.js} +1 -1
- package/dist/config/index.cjs +56 -16
- package/dist/config/index.d.cts +2 -1
- package/dist/config/index.d.ts +2 -1
- package/dist/config/index.js +1 -1
- package/dist/{define-DJbJduHy.d.ts → core-B6j6Fxse.d.cts} +89 -2
- package/dist/{define-DJbJduHy.d.cts → core-B6j6Fxse.d.ts} +89 -2
- package/dist/index.cjs +0 -109
- package/dist/index.d.cts +75 -9
- package/dist/index.d.ts +75 -9
- package/dist/index.js +0 -11
- package/dist/{load-UUXLUBHL.js → load-MNG3CLET.js} +1 -3
- package/dist/next/index.cjs +298 -234
- package/dist/next/index.d.cts +2 -11
- package/dist/next/index.d.ts +2 -11
- package/dist/next/index.js +177 -141
- package/dist/node/loader.cjs +228 -85
- package/dist/node/loader.js +19 -9
- package/dist/plugins/json-schema.cjs +162 -0
- package/dist/plugins/json-schema.d.cts +24 -0
- package/dist/plugins/json-schema.d.ts +24 -0
- package/dist/plugins/json-schema.js +78 -0
- package/dist/runtime/next/async.cjs +108 -70
- package/dist/runtime/next/async.d.cts +9 -6
- package/dist/runtime/next/async.d.ts +9 -6
- package/dist/runtime/next/async.js +8 -18
- package/dist/runtime/next/index.cjs +25 -14
- package/dist/runtime/next/index.d.cts +11 -8
- package/dist/runtime/next/index.d.ts +11 -8
- package/dist/runtime/next/index.js +2 -2
- package/dist/runtime/vite/browser.cjs +7 -3
- package/dist/runtime/vite/browser.d.cts +56 -7
- package/dist/runtime/vite/browser.d.ts +56 -7
- package/dist/runtime/vite/browser.js +2 -1
- package/dist/runtime/vite/server.cjs +40 -34
- package/dist/runtime/vite/server.d.cts +13 -10
- package/dist/runtime/vite/server.d.ts +13 -10
- package/dist/runtime/vite/server.js +8 -23
- package/dist/{types-TeHjsmja.d.ts → types-AGzTfBmf.d.ts} +3 -10
- package/dist/{types-BRx1QsIJ.d.cts → types-DKGMoay5.d.cts} +3 -10
- package/dist/vite/index.cjs +443 -249
- package/dist/vite/index.d.cts +23 -10
- package/dist/vite/index.d.ts +23 -10
- package/dist/vite/index.js +213 -36
- package/dist/{loader-mdx.cjs → webpack/index.cjs} +268 -82
- package/dist/{loader-mdx.d.ts → webpack/index.d.cts} +1 -0
- package/dist/{loader-mdx.d.cts → webpack/index.d.ts} +1 -0
- package/dist/webpack/index.js +44 -0
- package/loader-mdx.cjs +1 -1
- package/package.json +30 -16
- package/dist/browser-BupUnhpC.d.ts +0 -98
- package/dist/browser-R0x9IPaQ.d.cts +0 -98
- package/dist/chunk-ADR6R7HM.js +0 -29
- package/dist/chunk-IQAEAI4P.js +0 -66
- package/dist/chunk-XMFLD5J6.js +0 -30
- package/dist/chunk-ZLCSVXCD.js +0 -10
- package/dist/chunk-ZX7TM4AR.js +0 -127
- package/dist/loader-mdx.js +0 -25
- package/dist/postinstall-SCSXM4IM.js +0 -10
- package/dist/shared-CfiiRctw.d.ts +0 -70
- package/dist/shared-fFqiuWJC.d.cts +0 -70
- package/dist/watcher-HGOH3APP.js +0 -22
package/dist/next/index.d.cts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import { NextConfig } from 'next';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Start a MDX server that builds index and manifest files.
|
|
5
|
-
*
|
|
6
|
-
* In development mode, it starts a file watcher to auto-update output as your input changes.
|
|
7
|
-
*/
|
|
8
|
-
declare function start(dev: boolean, configPath: string, outDir: string): Promise<void>;
|
|
9
|
-
|
|
10
3
|
interface CreateMDXOptions {
|
|
11
4
|
/**
|
|
12
5
|
* Path to source configuration file
|
|
@@ -19,9 +12,7 @@ interface CreateMDXOptions {
|
|
|
19
12
|
*/
|
|
20
13
|
outDir?: string;
|
|
21
14
|
}
|
|
22
|
-
|
|
23
|
-
declare function createMDX({ configPath, outDir, }?: CreateMDXOptions): (nextConfig?: NextConfig) => NextConfig;
|
|
24
|
-
|
|
15
|
+
declare function createMDX(createOptions?: CreateMDXOptions): (nextConfig?: NextConfig) => NextConfig;
|
|
25
16
|
declare function postInstall(configPath?: string, outDir?: string): Promise<void>;
|
|
26
17
|
|
|
27
|
-
export { type CreateMDXOptions, createMDX, postInstall
|
|
18
|
+
export { type CreateMDXOptions, createMDX, postInstall };
|
package/dist/next/index.d.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import { NextConfig } from 'next';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Start a MDX server that builds index and manifest files.
|
|
5
|
-
*
|
|
6
|
-
* In development mode, it starts a file watcher to auto-update output as your input changes.
|
|
7
|
-
*/
|
|
8
|
-
declare function start(dev: boolean, configPath: string, outDir: string): Promise<void>;
|
|
9
|
-
|
|
10
3
|
interface CreateMDXOptions {
|
|
11
4
|
/**
|
|
12
5
|
* Path to source configuration file
|
|
@@ -19,9 +12,7 @@ interface CreateMDXOptions {
|
|
|
19
12
|
*/
|
|
20
13
|
outDir?: string;
|
|
21
14
|
}
|
|
22
|
-
|
|
23
|
-
declare function createMDX({ configPath, outDir, }?: CreateMDXOptions): (nextConfig?: NextConfig) => NextConfig;
|
|
24
|
-
|
|
15
|
+
declare function createMDX(createOptions?: CreateMDXOptions): (nextConfig?: NextConfig) => NextConfig;
|
|
25
16
|
declare function postInstall(configPath?: string, outDir?: string): Promise<void>;
|
|
26
17
|
|
|
27
|
-
export { type CreateMDXOptions, createMDX, postInstall
|
|
18
|
+
export { type CreateMDXOptions, createMDX, postInstall };
|
package/dist/next/index.js
CHANGED
|
@@ -1,40 +1,93 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
} from "../chunk-ADR6R7HM.js";
|
|
2
|
+
loadConfig
|
|
3
|
+
} from "../chunk-JVZFH6ND.js";
|
|
5
4
|
import {
|
|
6
|
-
getGlobPatterns,
|
|
7
5
|
getImportCode,
|
|
8
|
-
isFileSupported,
|
|
9
6
|
toImportPath
|
|
10
|
-
} from "../chunk-
|
|
11
|
-
import {
|
|
12
|
-
getConfigHash,
|
|
13
|
-
loadConfig
|
|
14
|
-
} from "../chunk-LGYVNESJ.js";
|
|
7
|
+
} from "../chunk-CXA4JO4Z.js";
|
|
15
8
|
import "../chunk-U4MQ44TS.js";
|
|
16
9
|
import {
|
|
17
10
|
ValidationError,
|
|
11
|
+
createCore,
|
|
12
|
+
findConfigFile,
|
|
18
13
|
getGitTimestamp,
|
|
19
14
|
validate
|
|
20
|
-
} from "../chunk-
|
|
21
|
-
import {
|
|
22
|
-
findConfigFile
|
|
23
|
-
} from "../chunk-XMFLD5J6.js";
|
|
15
|
+
} from "../chunk-EELYB2XC.js";
|
|
24
16
|
import {
|
|
25
17
|
fumaMatter
|
|
26
18
|
} from "../chunk-VWJKRQZR.js";
|
|
19
|
+
import {
|
|
20
|
+
getCollectionFiles
|
|
21
|
+
} from "../chunk-XZY2AWJI.js";
|
|
27
22
|
|
|
28
23
|
// src/next/index.ts
|
|
29
|
-
import path3 from "path";
|
|
30
|
-
|
|
24
|
+
import * as path3 from "path";
|
|
25
|
+
|
|
26
|
+
// src/next/file-cache.ts
|
|
27
|
+
import { LRUCache } from "lru-cache";
|
|
28
|
+
import fs from "fs/promises";
|
|
29
|
+
import path from "path";
|
|
30
|
+
var map = new LRUCache({
|
|
31
|
+
max: 100
|
|
32
|
+
});
|
|
33
|
+
function toFullPath(file) {
|
|
34
|
+
if (path.isAbsolute(file)) {
|
|
35
|
+
return path.relative(process.cwd(), file);
|
|
36
|
+
}
|
|
37
|
+
return file;
|
|
38
|
+
}
|
|
39
|
+
async function readFileWithCache(file) {
|
|
40
|
+
const fullPath = toFullPath(file);
|
|
41
|
+
const cached = map.get(fullPath);
|
|
42
|
+
if (cached) return cached;
|
|
43
|
+
const read = fs.readFile(fullPath).then((s) => s.toString());
|
|
44
|
+
map.set(fullPath, read);
|
|
45
|
+
return read;
|
|
46
|
+
}
|
|
47
|
+
function removeFileCache(file) {
|
|
48
|
+
map.delete(toFullPath(file));
|
|
49
|
+
}
|
|
31
50
|
|
|
32
|
-
// src/next
|
|
33
|
-
import * as
|
|
51
|
+
// src/plugins/next.ts
|
|
52
|
+
import * as path2 from "path";
|
|
34
53
|
import { createHash } from "crypto";
|
|
35
|
-
import { glob } from "tinyglobby";
|
|
36
54
|
import { load } from "js-yaml";
|
|
37
|
-
|
|
55
|
+
function next() {
|
|
56
|
+
let config;
|
|
57
|
+
let shouldEmitOnChange = false;
|
|
58
|
+
return {
|
|
59
|
+
name: "next",
|
|
60
|
+
config(v) {
|
|
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;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
configureServer(server) {
|
|
70
|
+
if (!server.watcher) return;
|
|
71
|
+
server.watcher.on("all", async () => {
|
|
72
|
+
if (!shouldEmitOnChange) return;
|
|
73
|
+
await this.core.emitAndWrite({
|
|
74
|
+
filterPlugin: (plugin) => plugin.name === "next"
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
async emit() {
|
|
79
|
+
return [
|
|
80
|
+
{
|
|
81
|
+
path: "index.ts",
|
|
82
|
+
content: await indexFile(this.configPath, config, {
|
|
83
|
+
relativeTo: this.outDir
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
];
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
async function indexFile(configPath, config, importPath, configHash = false) {
|
|
38
91
|
let asyncInit = false;
|
|
39
92
|
const lines = [
|
|
40
93
|
getImportCode({
|
|
@@ -163,29 +216,8 @@ async function generateJS(configPath, config, importPath, configHash = false) {
|
|
|
163
216
|
...resolvedDeclares
|
|
164
217
|
].join("\n");
|
|
165
218
|
}
|
|
166
|
-
async function getCollectionFiles(collection) {
|
|
167
|
-
const files = /* @__PURE__ */ new Map();
|
|
168
|
-
const dirs = Array.isArray(collection.dir) ? collection.dir : [collection.dir];
|
|
169
|
-
const patterns = getGlobPatterns(collection);
|
|
170
|
-
await Promise.all(
|
|
171
|
-
dirs.map(async (dir) => {
|
|
172
|
-
const result = await glob(patterns, {
|
|
173
|
-
cwd: path.resolve(dir)
|
|
174
|
-
});
|
|
175
|
-
for (const item of result) {
|
|
176
|
-
if (!isFileSupported(item, collection)) continue;
|
|
177
|
-
const fullPath = path.join(dir, item);
|
|
178
|
-
files.set(fullPath, {
|
|
179
|
-
path: item,
|
|
180
|
-
fullPath
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
})
|
|
184
|
-
);
|
|
185
|
-
return Array.from(files.values());
|
|
186
|
-
}
|
|
187
219
|
function parseMetaEntry(file, content) {
|
|
188
|
-
const extname2 =
|
|
220
|
+
const extname2 = path2.extname(file);
|
|
189
221
|
try {
|
|
190
222
|
if (extname2 === ".json") return JSON.parse(content);
|
|
191
223
|
if (extname2 === ".yaml") return load(content);
|
|
@@ -197,91 +229,23 @@ function parseMetaEntry(file, content) {
|
|
|
197
229
|
throw new Error(`Unknown meta file format: ${extname2}, in ${file}.`);
|
|
198
230
|
}
|
|
199
231
|
|
|
200
|
-
// src/next/
|
|
201
|
-
import * as path2 from "path";
|
|
202
|
-
import * as fs from "fs/promises";
|
|
203
|
-
async function start(dev, configPath, outDir) {
|
|
204
|
-
let configHash = await getConfigHash(configPath);
|
|
205
|
-
let config = await loadConfig(configPath, outDir, configHash, true);
|
|
206
|
-
const outPath = path2.resolve(outDir, `index.ts`);
|
|
207
|
-
async function updateMapFile() {
|
|
208
|
-
const start2 = performance.now();
|
|
209
|
-
try {
|
|
210
|
-
await fs.writeFile(
|
|
211
|
-
outPath,
|
|
212
|
-
await generateJS(
|
|
213
|
-
configPath,
|
|
214
|
-
config,
|
|
215
|
-
{ relativeTo: outDir },
|
|
216
|
-
configHash
|
|
217
|
-
)
|
|
218
|
-
);
|
|
219
|
-
} catch (err) {
|
|
220
|
-
if (err instanceof ValidationError) {
|
|
221
|
-
console.error(err.toStringFormatted());
|
|
222
|
-
} else {
|
|
223
|
-
console.error(err);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
console.log(`[MDX] updated map file in ${performance.now() - start2}ms`);
|
|
227
|
-
}
|
|
228
|
-
await updateMapFile();
|
|
229
|
-
if (dev) {
|
|
230
|
-
const { watcher } = await import("../watcher-HGOH3APP.js");
|
|
231
|
-
const instance = watcher(configPath, config, [outPath]);
|
|
232
|
-
instance.on("ready", () => {
|
|
233
|
-
console.log("[MDX] started dev server");
|
|
234
|
-
});
|
|
235
|
-
instance.on("all", (event, file) => {
|
|
236
|
-
if (typeof file !== "string") return;
|
|
237
|
-
const absolutePath = path2.resolve(file);
|
|
238
|
-
const onUpdate = async () => {
|
|
239
|
-
const isConfigFile = absolutePath === configPath;
|
|
240
|
-
if (isConfigFile) {
|
|
241
|
-
configHash = await getConfigHash(configPath);
|
|
242
|
-
config = await loadConfig(configPath, outDir, configHash, true);
|
|
243
|
-
}
|
|
244
|
-
if (event === "change") removeFileCache(absolutePath);
|
|
245
|
-
await updateMapFile();
|
|
246
|
-
};
|
|
247
|
-
void onUpdate();
|
|
248
|
-
});
|
|
249
|
-
process.on("exit", () => {
|
|
250
|
-
console.log("[MDX] closing dev server");
|
|
251
|
-
void instance.close();
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// src/next/create.ts
|
|
257
|
-
import { readFileSync } from "fs";
|
|
232
|
+
// src/next/index.ts
|
|
258
233
|
var defaultPageExtensions = ["mdx", "md", "jsx", "js", "tsx", "ts"];
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
const
|
|
262
|
-
const version = JSON.parse(content).version;
|
|
263
|
-
isTurboExperimental = version.startsWith("15.0.") || version.startsWith("15.1.") || version.startsWith("15.2.");
|
|
264
|
-
} catch {
|
|
265
|
-
isTurboExperimental = false;
|
|
266
|
-
}
|
|
267
|
-
function createMDX({
|
|
268
|
-
configPath = findConfigFile(),
|
|
269
|
-
outDir = ".source"
|
|
270
|
-
} = {}) {
|
|
234
|
+
function createMDX(createOptions = {}) {
|
|
235
|
+
const options = applyDefaults(createOptions);
|
|
236
|
+
const isDev = process.env.NODE_ENV === "development";
|
|
271
237
|
if (process.env._FUMADOCS_MDX !== "1") {
|
|
272
238
|
process.env._FUMADOCS_MDX = "1";
|
|
273
|
-
void
|
|
239
|
+
void init(isDev, options);
|
|
274
240
|
}
|
|
275
241
|
return (nextConfig = {}) => {
|
|
276
242
|
const mdxLoaderOptions = {
|
|
277
|
-
|
|
278
|
-
|
|
243
|
+
...options,
|
|
244
|
+
isDev
|
|
279
245
|
};
|
|
280
|
-
const
|
|
281
|
-
...nextConfig.experimental?.turbo,
|
|
246
|
+
const turbopack = {
|
|
282
247
|
...nextConfig.turbopack,
|
|
283
248
|
rules: {
|
|
284
|
-
...nextConfig.experimental?.turbo?.rules,
|
|
285
249
|
...nextConfig.turbopack?.rules,
|
|
286
250
|
"*.{md,mdx}": {
|
|
287
251
|
loaders: [
|
|
@@ -294,17 +258,18 @@ function createMDX({
|
|
|
294
258
|
}
|
|
295
259
|
}
|
|
296
260
|
};
|
|
297
|
-
|
|
261
|
+
return {
|
|
298
262
|
...nextConfig,
|
|
263
|
+
turbopack,
|
|
299
264
|
pageExtensions: nextConfig.pageExtensions ?? defaultPageExtensions,
|
|
300
|
-
webpack: (config,
|
|
265
|
+
webpack: (config, options2) => {
|
|
301
266
|
config.resolve ||= {};
|
|
302
267
|
config.module ||= {};
|
|
303
268
|
config.module.rules ||= [];
|
|
304
269
|
config.module.rules.push({
|
|
305
270
|
test: /\.mdx?$/,
|
|
306
271
|
use: [
|
|
307
|
-
|
|
272
|
+
options2.defaultLoaders.babel,
|
|
308
273
|
{
|
|
309
274
|
loader: "fumadocs-mdx/loader-mdx",
|
|
310
275
|
options: mdxLoaderOptions
|
|
@@ -312,33 +277,104 @@ function createMDX({
|
|
|
312
277
|
]
|
|
313
278
|
});
|
|
314
279
|
config.plugins ||= [];
|
|
315
|
-
return nextConfig.webpack?.(config,
|
|
280
|
+
return nextConfig.webpack?.(config, options2) ?? config;
|
|
316
281
|
}
|
|
317
282
|
};
|
|
318
|
-
if (isTurboExperimental) {
|
|
319
|
-
updated.experimental = { ...updated.experimental, turbo };
|
|
320
|
-
} else {
|
|
321
|
-
updated.turbopack = turbo;
|
|
322
|
-
}
|
|
323
|
-
return updated;
|
|
324
283
|
};
|
|
325
284
|
}
|
|
326
|
-
|
|
327
|
-
|
|
285
|
+
async function init(dev, options) {
|
|
286
|
+
const core = createNextCore(options);
|
|
287
|
+
async function initOrReload() {
|
|
288
|
+
await core.init({
|
|
289
|
+
config: loadConfig(options.configPath, options.outDir, true)
|
|
290
|
+
});
|
|
291
|
+
await core.emitAndWrite();
|
|
292
|
+
}
|
|
293
|
+
async function devServer() {
|
|
294
|
+
const { FSWatcher } = await import("chokidar");
|
|
295
|
+
const watcher = new FSWatcher({
|
|
296
|
+
ignoreInitial: true,
|
|
297
|
+
persistent: true,
|
|
298
|
+
ignored: [options.outDir]
|
|
299
|
+
});
|
|
300
|
+
watcher.add(options.configPath);
|
|
301
|
+
for (const collection of core.getConfig().collections.values()) {
|
|
302
|
+
if (collection.type === "docs") {
|
|
303
|
+
watcher.add(collection.docs.dir);
|
|
304
|
+
watcher.add(collection.meta.dir);
|
|
305
|
+
} else {
|
|
306
|
+
watcher.add(collection.dir);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
watcher.on("ready", () => {
|
|
310
|
+
console.log("[MDX] started dev server");
|
|
311
|
+
});
|
|
312
|
+
watcher.on("all", async (event, file) => {
|
|
313
|
+
const absolutePath = path3.resolve(file);
|
|
314
|
+
if (event === "change") removeFileCache(absolutePath);
|
|
315
|
+
if (absolutePath === path3.resolve(options.configPath)) {
|
|
316
|
+
watcher.removeAllListeners();
|
|
317
|
+
await watcher.close();
|
|
318
|
+
await initOrReload();
|
|
319
|
+
console.log("[MDX] restarting dev server");
|
|
320
|
+
await devServer();
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
process.on("exit", () => {
|
|
324
|
+
if (watcher.closed) return;
|
|
325
|
+
console.log("[MDX] closing dev server");
|
|
326
|
+
void watcher.close();
|
|
327
|
+
});
|
|
328
|
+
await core.initServer({ watcher });
|
|
329
|
+
}
|
|
330
|
+
await initOrReload();
|
|
331
|
+
if (dev) {
|
|
332
|
+
await devServer();
|
|
333
|
+
}
|
|
334
|
+
}
|
|
328
335
|
async function postInstall(configPath = findConfigFile(), outDir = ".source") {
|
|
329
|
-
const
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
336
|
+
const core = await createNextCore({
|
|
337
|
+
outDir,
|
|
338
|
+
configPath
|
|
339
|
+
}).init({
|
|
340
|
+
config: loadConfig(configPath, outDir, true)
|
|
341
|
+
});
|
|
342
|
+
await core.emitAndWrite();
|
|
343
|
+
}
|
|
344
|
+
function applyDefaults(options) {
|
|
345
|
+
return {
|
|
346
|
+
outDir: options.outDir ?? ".source",
|
|
347
|
+
configPath: options.configPath ?? findConfigFile()
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
function createNextCore({
|
|
351
|
+
outDir,
|
|
352
|
+
configPath
|
|
353
|
+
}) {
|
|
354
|
+
const core = createCore(
|
|
355
|
+
{
|
|
356
|
+
environment: "next",
|
|
357
|
+
outDir,
|
|
358
|
+
configPath
|
|
359
|
+
},
|
|
360
|
+
[next()]
|
|
337
361
|
);
|
|
338
|
-
|
|
362
|
+
return {
|
|
363
|
+
...core,
|
|
364
|
+
async emitAndWrite(...args) {
|
|
365
|
+
try {
|
|
366
|
+
await core.emitAndWrite(...args);
|
|
367
|
+
} catch (err) {
|
|
368
|
+
if (err instanceof ValidationError) {
|
|
369
|
+
console.error(err.toStringFormatted());
|
|
370
|
+
} else {
|
|
371
|
+
console.error(err);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
};
|
|
339
376
|
}
|
|
340
377
|
export {
|
|
341
378
|
createMDX,
|
|
342
|
-
postInstall
|
|
343
|
-
start
|
|
379
|
+
postInstall
|
|
344
380
|
};
|