Skip to content

Build your personal knowledge base with Trilium Notes

fix(script_deployer): Node.js imports not working

Elian Doran074edeefab99
diff --git a/apps/script-deployer/scripts/auto-import-rnote.ts b/apps/script-deployer/scripts/auto-import-rnote.ts
index 286b1a9429..32e364c024 100644
--- a/apps/script-deployer/scripts/auto-import-rnote.ts
+++ b/apps/script-deployer/scripts/auto-import-rnote.ts
@@ -8,7 +8,7 @@
* executeDescription: Converts all .rnote children of this note into Excalidraw canvas notes.
*/
-const zlib = require("zlib");
+import zlib from "zlib";
// ── Types (rnote v0.9+ / v0.13 JSON format) ────────────────────────────────
diff --git a/apps/script-deployer/scripts/auto-import-xopp.ts b/apps/script-deployer/scripts/auto-import-xopp.ts
index 6ac2cfd56e..b800f1d319 100644
--- a/apps/script-deployer/scripts/auto-import-xopp.ts
+++ b/apps/script-deployer/scripts/auto-import-xopp.ts
@@ -8,7 +8,7 @@
* executeDescription: Converts all .xopp children of this note into Excalidraw canvas notes.
*/
-const zlib = require("zlib");
+import zlib from "zlib";
// ── Color mapping ────────────────────────────────────────────────────────────
@@ -104,7 +104,7 @@ function text(node: Record<string, unknown>): string {
function children(node: Record<string, unknown>, tag: string): Record<string, unknown>[] {
const val = node[tag];
if (!val) return [];
- return Array.isArray(val) ? val : [val];
+ return Array.isArray(val) ? val : [val as Record<string, unknown>];
}
// ── Converters ───────────────────────────────────────────────────────────────
diff --git a/apps/script-deployer/src/deploy.ts b/apps/script-deployer/src/deploy.ts
index 862f7ba8f6..704c59a2f5 100644
--- a/apps/script-deployer/src/deploy.ts
+++ b/apps/script-deployer/src/deploy.ts
@@ -85,10 +85,12 @@ export function transpile(source: string, filePath: string): string {
const ext = extname(filePath);
if (!TRANSPILE_EXTS.has(ext)) return source;
+ const isBackend = ext === ".ts";
const result = transformSync(source, {
loader: ext === ".tsx" ? "tsx" : "ts",
jsx: "preserve",
sourcemap: false,
+ ...(isBackend && { format: "cjs" }),
});
return result.code;
}