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
+2
View File
@@ -12,12 +12,14 @@
*/
import {
getReactiveRuntime,
getComponentControllerRuntime,
getNavRuntime,
getRealtimeRuntime,
} from "../../packages/csr/src/index.ts";
const runtimes: Record<string, string> = {
"reactive-runtime.ts": getReactiveRuntime(),
"component-controllers.ts": getComponentControllerRuntime(),
"nav-runtime.ts": getNavRuntime(),
"realtime-runtime.ts": getRealtimeRuntime(),
};
+4 -2
View File
@@ -169,7 +169,8 @@ addCheck(
* minified transfer once. That is the number worth defending.
*/
const runtimeBudgets = {
"reactive-runtime.ts": 71_000,
"reactive-runtime.ts": 49_000,
"component-controllers.ts": 24_100,
"nav-runtime.ts": 12_000,
"realtime-runtime.ts": 8_000,
};
@@ -182,7 +183,8 @@ const minifiedSizes = JSON.parse(
);
for (const [file, budget] of Object.entries(runtimeBudgets)) {
const bytes = minifiedSizes[file];
const raw = statSync(join(root, "packages", "csr", "src", file)).size;
const sourceFile = file === "component-controllers.ts" ? "reactive-runtime.ts" : file;
const raw = statSync(join(root, "packages", "csr", "src", sourceFile)).size;
addCheck(
`PERF-RUNTIME-SIZE-${file.replace(/-runtime\.ts$/, "").toUpperCase()}`,
typeof bytes === "number" && bytes <= budget,