prev-cli 0.22.3 → 0.22.4

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/cli.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  // src/cli.ts
4
4
  import { parseArgs } from "util";
5
- import path9 from "path";
5
+ import path10 from "path";
6
6
  import { existsSync as existsSync7, mkdirSync as mkdirSync2, writeFileSync as writeFileSync4, rmSync as rmSync3, readFileSync as readFileSync5 } from "fs";
7
7
  import { fileURLToPath as fileURLToPath3 } from "url";
8
8
 
@@ -15,7 +15,7 @@ import react from "@vitejs/plugin-react";
15
15
  import mdx from "@mdx-js/rollup";
16
16
  import remarkGfm from "remark-gfm";
17
17
  import rehypeHighlight from "rehype-highlight";
18
- import path7 from "path";
18
+ import path8 from "path";
19
19
  import { fileURLToPath as fileURLToPath2 } from "url";
20
20
  import { existsSync as existsSync5, readFileSync as readFileSync4 } from "fs";
21
21
 
@@ -70,6 +70,9 @@ async function ensureCacheDir(rootDir) {
70
70
  return cacheDir;
71
71
  }
72
72
 
73
+ // src/vite/plugins/pages-plugin.ts
74
+ import path3 from "path";
75
+
73
76
  // src/vite/pages.ts
74
77
  import fg from "fast-glob";
75
78
  import { readFile } from "fs/promises";
