perf(studio): defer import history and Nitro scale tools until opened
CI / check (push) Successful in 3m7s
CI / deploy (push) Successful in 1m2s
CI / publish-container (push) Successful in 1m8s

This commit is contained in:
Simo committed 2026-09-13 18:29:24 +02:00
1 parent 13665e0c3c
commit afea80708c
5 files changed
+339 -199

No files matched your search

+48
View File
@@ -0,0 +1,48 @@
import path from "node:path";
import { build } from "esbuild";
import { expect, it } from "vitest";
it("keeps scale preview and generation outside the initial Nitro editor bundle", async () => {
const entry = "src/app/admin/import/furni/nitro-editor-dialog.tsx";
const result = await build({
entryPoints: [entry],
bundle: true,
splitting: true,
format: "esm",
write: false,
outdir: "storage/bundle-check",
metafile: true,
packages: "external",
alias: { "@": path.resolve("src") },
});
const outputs = result.metafile.outputs;
const start = Object.keys(outputs).find(
(key) => outputs[key].entryPoint === entry,
);
expect(start).toBeDefined();
const seen = new Set<string>();
function visit(key: string) {
if (seen.has(key)) return;
seen.add(key);
for (const dependency of outputs[key].imports) {
if (dependency.kind !== "dynamic-import" && !dependency.external)
visit(dependency.path);
}
}
if (!start) throw new Error("Missing editor entry bundle");
visit(start);
const initialInputs = new Set(
[...seen].flatMap((key) => Object.keys(outputs[key].inputs)),
);
for (const name of [
"nitro-quality-panel.tsx",
"nitro-scale32-generator.tsx",
]) {
expect(
Object.keys(result.metafile.inputs).some((input) => input.endsWith(name)),
).toBe(true);
expect([...initialInputs].some((input) => input.endsWith(name))).toBe(
false,
);
}
}, 30_000);