perf(csr): load component controllers on demand

This commit is contained in:
2026-08-09 14:10:15 +05:30
parent 324928cfca
commit 1660044ed2
8 changed files with 180 additions and 11 deletions
+3
View File
@@ -12,6 +12,7 @@
import {
getActionRuntime,
getComponentControllerRuntime,
getReactiveRuntime,
getNavRuntime,
getRealtimeRuntime,
@@ -94,6 +95,8 @@ export function createDevAssetServer(
return serveWrnBrowserArtifact(pathname) ?? new Response("Not Found", { status: 404 });
}
if (pathname === "/__wrnexus/reactive.js") return jsResponse(getReactiveRuntime(true));
if (pathname === "/__wrnexus/controllers.js")
return jsResponse(getComponentControllerRuntime(true));
if (pathname === "/__wrnexus/nav.js") return jsResponse(getNavRuntime());
if (pathname === "/__wrnexus/realtime.js") return jsResponse(getRealtimeRuntime());
if (pathname === "/__wrnexus/actions.js") return jsResponse(getActionRuntime());
+7
View File
@@ -20,6 +20,7 @@ import {
} from "@wrnexus/router";
import {
getActionRuntime,
getComponentControllerRuntime,
getReactiveRuntime,
getNavRuntime,
getRealtimeRuntime,
@@ -92,6 +93,8 @@ export interface ProdOptions {
stylesIncludeFramework?: boolean;
/** Absolute path to the pre-built reactive runtime. */
reactivePath?: string;
/** Absolute path to the on-demand component controller runtime. */
controllersPath?: string;
/** Absolute directory containing bundled per-WRN browser modules. */
clientModulesDir?: string;
/** Absolute path to the pre-built theme stylesheet (`theme.css`). */
@@ -341,6 +344,10 @@ function createProdAssetServer(opts: ProdOptions): AssetServer {
}
return new Response(getReactiveRuntime(), { headers: JS_HEADERS });
}
if (pathname === "/__wrnexus/controllers.js") {
if (opts.controllersPath) return serveFile(opts.controllersPath, JS_HEADERS);
return new Response(getComponentControllerRuntime(), { headers: JS_HEADERS });
}
if (pathname === "/__wrnexus/nav.js")
return new Response(getNavRuntime(), { headers: JS_HEADERS });
if (pathname === "/__wrnexus/realtime.js")