@@ -254,45 +257,82 @@ function buildSidebarTree(pages) {
254
257
  // src/vite/plugins/pages-plugin.ts
255
258
  var VIRTUAL_MODULE_ID = "virtual:prev-pages";
256
259
  var RESOLVED_VIRTUAL_MODULE_ID = "\x00" + VIRTUAL_MODULE_ID;
260
+ var VIRTUAL_MODULES_ID = "virtual:prev-page-modules";
261
+ var RESOLVED_VIRTUAL_MODULES_ID = "\x00" + VIRTUAL_MODULES_ID;
257
262
  function pagesPlugin(rootDir, options = {}) {
258
263
  const { include } = options;
264
+ let cachedPages = null;
265
+ async function getPages() {
266
+ if (!cachedPages) {
267
+ cachedPages = await scanPages(rootDir, { include });
268
+ }
269
+ return cachedPages;
270
+ }
259
271
  return {
260
272
  name: "prev-pages",
261
273
  resolveId(id) {
262
274
  if (id === VIRTUAL_MODULE_ID) {
263
275
  return RESOLVED_VIRTUAL_MODULE_ID;
264
276
  }
277
+ if (id === VIRTUAL_MODULES_ID) {
278
+ return RESOLVED_VIRTUAL_MODULES_ID;
279
+ }
265
280
  },
266
281
  async load(id) {
267
282
  if (id === RESOLVED_VIRTUAL_MODULE_ID) {
268
- const pages = await scanPages(rootDir, { include });
283
+ const pages = await getPages();
269
284
  const sidebar = buildSidebarTree(pages);
270
285
  return `
271
286
  export const pages = ${JSON.stringify(pages)};
272
287
  export const sidebar = ${JSON.stringify(sidebar)};
273
288
  `;
274
289
  }
290
+ if (id === RESOLVED_VIRTUAL_MODULES_ID) {
291
+ const pages = await getPages();
292
+ const imports = pages.map((page, i) => {
293
+ const absolutePath = path3.join(rootDir, page.file);
294
+ return `import * as _page${i} from ${JSON.stringify(absolutePath)};`;
295
+ }).join(`
296
+ `);
297
+ const entries = pages.map((page, i) => {
298
+ return ` ${JSON.stringify("/" + page.file)}: _page${i}`;
299
+ }).join(`,
300
+ `);
301
+ return `${imports}
302
+
303
+ export const pageModules = {
304
+ ${entries}
305
+ };`;
306
+ }
275
307
  },
276
308
  handleHotUpdate({ file, server }) {
277
309
  if (file.endsWith(".mdx") || file.endsWith(".md")) {
310
+ cachedPages = null;
278
311
  const mod = server.moduleGraph.getModuleById(RESOLVED_VIRTUAL_MODULE_ID);
312
+ const modulesMod = server.moduleGraph.getModuleById(RESOLVED_VIRTUAL_MODULES_ID);
313
+ const mods = [];
279
314
  if (mod) {
280
315
  server.moduleGraph.invalidateModule(mod);
281
- return [mod];
316
+ mods.push(mod);
317
+ }
318
+ if (modulesMod) {
319
+ server.moduleGraph.invalidateModule(modulesMod);
320
+ mods.push(modulesMod);
282
321
  }
322
+ return mods.length > 0 ? mods : undefined;
283
323
  }
284
324
  }
285
325
  };
286
326
  }
287
327
 
288
328
  // src/vite/plugins/entry-plugin.ts
289
- import path3 from "path";
329
+ import path4 from "path";
290
330
  import { fileURLToPath } from "url";
291
331
  import { existsSync, readFileSync, writeFileSync, unlinkSync } from "fs";
292
332
  function findCliRoot() {
293
- let dir = path3.dirname(fileURLToPath(import.meta.url));
333
+ let dir = path4.dirname(fileURLToPath(import.meta.url));
294
334
  for (let i = 0;i < 10; i++) {
295
- const pkgPath = path3.join(dir, "package.json");
335
+ const pkgPath = path4.join(dir, "package.json");
296
336
  if (existsSync(pkgPath)) {
297
337
  try {
298
338
  const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
@@ -301,15 +341,15 @@ function findCliRoot() {
301
341
  }
302
342
  } catch {}
303
343
  }
304
- const parent = path3.dirname(dir);
344
+ const parent = path4.dirname(dir);
305
345
  if (parent === dir)
306
346
  break;
307
347
  dir = parent;
308
348
  }
309
- return path3.dirname(path3.dirname(fileURLToPath(import.meta.url)));
349
+ return path4.dirname(path4.dirname(fileURLToPath(import.meta.url)));
310
350
  }
311
351
  var cliRoot = findCliRoot();
312
- var srcRoot = path3.join(cliRoot, "src");
352
+ var srcRoot = path4.join(cliRoot, "src");
313
353
  function getHtml(entryPath, forBuild = false) {
314
354
  const scriptSrc = forBuild ? entryPath : `/@fs${entryPath}`;
315
355
  return `<!DOCTYPE html>
@@ -332,13 +372,13 @@ function getHtml(entryPath, forBuild = false) {
332
372
  </html>`;
333
373
  }
334
374
  function entryPlugin(rootDir) {
335
- const entryPath = path3.join(srcRoot, "theme/entry.tsx");
375
+ const entryPath = path4.join(srcRoot, "theme/entry.tsx");
336
376
  let tempHtmlPath = null;
337
377
  return {
338
378
  name: "prev-entry",
339
379
  config(config, { command }) {
340
380
  if (command === "build" && rootDir) {
341
- tempHtmlPath = path3.join(rootDir, "index.html");
381
+ tempHtmlPath = path4.join(rootDir, "index.html");
342
382
  writeFileSync(tempHtmlPath, getHtml(entryPath, true));
343
383
  const existingInput = config.build?.rollupOptions?.input || {};
344
384
  const inputObj = typeof existingInput === "string" ? { _original: existingInput } : Array.isArray(existingInput) ? Object.fromEntries(existingInput.map((f, i) => [`entry${i}`, f])) : existingInput;
@@ -385,10 +425,10 @@ function entryPlugin(rootDir) {
385
425
 
386
426
  // src/vite/previews.ts
387
427
  import fg2 from "fast-glob";
388
- import path4 from "path";
428
+ import path5 from "path";
389
429
  import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
390
430
  async function scanPreviews(rootDir) {
391
- const previewsDir = path4.join(rootDir, "previews");
431
+ const previewsDir = path5.join(rootDir, "previews");
392
432
  if (!existsSync2(previewsDir)) {
393
433
  return [];
394
434
  }
@@ -398,17 +438,17 @@ async function scanPreviews(rootDir) {
398
438
  });
399
439
  const previewDirs = new Map;
400
440
  for (const file of entryFiles) {
401
- const dir = path4.dirname(file);
441
+ const dir = path5.dirname(file);
402
442
  if (!previewDirs.has(dir)) {
403
443
  previewDirs.set(dir, file);
404
444
  }
405
445
  }
406
446
  return Array.from(previewDirs.entries()).map(([dir, file]) => {
407
- const name = dir === "." ? path4.basename(previewsDir) : dir;
447
+ const name = dir === "." ? path5.basename(previewsDir) : dir;
408
448
  return {
409
449
  name,
410
450
  route: `/_preview/${name}`,
411
- htmlPath: path4.join(previewsDir, file)
451
+ htmlPath: path5.join(previewsDir, file)
412
452
  };
413
453
  });
414
454
  }
@@ -418,8 +458,8 @@ async function scanPreviewFiles(previewDir) {
418
458
  ignore: ["node_modules/**", "dist/**"]
419
459
  });
420
460
  return files.map((file) => {
421
- const content = readFileSync2(path4.join(previewDir, file), "utf-8");
422
- const ext = path4.extname(file).slice(1);
461
+ const content = readFileSync2(path5.join(previewDir, file), "utf-8");
462
+ const ext = path5.extname(file).slice(1);
423
463
  return {
424
464
  path: file,
425
465
  content,
@@ -563,7 +603,7 @@ async function buildPreviewHtml(config) {
563
603
 
564
604
  // src/vite/plugins/previews-plugin.ts
565
605
  import { existsSync as existsSync3, mkdirSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
566
- import path5 from "path";
606
+ import path6 from "path";
567
607
  var VIRTUAL_MODULE_ID2 = "virtual:prev-previews";
568
608
  var RESOLVED_VIRTUAL_MODULE_ID2 = "\x00" + VIRTUAL_MODULE_ID2;
569
609
  function previewsPlugin(rootDir) {
@@ -596,10 +636,10 @@ function previewsPlugin(rootDir) {
596
636
  async closeBundle() {
597
637
  if (!isBuild)
598
638
  return;
599
- const distDir = path5.join(rootDir, "dist");
600
- const targetDir = path5.join(distDir, "_preview");
601
- const previewsDir = path5.join(rootDir, "previews");
602
- const oldPreviewsDir = path5.join(distDir, "previews");
639
+ const distDir = path6.join(rootDir, "dist");
640
+ const targetDir = path6.join(distDir, "_preview");
641
+ const previewsDir = path6.join(rootDir, "previews");
642
+ const oldPreviewsDir = path6.join(distDir, "previews");
603
643
  if (existsSync3(oldPreviewsDir)) {
604
644
  rmSync(oldPreviewsDir, { recursive: true });
605
645
  }
@@ -612,7 +652,7 @@ function previewsPlugin(rootDir) {
612
652
  console.log(`
613
653
  Building ${previews.length} preview(s)...`);
614
654
  for (const preview of previews) {
615
- const previewDir = path5.join(previewsDir, preview.name);
655
+ const previewDir = path6.join(previewsDir, preview.name);
616
656
  try {
617
657
  const config = await buildPreviewConfig(previewDir);
618
658
  const result = await buildPreviewHtml(config);
@@ -620,9 +660,9 @@ function previewsPlugin(rootDir) {
620
660
  console.error(` ✗ ${preview.name}: ${result.error}`);
621
661
  continue;
622
662
  }
623
- const outputDir = path5.join(targetDir, preview.name);
663
+ const outputDir = path6.join(targetDir, preview.name);
624
664
  mkdirSync(outputDir, { recursive: true });
625
- writeFileSync2(path5.join(outputDir, "index.html"), result.html);
665
+ writeFileSync2(path6.join(outputDir, "index.html"), result.html);
626
666
  console.log(` ✓ ${preview.name}`);
627
667
  } catch (err) {
628
668
  console.error(` ✗ ${preview.name}: ${err}`);
@@ -693,11 +733,11 @@ function validateConfig(raw) {
693
733
  }
694
734
  // src/config/loader.ts
695
735
  import { readFileSync as readFileSync3, existsSync as existsSync4, writeFileSync as writeFileSync3 } from "fs";
696
- import path6 from "path";
736
+ import path7 from "path";
697
737
  import yaml from "js-yaml";
698
738
  function findConfigFile(rootDir) {
699
- const yamlPath = path6.join(rootDir, ".prev.yaml");
700
- const ymlPath = path6.join(rootDir, ".prev.yml");
739
+ const yamlPath = path7.join(rootDir, ".prev.yaml");
740
+ const ymlPath = path7.join(rootDir, ".prev.yml");
701
741
  if (existsSync4(yamlPath))
702
742
  return yamlPath;
703
743
  if (existsSync4(ymlPath))
@@ -719,7 +759,7 @@ function loadConfig(rootDir) {
719
759
  }
720
760
  }
721
761
  function saveConfig(rootDir, config) {
722
- const configPath = findConfigFile(rootDir) || path6.join(rootDir, ".prev.yaml");
762
+ const configPath = findConfigFile(rootDir) || path7.join(rootDir, ".prev.yaml");
723
763
  const content = yaml.dump(config, {
724
764
  indent: 2,
725
765
  lineWidth: -1,
@@ -788,9 +828,9 @@ function createFriendlyLogger() {
788
828
  };
789
829
  }
790
830
  function findCliRoot2() {
791
- let dir = path7.dirname(fileURLToPath2(import.meta.url));
831
+ let dir = path8.dirname(fileURLToPath2(import.meta.url));
792
832
  for (let i = 0;i < 10; i++) {
793
- const pkgPath = path7.join(dir, "package.json");
833
+ const pkgPath = path8.join(dir, "package.json");
794
834
  if (existsSync5(pkgPath)) {
795
835
  try {
796
836
  const pkg = JSON.parse(readFileSync4(pkgPath, "utf-8"));
@@ -799,24 +839,24 @@ function findCliRoot2() {
799
839
  }
800
840
  } catch {}
801
841
  }
802
- const parent = path7.dirname(dir);
842
+ const parent = path8.dirname(dir);
803
843
  if (parent === dir)
804
844
  break;
805
845
  dir = parent;
806
846
  }
807
- return path7.dirname(path7.dirname(fileURLToPath2(import.meta.url)));
847
+ return path8.dirname(path8.dirname(fileURLToPath2(import.meta.url)));
808
848
  }
809
849
  function findNodeModules(cliRoot2) {
810
- const localNodeModules = path7.join(cliRoot2, "node_modules");
811
- if (existsSync5(path7.join(localNodeModules, "react"))) {
850
+ const localNodeModules = path8.join(cliRoot2, "node_modules");
851
+ if (existsSync5(path8.join(localNodeModules, "react"))) {
812
852
  return localNodeModules;
813
853
  }
814
854
  let dir = cliRoot2;
815
855
  for (let i = 0;i < 10; i++) {
816
- const parent = path7.dirname(dir);
856
+ const parent = path8.dirname(dir);
817
857
  if (parent === dir)
818
858
  break;
819
- if (path7.basename(parent) === "node_modules" && existsSync5(path7.join(parent, "react"))) {
859
+ if (path8.basename(parent) === "node_modules" && existsSync5(path8.join(parent, "react"))) {
820
860
  return parent;
821
861
  }
822
862
  dir = parent;
@@ -825,7 +865,7 @@ function findNodeModules(cliRoot2) {
825
865
  }
826
866
  var cliRoot2 = findCliRoot2();
827
867
  var cliNodeModules = findNodeModules(cliRoot2);
828
- var srcRoot2 = path7.join(cliRoot2, "src");
868
+ var srcRoot2 = path8.join(cliRoot2, "src");
829
869
  async function createViteConfig(options) {
830
870
  const { rootDir, mode, port, include } = options;
831
871
  const cacheDir = await ensureCacheDir(rootDir);
@@ -883,7 +923,7 @@ async function createViteConfig(options) {
883
923
  if (urlPath.startsWith("/__") || urlPath.startsWith("/@") || urlPath.startsWith("/node_modules") || urlPath.includes(".")) {
884
924
  return next();
885
925
  }
886
- const indexPath = path7.join(srcRoot2, "theme/index.html");
926
+ const indexPath = path8.join(srcRoot2, "theme/index.html");
887
927
  if (existsSync5(indexPath)) {
888
928
  server.transformIndexHtml(req.url, readFileSync4(indexPath, "utf-8")).then((html) => {
889
929
  res.setHeader("Content-Type", "text/html");
@@ -901,8 +941,8 @@ async function createViteConfig(options) {
901
941
  resolveId(id) {
902
942
  if (id.startsWith("/_preview/")) {
903
943
  const relativePath = id.slice("/_preview/".length);
904
- const previewsDir = path7.join(rootDir, "previews");
905
- const resolved = path7.resolve(previewsDir, relativePath);
944
+ const previewsDir = path8.join(rootDir, "previews");
945
+ const resolved = path8.resolve(previewsDir, relativePath);
906
946
  if (resolved.startsWith(previewsDir)) {
907
947
  return resolved;
908
948
  }
@@ -912,7 +952,7 @@ async function createViteConfig(options) {
912
952
  server.middlewares.use(async (req, res, next) => {
913
953
  const urlPath = req.url?.split("?")[0] || "";
914
954
  if (urlPath === "/_preview-runtime") {
915
- const templatePath = path7.join(srcRoot2, "preview-runtime/template.html");
955
+ const templatePath = path8.join(srcRoot2, "preview-runtime/template.html");
916
956
  if (existsSync5(templatePath)) {
917
957
  const html = readFileSync4(templatePath, "utf-8");
918
958
  res.setHeader("Content-Type", "text/html");
@@ -922,8 +962,8 @@ async function createViteConfig(options) {
922
962
  }
923
963
  if (urlPath.startsWith("/_preview-config/")) {
924
964
  const previewName = decodeURIComponent(urlPath.slice("/_preview-config/".length));
925
- const previewsDir = path7.join(rootDir, "previews");
926
- const previewDir = path7.resolve(previewsDir, previewName);
965
+ const previewsDir = path8.join(rootDir, "previews");
966
+ const previewDir = path8.resolve(previewsDir, previewName);
927
967
  if (!previewDir.startsWith(previewsDir)) {
928
968
  res.statusCode = 403;
929
969
  res.end("Forbidden");
@@ -944,11 +984,11 @@ async function createViteConfig(options) {
944
984
  }
945
985
  }
946
986
  if (urlPath.startsWith("/_preview/")) {
947
- const isHtmlRequest = !path7.extname(urlPath) || urlPath.endsWith("/");
987
+ const isHtmlRequest = !path8.extname(urlPath) || urlPath.endsWith("/");
948
988
  if (isHtmlRequest) {
949
989
  const previewName = decodeURIComponent(urlPath.slice("/_preview/".length).replace(/\/$/, ""));
950
- const previewsDir = path7.join(rootDir, "previews");
951
- const htmlPath = path7.resolve(previewsDir, previewName, "index.html");
990
+ const previewsDir = path8.join(rootDir, "previews");
991
+ const htmlPath = path8.resolve(previewsDir, previewName, "index.html");
952
992
  if (!htmlPath.startsWith(previewsDir)) {
953
993
  return next();
954
994
  }
@@ -975,15 +1015,15 @@ async function createViteConfig(options) {
975
1015
  ],
976
1016
  resolve: {
977
1017
  alias: {
978
- "@prev/ui": path7.join(srcRoot2, "ui"),
979
- "@prev/theme": path7.join(srcRoot2, "theme"),
980
- react: path7.join(cliNodeModules, "react"),
981
- "react-dom": path7.join(cliNodeModules, "react-dom"),
982
- "@tanstack/react-router": path7.join(cliNodeModules, "@tanstack/react-router"),
983
- "@mdx-js/react": path7.join(cliNodeModules, "@mdx-js/react"),
984
- mermaid: path7.join(cliNodeModules, "mermaid"),
985
- dayjs: path7.join(cliNodeModules, "dayjs"),
986
- "@terrastruct/d2": path7.join(cliNodeModules, "@terrastruct/d2")
1018
+ "@prev/ui": path8.join(srcRoot2, "ui"),
1019
+ "@prev/theme": path8.join(srcRoot2, "theme"),
1020
+ react: path8.join(cliNodeModules, "react"),
1021
+ "react-dom": path8.join(cliNodeModules, "react-dom"),
1022
+ "@tanstack/react-router": path8.join(cliNodeModules, "@tanstack/react-router"),
1023
+ "@mdx-js/react": path8.join(cliNodeModules, "@mdx-js/react"),
1024
+ mermaid: path8.join(cliNodeModules, "mermaid"),
1025
+ dayjs: path8.join(cliNodeModules, "dayjs"),
1026
+ "@terrastruct/d2": path8.join(cliNodeModules, "@terrastruct/d2")
987
1027
  },
988
1028
  dedupe: [
989
1029
  "react",
@@ -1008,6 +1048,7 @@ async function createViteConfig(options) {
1008
1048
  "virtual:prev-config",
1009
1049
  "virtual:prev-previews",
1010
1050
  "virtual:prev-pages",
1051
+ "virtual:prev-page-modules",
1011
1052
  "@prev/theme"
1012
1053
  ]
1013
1054
  },
@@ -1022,8 +1063,8 @@ async function createViteConfig(options) {
1022
1063
  },
1023
1064
  warmup: {
1024
1065
  clientFiles: [
1025
- path7.join(srcRoot2, "theme/entry.tsx"),
1026
- path7.join(srcRoot2, "theme/styles.css")
1066
+ path8.join(srcRoot2, "theme/entry.tsx"),
1067
+ path8.join(srcRoot2, "theme/styles.css")
1027
1068
  ]
1028
1069
  }
1029
1070
  },
@@ -1032,12 +1073,12 @@ async function createViteConfig(options) {
1032
1073
  strictPort: false
1033
1074
  },
1034
1075
  build: {
1035
- outDir: path7.join(rootDir, "dist"),
1076
+ outDir: path8.join(rootDir, "dist"),
1036
1077
  reportCompressedSize: false,
1037
1078
  chunkSizeWarningLimit: 1e4,
1038
1079
  rollupOptions: {
1039
1080
  input: {
1040
- main: path7.join(srcRoot2, "theme/index.html")
1081
+ main: path8.join(srcRoot2, "theme/index.html")
1041
1082
  }
1042
1083
  }
1043
1084
  }
@@ -1078,7 +1119,7 @@ async function findAvailablePort(minPort, maxPort) {
1078
1119
  // src/vite/start.ts
1079
1120
  import { exec as exec2 } from "child_process";
1080
1121
  import { existsSync as existsSync6, rmSync as rmSync2 } from "fs";
1081
- import path8 from "path";
1122
+ import path9 from "path";
1082
1123
  function printWelcome(type) {
1083
1124
  console.log();
1084
1125
  console.log(" ✨ prev");
@@ -1111,8 +1152,8 @@ function openBrowser(url) {
1111
1152
  console.log(` ↗ Opened ${url}`);
1112
1153
  }
1113
1154
  function clearCache(rootDir) {
1114
- const viteCacheDir = path8.join(rootDir, ".vite");
1115
- const nodeModulesVite = path8.join(rootDir, "node_modules", ".vite");
1155
+ const viteCacheDir = path9.join(rootDir, ".vite");
1156
+ const nodeModulesVite = path9.join(rootDir, "node_modules", ".vite");
1116
1157
  let cleared = 0;
1117
1158
  if (existsSync6(viteCacheDir)) {
1118
1159
  rmSync2(viteCacheDir, { recursive: true });
@@ -1212,15 +1253,15 @@ async function previewSite(rootDir, options = {}) {
1212
1253
  import yaml2 from "js-yaml";
1213
1254
  function getVersion() {
1214
1255
  try {
1215
- let dir = path9.dirname(fileURLToPath3(import.meta.url));
1256
+ let dir = path10.dirname(fileURLToPath3(import.meta.url));
1216
1257
  for (let i = 0;i < 5; i++) {
1217
- const pkgPath = path9.join(dir, "package.json");
1258
+ const pkgPath = path10.join(dir, "package.json");
1218
1259
  if (existsSync7(pkgPath)) {
1219
1260
  const pkg = JSON.parse(readFileSync5(pkgPath, "utf-8"));
1220
1261
  if (pkg.name === "prev-cli")
1221
1262
  return pkg.version;
1222
1263
  }
1223
- dir = path9.dirname(dir);
1264
+ dir = path10.dirname(dir);
1224
1265
  }
1225
1266
  } catch {}
1226
1267
  return "unknown";
@@ -1237,7 +1278,7 @@ var { values, positionals } = parseArgs({
1237
1278
  allowPositionals: true
1238
1279
  });
1239
1280
  var command = positionals[0] || "dev";
1240
- var rootDir = path9.resolve(values.cwd || (command === "config" || command === "create" ? "." : positionals[1]) || ".");
1281
+ var rootDir = path10.resolve(values.cwd || (command === "config" || command === "create" ? "." : positionals[1]) || ".");
1241
1282
  function printHelp() {
1242
1283
  console.log(`
1243
1284
  prev - Zero-config documentation site generator
@@ -1345,8 +1386,8 @@ async function clearViteCache(rootDir2) {
1345
1386
  console.log(` ✓ Removed ${prevCacheDir}`);
1346
1387
  }
1347
1388
  } catch {}
1348
- const viteCacheDir = path9.join(rootDir2, ".vite");
1349
- const nodeModulesVite = path9.join(rootDir2, "node_modules", ".vite");
1389
+ const viteCacheDir = path10.join(rootDir2, ".vite");
1390
+ const nodeModulesVite = path10.join(rootDir2, "node_modules", ".vite");
1350
1391
  if (existsSync7(viteCacheDir)) {
1351
1392
  rmSync3(viteCacheDir, { recursive: true });
1352
1393
  cleared++;
@@ -1398,7 +1439,7 @@ function handleConfig(rootDir2, subcommand) {
1398
1439
  break;
1399
1440
  }
1400
1441
  case "init": {
1401
- const targetPath = path9.join(rootDir2, ".prev.yaml");
1442
+ const targetPath = path10.join(rootDir2, ".prev.yaml");
1402
1443
  if (configPath) {
1403
1444
  console.log(`
1404
1445
  Config already exists: ${configPath}
@@ -1457,7 +1498,7 @@ Available subcommands: show, init, path`);
1457
1498
  }
1458
1499
  }
1459
1500
  function createPreview(rootDir2, name) {
1460
- const previewDir = path9.join(rootDir2, "previews", name);
1501
+ const previewDir = path10.join(rootDir2, "previews", name);
1461
1502
  if (existsSync7(previewDir)) {
1462
1503
  console.error(`Preview "${name}" already exists at: ${previewDir}`);
1463
1504
  process.exit(1);
@@ -1583,8 +1624,8 @@ export default function App() {
1583
1624
  .dark\\:text-white { color: #fff; }
1584
1625
  }
1585
1626
  `;
1586
- writeFileSync4(path9.join(previewDir, "App.tsx"), appTsx);
1587
- writeFileSync4(path9.join(previewDir, "styles.css"), stylesCss);
1627
+ writeFileSync4(path10.join(previewDir, "App.tsx"), appTsx);
1628
+ writeFileSync4(path10.join(previewDir, "styles.css"), stylesCss);
1588
1629
  console.log(`
1589
1630
  ✨ Created preview: previews/${name}/
1590
1631
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prev-cli",
3
- "version": "0.22.3",
3
+ "version": "0.22.4",
4
4
  "description": "Transform MDX directories into beautiful documentation websites",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -14,6 +14,7 @@ import {
14
14
  } from '@tanstack/react-router'
15
15
  import { MDXProvider } from '@mdx-js/react'
16
16
  import { pages, sidebar } from 'virtual:prev-pages'
17
+ import { pageModules } from 'virtual:prev-page-modules'
17
18
  import { previews } from 'virtual:prev-previews'
18
19
  import { Preview } from './Preview'
19
20
  import { useDiagrams } from './diagrams'
@@ -64,11 +65,10 @@ function convertToPageTree(items: any[]): PageTree.Root {
64
65
  }
65
66
  }
66
67
 
67
- // Dynamic imports for MDX pages (include dot directories for --include flag)
68
- const pageModules = import.meta.glob(['/**/*.{md,mdx}', '/.*/**/*.{md,mdx}'], { eager: true })
69
-
68
+ // Page modules are dynamically generated by the pages plugin
69
+ // This ensures all MDX files are included regardless of dot-prefixed directories
70
70
  function getPageComponent(file: string): React.ComponentType | null {
71
- const mod = pageModules[`/${file}`] as { default: React.ComponentType } | undefined
71
+ const mod = pageModules[`/${file}`]
72
72
  return mod?.default || null
73
73
  }
74
74