From 84dab0abe5df353e7481cb7be4e6b46e93033027 Mon Sep 17 00:00:00 2001 From: Federico Jaramillo Martinez Date: Fri, 8 May 2026 16:30:53 +0200 Subject: [PATCH] Split editor and terminal client chunks --- src/client/src/plugins/core/panels.ts | 13 +++++++++++-- vite.config.ts | 12 ++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/client/src/plugins/core/panels.ts b/src/client/src/plugins/core/panels.ts index f173aae..3328f40 100644 --- a/src/client/src/plugins/core/panels.ts +++ b/src/client/src/plugins/core/panels.ts @@ -1,8 +1,6 @@ import { html, type TemplateResult } from "lit"; import type { FileTreeEntry, GitDiffResponse, GitStatusResponse } from "../../api"; import type { WorkspacePanelContribution, WorkspacePanelContext } from "../types"; -import "../../components/CodeViewer"; -import "../../components/TerminalPanel"; export function createCoreWorkspacePanels(): WorkspacePanelContribution[] { return [ @@ -68,6 +66,7 @@ function renderFileViewer(context: WorkspacePanelContext): TemplateResult { if (context.selectedFilePath === undefined || context.selectedFilePath === "") return html`

Select a file.

`; if (file === undefined) return html`

Loading ${context.selectedFilePath}…

`; if (file.binary) return html`

Binary file: ${file.path}

`; + loadCodeViewer(); return html`
${file.path}${file.language ?? "text"}${file.truncated ? " · truncated" : ""}
@@ -75,6 +74,7 @@ function renderFileViewer(context: WorkspacePanelContext): TemplateResult { } function renderTerminal(context: WorkspacePanelContext): TemplateResult { + loadTerminalPanel(); return html``; } @@ -120,6 +120,7 @@ function renderDiffViewer(context: WorkspacePanelContext): TemplateResult { } function renderDiffSection(diff: GitDiffResponse): TemplateResult { + loadCodeViewer(); return html`
${diff.path ?? "diff"}${diff.staged ? "staged" : "unstaged"}${diff.truncated ? " · truncated" : ""}
@@ -128,6 +129,14 @@ function renderDiffSection(diff: GitDiffResponse): TemplateResult { `; } +function loadCodeViewer(): void { + void import("../../components/CodeViewer"); +} + +function loadTerminalPanel(): void { + void import("../../components/TerminalPanel"); +} + function gitSummary(status: GitStatusResponse): string { const branch = status.branch ?? "detached"; const ahead = status.ahead ?? 0; diff --git a/vite.config.ts b/vite.config.ts index 31b2c01..3320d22 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -5,6 +5,18 @@ export default defineConfig({ build: { outDir: "../../dist/client", emptyOutDir: true, + rollupOptions: { + output: { + manualChunks(id) { + if (!id.includes("node_modules")) return; + if (id.includes("@codemirror/legacy-modes")) return "vendor-editor-legacy"; + if (id.includes("@lezer/common") || id.includes("@lezer/highlight") || id.includes("@lezer/lr")) return "vendor-editor-core"; + if (id.includes("@codemirror/lang-") || id.includes("@lezer/")) return "vendor-editor-languages"; + if (id.includes("@codemirror") || id.includes("codemirror")) return "vendor-editor-core"; + if (id.includes("@xterm")) return "vendor-terminal"; + }, + }, + }, }, server: { port: 5173,