From 5c5fff517c40b54875db7b56f68e15cca1f73b6c Mon Sep 17 00:00:00 2001 From: Philipinho <16838612+Philipinho@users.noreply.github.com> Date: Thu, 14 May 2026 18:05:39 +0100 Subject: [PATCH] fix code splitting --- .../components/excalidraw/excalidraw-menu-lazy.tsx | 14 ++++++++++++++ .../components/excalidraw/excalidraw-view-lazy.tsx | 14 ++++++++++++++ .../src/features/editor/extensions/extensions.ts | 2 +- apps/client/src/features/editor/page-editor.tsx | 2 +- apps/client/vite.config.ts | 10 +++++----- 5 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 apps/client/src/features/editor/components/excalidraw/excalidraw-menu-lazy.tsx create mode 100644 apps/client/src/features/editor/components/excalidraw/excalidraw-view-lazy.tsx diff --git a/apps/client/src/features/editor/components/excalidraw/excalidraw-menu-lazy.tsx b/apps/client/src/features/editor/components/excalidraw/excalidraw-menu-lazy.tsx new file mode 100644 index 000000000..acdf5440d --- /dev/null +++ b/apps/client/src/features/editor/components/excalidraw/excalidraw-menu-lazy.tsx @@ -0,0 +1,14 @@ +import { lazy, Suspense } from "react"; +import { EditorMenuProps } from "@/features/editor/components/table/types/types.ts"; + +const ExcalidrawMenu = lazy( + () => import("@/features/editor/components/excalidraw/excalidraw-menu.tsx"), +); + +export default function ExcalidrawMenuLazy(props: EditorMenuProps) { + return ( + + + + ); +} diff --git a/apps/client/src/features/editor/components/excalidraw/excalidraw-view-lazy.tsx b/apps/client/src/features/editor/components/excalidraw/excalidraw-view-lazy.tsx new file mode 100644 index 000000000..573a25dbd --- /dev/null +++ b/apps/client/src/features/editor/components/excalidraw/excalidraw-view-lazy.tsx @@ -0,0 +1,14 @@ +import { lazy, Suspense } from "react"; +import { NodeViewProps } from "@tiptap/react"; + +const ExcalidrawView = lazy( + () => import("@/features/editor/components/excalidraw/excalidraw-view.tsx"), +); + +export default function ExcalidrawViewLazy(props: NodeViewProps) { + return ( + + + + ); +} diff --git a/apps/client/src/features/editor/extensions/extensions.ts b/apps/client/src/features/editor/extensions/extensions.ts index 91411daef..9857b0551 100644 --- a/apps/client/src/features/editor/extensions/extensions.ts +++ b/apps/client/src/features/editor/extensions/extensions.ts @@ -85,7 +85,7 @@ import AudioView from "@/features/editor/components/audio/audio-view.tsx"; import AttachmentView from "@/features/editor/components/attachment/attachment-view.tsx"; import CodeBlockView from "@/features/editor/components/code-block/code-block-view.tsx"; import DrawioView from "../components/drawio/drawio-view"; -import ExcalidrawView from "@/features/editor/components/excalidraw/excalidraw-view.tsx"; +import ExcalidrawView from "@/features/editor/components/excalidraw/excalidraw-view-lazy.tsx"; import EmbedView from "@/features/editor/components/embed/embed-view.tsx"; import PdfView from "@/features/editor/components/pdf/pdf-view.tsx"; import SubpagesView from "@/features/editor/components/subpages/subpages-view.tsx"; diff --git a/apps/client/src/features/editor/page-editor.tsx b/apps/client/src/features/editor/page-editor.tsx index 9d53eec31..8521356ec 100644 --- a/apps/client/src/features/editor/page-editor.tsx +++ b/apps/client/src/features/editor/page-editor.tsx @@ -55,7 +55,7 @@ import { handleFileDrop, handlePaste, } from "@/features/editor/components/common/editor-paste-handler.tsx"; -import ExcalidrawMenu from "./components/excalidraw/excalidraw-menu"; +import ExcalidrawMenu from "./components/excalidraw/excalidraw-menu-lazy"; import DrawioMenu from "./components/drawio/drawio-menu"; import { useCollabToken } from "@/features/auth/queries/auth-query.tsx"; import SearchAndReplaceDialog from "@/features/editor/components/search-and-replace/search-and-replace-dialog.tsx"; diff --git a/apps/client/vite.config.ts b/apps/client/vite.config.ts index e6f9de48c..b230a29ff 100644 --- a/apps/client/vite.config.ts +++ b/apps/client/vite.config.ts @@ -38,12 +38,12 @@ export default defineConfig(({ mode }) => { build: { rolldownOptions: { output: { - codeSplitting: { + advancedChunks: { groups: [ - { name: "vendor-mantine", test: /@mantine/ }, - { name: "vendor-mermaid", test: /mermaid|cytoscape|elkjs/ }, - { name: "vendor-excalidraw", test: /excalidraw/ }, - { name: "vendor-katex", test: /katex/ }, + { + name: "vendor-mantine", + test: /[\\/]node_modules[\\/]@mantine[\\/]/, + }, ], }, },