Fix documentation build system - resolve becca module instance issue

Fixed the issue where multiple becca instances were being created due to inconsistent module import paths. The solution was to export becca from becca_loader and access it from there, ensuring a single instance is used throughout the build process.

Co-authored-by: eliandoran <21236836+eliandoran@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-11-02 22:18:49 +00:00
parent 01deab9c79
commit 0c6a57d3bb
89 changed files with 568 additions and 5 deletions

View File

@@ -20,6 +20,10 @@ async function buildDocsInner() {
const sqlInit = (await import("../../server/src/services/sql_init.js")).default;
await sqlInit.createInitialDatabase(true);
// Wait for becca to be loaded before importing data
const beccaLoader = await import("../../server/src/becca/becca_loader.js");
await beccaLoader.beccaLoaded;
const note = await importData(join(__dirname, DOCS_ROOT, "User Guide"));
@@ -51,11 +55,12 @@ async function buildDocsInner() {
export async function importData(path: string) {
const buffer = await createImportZip(path);
const importService = (await import("@triliumnext/server/src/services/import/zip.js")).default;
const TaskContext = (await import("@triliumnext/server/src/services/task_context.js")).default;
const importService = (await import("../../server/src/services/import/zip.js")).default;
const TaskContext = (await import("../../server/src/services/task_context.js")).default;
const context = new TaskContext("no-progress-reporting", "importNotes", null);
const becca = (await import("@triliumnext/server/src/becca/becca.js")).default;
const beccaLoader = (await import("../../server/src/becca/becca_loader.js")).default;
const becca = beccaLoader.becca;
const rootNote = becca.getRoot();
if (!rootNote) {
throw new Error("Missing root note for import.");