Skip to content

Build your personal knowledge base with Trilium Notes

perf(client): drop the spreadsheet modules from the commons barrel

Elian Doran3a4aed57bc69
diff --git a/apps/client/src/print.tsx b/apps/client/src/print.tsx
index 4459e1d555..8ac7f24ba6 100644
--- a/apps/client/src/print.tsx
+++ b/apps/client/src/print.tsx
@@ -1,4 +1,3 @@
-import { renderSpreadsheetToHtml } from "@triliumnext/commons";
import { render } from "preact";
import { useCallback, useLayoutEffect, useRef } from "preact/hooks";
@@ -103,6 +102,7 @@ export function SingleNoteRenderer({ note, onReady }: RendererProps) {
if (note.type === "spreadsheet") {
// Render spreadsheet as HTML tables instead of an image.
+ const { renderSpreadsheetToHtml } = await import("@triliumnext/commons/src/lib/spreadsheet/render_to_html");
const blob = await note.getBlob();
const html = renderSpreadsheetToHtml(blob?.content ?? "");
container.innerHTML = html;
diff --git a/apps/server/src/share/content_renderer.ts b/apps/server/src/share/content_renderer.ts
index 555f6769af..d65a4c9d65 100644
--- a/apps/server/src/share/content_renderer.ts
+++ b/apps/server/src/share/content_renderer.ts
@@ -1,4 +1,5 @@
-import { extractYouTubeVideoId, renderSpreadsheetToHtml, renderToHtml as renderMarkdownToHtml } from "@triliumnext/commons";
+import { extractYouTubeVideoId, renderToHtml as renderMarkdownToHtml } from "@triliumnext/commons";
+import { renderSpreadsheetToHtml } from "@triliumnext/commons/src/lib/spreadsheet/render_to_html.js";
import { type BAttachment, type BBranch, becca, BNote, getLog, icon_packs as iconPackService, options, sanitize, task_states, utils } from "@triliumnext/core";
import { highlightAuto } from "@triliumnext/highlightjs";
import ejs from "ejs";
diff --git a/packages/commons/src/index.ts b/packages/commons/src/index.ts
index a3a12f0574..d34578f038 100644
--- a/packages/commons/src/index.ts
+++ b/packages/commons/src/index.ts
@@ -16,8 +16,9 @@ export * from "./lib/dayjs.js";
export * from "./lib/notes.js";
export * from "./lib/week_utils.js";
export { default as BUILTIN_ATTRIBUTES } from "./lib/builtin_attributes.js";
-export * from "./lib/spreadsheet/extract_text.js";
-export * from "./lib/spreadsheet/render_to_html.js";
+// The spreadsheet modules are deliberately not re-exported here: they pull in numfmt, and the
+// barrel is imported by virtually every client module. Import them via their subpath instead,
+// e.g. "@triliumnext/commons/src/lib/spreadsheet/render_to_html".
export * from "./lib/electron_api_interface.js";
export * from "./lib/link_embed.js";
export * from "./lib/llm_api.js";
diff --git a/packages/trilium-core/src/services/search/expressions/note_content_fulltext_preprocessor.ts b/packages/trilium-core/src/services/search/expressions/note_content_fulltext_preprocessor.ts
index dd48594700..61560846c5 100644
--- a/packages/trilium-core/src/services/search/expressions/note_content_fulltext_preprocessor.ts
+++ b/packages/trilium-core/src/services/search/expressions/note_content_fulltext_preprocessor.ts
@@ -1,4 +1,4 @@
-import { extractSpreadsheetText } from "@triliumnext/commons";
+import { extractSpreadsheetText } from "@triliumnext/commons/src/lib/spreadsheet/extract_text.js";
import striptags from "striptags";
import { normalizeSearchText } from "../utils/text_utils";
import { normalize } from "../../utils/index";