Skip to content

Build your personal knowledge base with Trilium Notes

chore(server/esbuild): switch to cjs to embed deps

Elian Doran1abf1d3f60d5
diff --git a/apps/server/package.json b/apps/server/package.json
index 02282c7191..3f2d5f9ac2 100644
--- a/apps/server/package.json
+++ b/apps/server/package.json
@@ -114,21 +114,12 @@
"targets": {
"serve": {
"executor": "@nx/js:node",
- "defaultConfiguration": "development",
"dependsOn": [
"build-without-client"
],
"options": {
- "buildTarget": "server:build",
+ "buildTarget": "server:build-without-client:development",
"runBuildTargetDependencies": false
- },
- "configurations": {
- "development": {
- "buildTarget": "server:build-without-client"
- },
- "production": {
- "buildTarget": "server:build:production"
- }
}
},
"package": {
@@ -141,7 +132,7 @@
"dependsOn": [
"build"
],
- "command": "node apps/server/dist/main.js"
+ "command": "node apps/server/dist/main.cjs"
},
"docker-build": {
"dependsOn": [
@@ -190,10 +181,12 @@
"platform": "node",
"external": [
"electron",
- "@electron/remote"
+ "@electron/remote",
+ "better-sqlite3",
+ "jsdom"
],
"format": [
- "esm"
+ "cjs"
],
"declarationRootDir": "apps/server/src"
},
@@ -264,6 +257,5 @@
},
"types": "./dist/main.d.ts",
"module": "./dist/main.js",
- "type": "module",
"main": "./dist/main.js"
}
diff --git a/apps/server/src/routes/assets.ts b/apps/server/src/routes/assets.ts
index 850847a111..710feeb7a8 100644
--- a/apps/server/src/routes/assets.ts
+++ b/apps/server/src/routes/assets.ts
@@ -1,6 +1,5 @@
import { assetUrlFragment } from "../services/asset_path.js";
import path from "path";
-import { fileURLToPath } from "url";
import express from "express";
import { getResourceDir, isDev } from "../services/utils.js";
import type serveStatic from "serve-static";
@@ -18,7 +17,7 @@ const persistentCacheStatic = (root: string, options?: serveStatic.ServeStaticOp
};
async function register(app: express.Application) {
- const srcRoot = path.join(path.dirname(fileURLToPath(import.meta.url)), "..");
+ const srcRoot = path.join(__dirname, "..");
const resourceDir = getResourceDir();
if (isDev) {
diff --git a/apps/server/src/services/i18n.ts b/apps/server/src/services/i18n.ts
index 8e033bbf4b..e4488ef062 100644
--- a/apps/server/src/services/i18n.ts
+++ b/apps/server/src/services/i18n.ts
@@ -16,7 +16,7 @@ let dayjsLocale: string;
export async function initializeTranslations() {
const resourceDir = getResourceDir();
- const Backend = (await import("i18next-fs-backend")).default;
+ const Backend = (await import("i18next-fs-backend/cjs")).default;
const locale = getCurrentLanguage();
// Initialize translations