@aravindc26/velu 0.12.5 → 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.
- package/package.json +1 -1
- package/src/cli.ts +23 -1
- package/src/preview-engine/app/layout.tsx +4 -1
package/package.json
CHANGED
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) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
+
import { RootProvider } from 'fumadocs-ui/provider/next';
|
|
2
3
|
import './global.css';
|
|
3
4
|
|
|
4
5
|
export const metadata = {
|
|
@@ -9,7 +10,9 @@ export default function RootLayout({ children }: { children: ReactNode }) {
|
|
|
9
10
|
return (
|
|
10
11
|
<html lang="en" suppressHydrationWarning>
|
|
11
12
|
<body className="min-h-screen" suppressHydrationWarning>
|
|
12
|
-
|
|
13
|
+
<RootProvider>
|
|
14
|
+
{children}
|
|
15
|
+
</RootProvider>
|
|
13
16
|
</body>
|
|
14
17
|
</html>
|
|
15
18
|
);
|