perf(csr): load component controllers on demand
This commit is contained in:
@@ -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(),
|
||||
};
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user