@aravindc26/velu 0.12.6 → 0.12.7

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/cli.ts +23 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aravindc26/velu",
3
- "version": "0.12.6",
3
+ "version": "0.12.7",
4
4
  "description": "A modern documentation site generator powered by Markdown and JSON configuration",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/cli.ts CHANGED
@@ -526,13 +526,23 @@ async function previewServer(port: number) {
526
526
 
527
527
  const child = spawn("node", [nextBinPath, "dev", "--port", String(port), "--turbopack"], {
528
528
  cwd: runtimeDir,
529
- stdio: "inherit",
529
+ stdio: ["inherit", "pipe", "inherit"],
530
530
  env: {
531
531
  ...previewServerEnv(),
532
532
  WATCHPACK_POLLING: process.env.WATCHPACK_POLLING || "true",
533
533
  },
534
534
  });
535
535
 
536
+ // Pipe stdout through while watching for the "Ready" signal to trigger warmup
537
+ let warmedUp = false;
538
+ child.stdout?.on("data", (data: Buffer) => {
539
+ process.stdout.write(data);
540
+ if (!warmedUp && data.toString().includes("Ready")) {
541
+ warmedUp = true;
542
+ warmupRoutes(port);
543
+ }
544
+ });
545
+
536
546
  const cleanup = () => child.kill("SIGTERM");
537
547
  process.on("SIGINT", cleanup);
538
548
  process.on("SIGTERM", cleanup);
@@ -546,6 +556,18 @@ async function previewServer(port: number) {
546
556
  });
547
557
  }
548
558
 
559
+ /** Pre-warm key routes so Turbopack compiles them before real user requests. */
560
+ function warmupRoutes(port: number) {
561
+ const routes = [
562
+ "/api/sessions/_warmup/init", // compile API route
563
+ "/_warmup/docs/warmup", // compile [sessionId]/[...slug] page route
564
+ ];
565
+ console.log(" Pre-warming routes...");
566
+ for (const route of routes) {
567
+ fetch(`http://localhost:${port}${route}`).catch(() => {});
568
+ }
569
+ }
570
+
549
571
  // ── run ──────────────────────────────────────────────────────────────────────────
550
572
 
551
573
  function spawnServer(outDir: string, command: string, port: number, docsDir: string) {