Skip to content

Build your personal knowledge base with Trilium Notes

build: adapt the native build pipeline to better-sqlite3 v13

Elian Doran039b85ddd496
diff --git a/apps/build-docs/scripts/build.ts b/apps/build-docs/scripts/build.ts
index 79fa01f3f6..7a50373142 100644
--- a/apps/build-docs/scripts/build.ts
+++ b/apps/build-docs/scripts/build.ts
@@ -17,7 +17,7 @@ async function main() {
build.copy("src/index.html", "index.html");
// Copy node modules dependencies if needed
- build.copyNodeModules([ "better-sqlite3", "bindings", "file-uri-to-path" ]);
+ build.copyNodeModules([ "better-sqlite3" ]);
}
main();
diff --git a/apps/desktop/package.json b/apps/desktop/package.json
index b31ce00f30..51614914ca 100644
--- a/apps/desktop/package.json
+++ b/apps/desktop/package.json
@@ -52,7 +52,6 @@
"electron": "42.7.1",
"gifenc": "1.0.3",
"node-mocks-http": "1.18.1",
- "pngjs": "7.0.0",
- "prebuild-install": "7.1.3"
+ "pngjs": "7.0.0"
}
}
\ No newline at end of file
diff --git a/apps/desktop/scripts/build.ts b/apps/desktop/scripts/build.ts
index 33abdbc4d5..46de8ba4bf 100644
--- a/apps/desktop/scripts/build.ts
+++ b/apps/desktop/scripts/build.ts
@@ -23,7 +23,7 @@ async function main() {
build.copy("/packages/share-theme/src/templates", "share-theme/templates/");
// Copy node modules dependencies
- build.copyNodeModules([ "better-sqlite3", "bindings", "file-uri-to-path" ]);
+ build.copyNodeModules([ "better-sqlite3" ]);
build.copy("/node_modules/ckeditor5/dist/ckeditor5-content.css", "ckeditor5-content.css");
diff --git a/apps/edit-docs/scripts/build.ts b/apps/edit-docs/scripts/build.ts
index 002309bbb8..28a6a7998b 100644
--- a/apps/edit-docs/scripts/build.ts
+++ b/apps/edit-docs/scripts/build.ts
@@ -17,7 +17,7 @@ async function main() {
build.buildFrontend();
// Copy node modules dependencies
- build.copyNodeModules(["better-sqlite3", "bindings", "file-uri-to-path"]);
+ build.copyNodeModules(["better-sqlite3"]);
generatePackageJson();
}
diff --git a/apps/server/Dockerfile b/apps/server/Dockerfile
index d0bba38faf..3b51084c13 100644
--- a/apps/server/Dockerfile
+++ b/apps/server/Dockerfile
@@ -1,21 +1,12 @@
-FROM node:24.18.0-bullseye-slim AS builder
-RUN corepack enable
+# Since better-sqlite3 v13 the addon is N-API based and ships prebuilt binaries
+# for every supported platform/arch inside the package itself, which the server
+# build copies into ./dist. There is therefore no native compile step and no
+# builder stage any more. The Linux prebuilds need glibc >= 2.34 (x64) and
+# >= 2.38 (arm64), so the base image is trixie rather than bullseye (glibc 2.31).
+# Platforms without a prebuild (32-bit ARM) are served by Dockerfile.legacy,
+# which still compiles from source.
+FROM node:24.18.0-trixie-slim
-# Install build tools required to compile native addons (e.g. better-sqlite3) on ARM
-RUN apt-get update && \
- apt-get install -y --no-install-recommends \
- python3 \
- make \
- g++ && \
- rm -rf /var/lib/apt/lists/*
-
-# Install native dependencies since we might be building cross-platform.
-WORKDIR /usr/src/app/build
-COPY ./docker/package.json ./docker/pnpm-workspace.yaml /usr/src/app/
-# We have to use --no-frozen-lockfile due to CKEditor patches
-RUN pnpm install --no-frozen-lockfile --prod && pnpm rebuild
-
-FROM node:24.18.0-bullseye-slim
# Install only runtime dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
@@ -26,11 +17,9 @@ RUN apt-get update && \
WORKDIR /usr/src/app
COPY ./dist /usr/src/app
-RUN rm -rf /usr/src/app/node_modules/better-sqlite3
-COPY --from=builder /usr/src/app/node_modules/better-sqlite3 /usr/src/app/node_modules/better-sqlite3
COPY ./start-docker.sh /usr/src/app
# Configure container
EXPOSE 8080
CMD [ "sh", "./start-docker.sh" ]
-HEALTHCHECK --start-period=10s CMD exec gosu node node /usr/src/app/docker_healthcheck.cjs
\ No newline at end of file
+HEALTHCHECK --start-period=10s CMD exec gosu node node /usr/src/app/docker_healthcheck.cjs
diff --git a/apps/server/Dockerfile.alpine b/apps/server/Dockerfile.alpine
index 41cb0f8cae..c71d994ae3 100644
--- a/apps/server/Dockerfile.alpine
+++ b/apps/server/Dockerfile.alpine
@@ -2,26 +2,16 @@
# with libseccomp < 2.3.3 deny with EPERM instead of ENOSYS. musl only falls back on ENOSYS, so
# SQLite fails with "disk I/O error" there. Alpine 3.23 ships musl 1.2.5 and is supported until
# 2027-11-01. See https://github.com/TriliumNext/Trilium/issues/10627
-FROM node:24.18.0-alpine3.23 AS builder
-RUN corepack enable
-
-# Install build tools required to compile native addons (e.g. better-sqlite3) on ARM
-RUN apk add --no-cache python3 make g++
-
-# Install native dependencies since we might be building cross-platform.
-WORKDIR /usr/src/app
-COPY ./docker/package.json ./docker/pnpm-workspace.yaml /usr/src/app/
-# We have to use --no-frozen-lockfile due to CKEditor patches
-RUN pnpm install --no-frozen-lockfile --prod && pnpm rebuild
-
+#
+# See the comment in Dockerfile: better-sqlite3 v13 ships N-API prebuilds — the
+# linuxmusl-* ones here — so there is no native compile step and no builder
+# stage. They link libstdc++, which node:*-alpine already provides at runtime.
FROM node:24.18.0-alpine3.23
# Install runtime dependencies
RUN apk add --no-cache su-exec shadow
WORKDIR /usr/src/app
COPY ./dist /usr/src/app
-RUN rm -rf /usr/src/app/node_modules/better-sqlite3
-COPY --from=builder /usr/src/app/node_modules/better-sqlite3 /usr/src/app/node_modules/better-sqlite3
COPY ./start-docker.sh /usr/src/app
# Add application user
diff --git a/apps/server/Dockerfile.alpine.rootless b/apps/server/Dockerfile.alpine.rootless
index 6404af9944..797694cd29 100644
--- a/apps/server/Dockerfile.alpine.rootless
+++ b/apps/server/Dockerfile.alpine.rootless
@@ -1,15 +1,6 @@
-FROM node:24.18.0-alpine AS builder
-RUN corepack enable
-
-# Install build tools required to compile native addons (e.g. better-sqlite3) on ARM
-RUN apk add --no-cache python3 make g++
-
-# Install native dependencies since we might be building cross-platform.
-WORKDIR /usr/src/app
-COPY ./docker/package.json ./docker/pnpm-workspace.yaml /usr/src/app/
-# We have to use --no-frozen-lockfile due to CKEditor patches
-RUN pnpm install --no-frozen-lockfile --prod && pnpm rebuild
-
+# See the comment in Dockerfile: better-sqlite3 v13 ships N-API prebuilds — the
+# linuxmusl-* ones here — so there is no native compile step and no builder
+# stage. They link libstdc++, which node:*-alpine already provides at runtime.
FROM node:24.18.0-alpine
# Create a non-root user with configurable UID/GID
ARG USER=trilium
@@ -30,8 +21,6 @@ WORKDIR /home/${USER}/app
COPY ./dist /home/${USER}/app
# Also copy the rootless entrypoint script
COPY rootless-entrypoint.sh /home/${USER}/app/
-RUN rm -rf /home/${USER}/app/node_modules/better-sqlite3
-COPY --from=builder /usr/src/app/node_modules/better-sqlite3 /home/${USER}/app/node_modules/better-sqlite3
RUN chown -R ${USER}:${USER} /home/${USER}
# Configure container
diff --git a/apps/server/Dockerfile.legacy b/apps/server/Dockerfile.legacy
index 8f514c81cd..0ecede0b8e 100644
--- a/apps/server/Dockerfile.legacy
+++ b/apps/server/Dockerfile.legacy
@@ -9,6 +9,17 @@ RUN apt-get update && \
g++ && \
rm -rf /var/lib/apt/lists/*
+# Unlike the other images, this one cannot use better-sqlite3 v13's bundled
+# N-API prebuilds and must keep compiling from source:
+# - 32-bit ARM (linux/arm/v7) has no prebuild at all;
+# - linux/arm/v8 normalizes to arm64, whose prebuild needs glibc >= 2.38,
+# while this image stays on bullseye (glibc 2.31) to support old hosts.
+# Asking for it is not implicit: better-sqlite3's binding.gyp resolves both of
+# its targets to `type: none` whenever a prebuild for the host exists, so the
+# node-gyp run would emit a stamp file and no addon. force_build restores the
+# real compile and link rules.
+ENV npm_config_force_build=1
+
# Install native dependencies since we might be building cross-platform.
WORKDIR /usr/src/app/build
COPY ./docker/package.json ./docker/pnpm-workspace.yaml /usr/src/app/
diff --git a/apps/server/Dockerfile.rootless b/apps/server/Dockerfile.rootless
index eb2a6fa921..d449848555 100644
--- a/apps/server/Dockerfile.rootless
+++ b/apps/server/Dockerfile.rootless
@@ -1,21 +1,7 @@
-FROM node:24.18.0-bullseye-slim AS builder
-RUN corepack enable
-
-# Install build tools required to compile native addons (e.g. better-sqlite3) on ARM
-RUN apt-get update && \
- apt-get install -y --no-install-recommends \
- python3 \
- make \
- g++ && \
- rm -rf /var/lib/apt/lists/*
-
-# Install native dependencies since we might be building cross-platform.
-WORKDIR /usr/src/app/build
-COPY ./docker/package.json ./docker/pnpm-workspace.yaml /usr/src/app/
-# We have to use --no-frozen-lockfile due to CKEditor patches
-RUN pnpm install --no-frozen-lockfile --prod && pnpm rebuild
-
-FROM node:24.18.0-bullseye-slim
+# See the comment in Dockerfile: better-sqlite3 v13 ships N-API prebuilds, so
+# there is no native compile step and no builder stage, and the Linux prebuilds
+# need trixie's glibc rather than bullseye's.
+FROM node:24.18.0-trixie-slim
# Create a non-root user with configurable UID/GID
ARG USER=trilium
ARG UID=1001
@@ -36,8 +22,6 @@ WORKDIR /home/${USER}/app
COPY ./dist /home/${USER}/app
# Also copy the rootless entrypoint script
COPY rootless-entrypoint.sh /home/${USER}/app/
-RUN rm -rf /home/${USER}/app/node_modules/better-sqlite3
-COPY --from=builder /usr/src/app/node_modules/better-sqlite3 /home/${USER}/app/node_modules/better-sqlite3
RUN chown -R ${USER}:${USER} /home/${USER}
# Configure container
diff --git a/apps/server/scripts/build.ts b/apps/server/scripts/build.ts
index 988744ca8b..1b893823a0 100644
--- a/apps/server/scripts/build.ts
+++ b/apps/server/scripts/build.ts
@@ -17,7 +17,7 @@ async function main() {
build.copy("/packages/share-theme/src/templates", "share-theme/templates/");
// Copy node modules dependencies
- build.copyNodeModules([ "better-sqlite3", "bindings", "file-uri-to-path" ]);
+ build.copyNodeModules([ "better-sqlite3" ]);
build.copy("/node_modules/ckeditor5/dist/ckeditor5-content.css", "ckeditor5-content.css");
build.buildFrontend();
diff --git a/flake.nix b/flake.nix
index 65310a6df5..822875cef6 100644
--- a/flake.nix
+++ b/flake.nix
@@ -203,7 +203,7 @@ nodejs.python
makeShellWrapper
wrapGAppsHook3
- # For determining the Electron version to rebuild for:
+ # For the launcher wrapper generated in installCommands:
which
electron
]
@@ -279,16 +279,15 @@ nodejs.python
desktop = makeApp {
app = "desktop";
+ # better-sqlite3 v13 is N-API based and ships prebuilt binaries that
+ # load unchanged under Electron, so there is no native rebuild step
+ # (and no need for ELECTRON_NODEDIR) any more.
preBuildCommands = ''
- export ELECTRON_NODEDIR=${electron.headers}
pnpm postinstall
'';
buildTask = "desktop:build";
mainProgram = "trilium";
installCommands = ''
- #remove-references-to -t ${electron.headers} apps/desktop/dist/node_modules/better-sqlite3/build/config.gypi
- #remove-references-to -t ${nodejs.python} apps/desktop/dist/node_modules/better-sqlite3/build/config.gypi
-
mkdir -p $out/{bin,share/icons/hicolor/512x512/apps,opt/trilium}
cp --archive apps/desktop/dist/* $out/opt/trilium
cp apps/client/src/assets/icon.png $out/share/icons/hicolor/512x512/apps/trilium.png
@@ -338,15 +337,11 @@ nodejs.python
edit-docs = makeApp {
app = "edit-docs";
preBuildCommands = ''
- export ELECTRON_NODEDIR=${electron.headers}
pnpm postinstall
'';
buildTask = "edit-docs:build";
mainProgram = "trilium-edit-docs";
installCommands = ''
- #remove-references-to -t ${electron.headers} apps/edit-docs/dist/node_modules/better-sqlite3/build/config.gypi
- #remove-references-to -t ${nodejs.python} apps/edit-docs/dist/node_modules/better-sqlite3/build/config.gypi
-
mkdir -p $out/{bin,opt/trilium-edit-docs}
cp --archive apps/edit-docs/dist/* $out/opt/trilium-edit-docs
makeShellWrapper ${lib.getExe electron} $out/bin/trilium-edit-docs \
diff --git a/package.json b/package.json
index c79843f346..d7b3f8cdf1 100644
--- a/package.json
+++ b/package.json
@@ -47,13 +47,12 @@
"dev:format-fix": "eslint -c eslint.format.config.mjs . --fix",
"dev:linter-check": "cross-env NODE_OPTIONS=--max_old_space_size=4096 eslint .",
"dev:linter-fix": "cross-env NODE_OPTIONS=--max_old_space_size=4096 eslint . --fix",
- "postinstall": "tsx scripts/electron-rebuild.mts && pnpm prepare",
+ "postinstall": "pnpm prepare",
"prepare": "pnpm run --filter pdfjs-viewer --filter share-theme build && pnpm run --filter web-clipper postinstall",
"update-contributors": "tsx ./scripts/update-contributors.ts"
},
"private": true,
"devDependencies": {
- "@electron/rebuild": "4.2.0",
"@fast-csv/parse": "5.0.7",
"@playwright/test": "1.61.1",
"@triliumnext/server": "workspace:*",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 32b9fb07c3..0c63370d21 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -92,9 +92,6 @@ importers:
.:
devDependencies:
- '@electron/rebuild':
- specifier: 4.2.0
- version: 4.2.0([email protected])
'@fast-csv/parse':
specifier: 5.0.7
version: 5.0.7
@@ -513,9 +510,6 @@ importers:
pngjs:
specifier: 7.0.0
version: 7.0.0
- prebuild-install:
- specifier: 7.1.3
- version: 7.1.3
apps/dump-db:
dependencies:
@@ -2653,11 +2647,6 @@ packages:
engines: {node: '>=12.13.0'}
hasBin: true
- '@electron/[email protected]':
- resolution: {integrity: sha512-RKL/O+jGoXJMxrx/5771y1n0xTKmFuOYGO3gMmwypBM6rsH0kou0mswwdXA2JrhIkE4xyC7v9vGk0n6NPzgOxQ==}
- engines: {node: '>=22.12.0'}
- hasBin: true
-
'@electron/[email protected]':
resolution: {integrity: sha512-Wn9sPYIVFRFl5HmwMJkARCCf7rqK/EurkfQ/rJZ14mHP3iYTjZSIOSVonEAnhWeAXwtw7zOekGRlc6yTtZ0t+g==}
engines: {node: '>=16.4'}
@@ -6705,10 +6694,6 @@ packages:
resolution: {integrity: sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==}
- resolution: {integrity: sha512-a1wflyaL0tHtJSmLSOVybYhy22vRih4eduhhrkcjgrWGnRfrZtovJ2FRjxuTtkkj47O/baf0R86QU5OuYpz8fA==}
- engines: {node: ^20.17.0 || >=22.9.0}
-
resolution: {integrity: sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==}
engines: {node: '>=6.5'}
@@ -7437,9 +7422,6 @@ packages:
resolution: {integrity: sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==}
engines: {node: '>= 20.19.0'}
- resolution: {integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==}
-
resolution: {integrity: sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==}
engines: {node: '>=10'}
@@ -8736,10 +8718,6 @@ packages:
resolution: {integrity: sha512-c2bQfLNbMzLPmzQuOr8fy0csy84WmwnER81W88DzTp9CYNPJ6yzOj2EZAh9pywYpqHnshVLHQJ8WzldAyfY+Iw==}
- resolution: {integrity: sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==}
- engines: {node: '>=6'}
-
resolution: {integrity: sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA==}
engines: {node: '>=12.0.0'}
@@ -9162,9 +9140,6 @@ packages:
resolution: {integrity: sha512-GvHTWcykIR/fP8cj8dMpuMMkvaeJfPvYnhq0oW+chSeIr+ldX21ifU2Ms6KBoyKZQZmVaUAAhQ2EZ68KJF8a7A==}
hasBin: true
- resolution: {integrity: sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==}
-
resolution: {integrity: sha512-IaOQ9puYtjrkq7Y0Ygl9KDZnrf/aiUJYUpVf89y8kyaxbRG7Y1SrX/jaumrv81vc61+kiMempujsM3Yw7w5qcw==}
@@ -10869,9 +10844,6 @@ packages:
resolution: {integrity: sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==}
- resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==}
-
resolution: {integrity: sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==}
hasBin: true
@@ -10957,9 +10929,6 @@ packages:
resolution: {integrity: sha512-XPUa/jz+P1oJvN9VBxw4L9MtdFfaH3DAryqPssqhb2kXjmb9npz0dly6rCsgFWOPr4Yg9mTfM3MDZgZZ+7A3lA==}
engines: {node: ^20.0.0 || >=22.0.0}
- resolution: {integrity: sha512-GEbrYkbfF7MoNaoh2iGG84Mnf/WZfB0GdGEsM8wz7Expx/LlWf5U8t9nvJKXSp3qr5IsEbK04cBGhol/KwOsWA==}
-
resolution: {integrity: sha512-U1PllBuzW5d1gfan+88L+Hky2eZx+9gv3Pf6rNBxKbORxi7boHzqiA6QFGSnqMem4j0A9tZ08NMIs5+0m/VS1Q==}
engines: {node: '>=16.0.0'}
@@ -11024,11 +10993,6 @@ packages:
resolution: {integrity: sha512-LarFH0+6VfriEhqMMcLX2F7SwSXeWwnEAJEsYm5QKWchiVYVvJyV9v7UDvUv+w5HO23ZpQTXDv/GxdDdMyOuoQ==}
engines: {node: '>= 6.13.0'}
- resolution: {integrity: sha512-QNcUWM+HgJplcPzBvFBZ9VXacyGZ4+VTOb80PwWR+TlVzoHbRKULNEzpRsnaoxG3Wzr7Qh7BYxGDU3CbKib2Yg==}
- engines: {node: ^20.17.0 || >=22.9.0}
- hasBin: true
-
resolution: {integrity: sha512-qIsTMOY4C/dAa5Q5vsobRpOOvPfC4pB61UVW2uSwZNUp0QU/jCekTal1vMmbO0DgdHeLUJpv/ARmDqErVxA3Sg==}
@@ -11062,11 +11026,6 @@ packages:
engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0}
hasBin: true
- resolution: {integrity: sha512-Zhq3a+yFKrYwSBluL4H9XP3m3y5uvQkB/09CwDruCiRmR/UJYnn9W4R48ry0uGC70aeTPKLynBtscP9efFFcPw==}
- engines: {node: ^20.17.0 || >=22.9.0}
- hasBin: true
-
resolution: {integrity: sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==}
@@ -11603,12 +11562,6 @@ packages:
preact-render-to-string:
optional: true
- resolution: {integrity: sha512-8Mf2cbV7x1cXPUILADGI3wuhfqWvtiLA1iclTDbFRZkgRQS0NqsPZphna9V+HyTEadheuPmjaJMsbzKQFOzLug==}
- engines: {node: '>=10'}
- deprecated: No longer maintained. Please contact the author of the relevant native addon; alternatives are available.
- hasBin: true
-
resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==}
engines: {node: '>= 0.8.0'}
@@ -11622,10 +11575,6 @@ packages:
resolution: {integrity: sha512-Kcmo2FhfDTXdcbfDH76N7uBYHINxc/8GW7UAVuVP9I+Va3uHSerrnKV6dLooga/gh7GlgzuCCr/eoldnL1muGw==}
engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0}
- resolution: {integrity: sha512-iG+GYldRf2BQ0UDUAd6JQ/RwzaQy6mXmsk/IzlYyal4A4SNFw54MeH4/tLkF4I5WoWG9SQwuqWzS99jaFQHBuQ==}
- engines: {node: ^20.17.0 || >=22.9.0}
-
resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==}
@@ -12362,12 +12311,6 @@ packages:
resolution: {integrity: sha512-MB4pQmETUBlNs62BBeRjIFGeuy/x6gGKh7+eRUemn1rCFhqo7K+4slPqsyizCbcbYLnaYqaoZ2FWsZ/jN06D8w==}
- resolution: {integrity: sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==}
-
- resolution: {integrity: sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==}
-
resolution: {integrity: sha512-mz9VXphOxQWX3eQ/uXCtm6upltoN0DLx8Zb5T4TFC4FHB7S9FDPGre8CfLWqPWQQH/GrQYd2AXhhVM5LDpYx6Q==}
engines: {node: '>=20.12.2'}
@@ -12744,9 +12687,6 @@ packages:
resolution: {integrity: sha512-uxc/zpqFg6x7C8vOE7lh6Lbda8eEL9zmVm/PLeTPBRhh1xCgdWaQ+J1CUieGpIfm2HdtsUpRv+HshiasBMcc6A==}
engines: {node: '>=6'}
- resolution: {integrity: sha512-mDAjwmZdh7LTT6pNleZ05Yt65HC3E+NiQzl672vQG38jIrehtJk/J3mNwIg+vShQPcLF/LV7CMnDW6vjj6sfYQ==}
-
resolution: {integrity: sha512-/hU4AXnIdZu+Gvl1pk0oI5f5HxWsCJRtY2aFaJdk9VvyL48DWU6iU5WAIPG+wIi1YvWA6eTJvIviP/tMAZZNwQ==}
@@ -12980,9 +12920,6 @@ packages:
engines: {node: '>=18.0.0'}
hasBin: true
- resolution: {integrity: sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==}
-
resolution: {integrity: sha512-lR5VHmkPhzdhrM092lI2nACsLO4QubF0/yoOhzX7c+wIpbN1GjHNzCc91QlpxBi+cnx8vVJ+Ur6vL5cEoQPFpQ==}
@@ -15892,17 +15829,6 @@ snapshots:
- bluebird
- supports-color
- dependencies:
- '@malept/cross-spawn-promise': 2.0.0
- debug: 4.4.3([email protected])
- node-abi: 4.33.0
- node-api-version: 0.2.1
- node-gyp: 12.3.0
- read-binary-file-arch: 1.0.6([email protected])
- transitivePeerDependencies:
- - supports-color
-
dependencies:
'@electron/asar': 3.4.1
@@ -20806,8 +20732,6 @@ snapshots:
-
dependencies:
event-target-shim: 5.0.1
@@ -21641,8 +21565,6 @@ snapshots:
dependencies:
readdirp: 5.0.0
-
@@ -23283,8 +23205,6 @@ snapshots:
-
@@ -23821,8 +23741,6 @@ snapshots:
-
@@ -25781,8 +25699,6 @@ snapshots:
-
dependencies:
minimist: 1.2.8
@@ -25861,8 +25777,6 @@ snapshots:
-
dependencies:
'@ionic/utils-fs': 3.1.7([email protected])
@@ -25922,19 +25836,6 @@ snapshots:
- dependencies:
- env-paths: 2.2.1
- exponential-backoff: 3.1.3
- graceful-fs: 4.2.11
- nopt: 9.0.0
- proc-log: 6.1.0
- semver: 7.8.5
- tar: 7.5.15
- tinyglobby: 0.2.17
- undici: 6.27.0
- which: 6.0.1
-
dependencies:
css-select: 5.2.2
@@ -25977,10 +25878,6 @@ snapshots:
dependencies:
abbrev: 1.1.1
- dependencies:
- abbrev: 4.0.0
-
dependencies:
hosted-git-info: 2.8.9
@@ -26538,29 +26435,12 @@ snapshots:
optionalDependencies:
preact-render-to-string: 6.7.0([email protected])
- dependencies:
- detect-libc: 2.1.2
- expand-template: 2.0.3
- github-from-package: 0.0.0
- minimist: 1.2.8
- mkdirp-classic: 0.5.3
- napi-build-utils: 2.0.0
- node-abi: 4.33.0
- pump: 3.0.4
- rc: 1.2.8
- simple-get: 4.0.1
- tar-fs: 2.1.4
- tunnel-agent: 0.6.0
-
-
@@ -27494,14 +27374,6 @@ snapshots:
dependencies:
kolorist: 1.8.0
-
- dependencies:
- decompress-response: 6.0.0
- once: 1.4.0
- simple-concat: 1.0.1
-
@@ -27967,13 +27839,6 @@ snapshots:
- dependencies:
- chownr: 1.1.4
- mkdirp-classic: 0.5.3
- pump: 3.0.4
- tar-stream: 2.2.0
-
dependencies:
pump: 3.0.4
@@ -28203,10 +28068,6 @@ snapshots:
optionalDependencies:
fsevents: 2.3.3
- dependencies:
- safe-buffer: 5.2.1
-
dependencies:
zustand: 4.5.7([email protected])
diff --git a/scripts/electron-rebuild.mts b/scripts/electron-rebuild.mts
deleted file mode 100644
index 059a6a4a85..0000000000
--- a/scripts/electron-rebuild.mts
+++ /dev/null
@@ -1,88 +0,0 @@
-import { join, resolve } from "path";
-import { cpSync, existsSync, mkdirSync, readFileSync, rmSync } from "fs";
-import { execSync } from "child_process";
-import { rebuild } from "@electron/rebuild"
-import { isNixOS } from "./utils.mjs";
-
-const workspaceRoot = join(import.meta.dirname, "..");
-
-// On NixOS, re-execute this script inside `nix develop` to get access to Python and other build tools.
-// Skip this if we're already inside a nix shell or a nix build (NIX_BUILD_TOP is set during `nix build`).
-if (isNixOS() && !process.env.IN_NIX_SHELL && !process.env.NIX_BUILD_TOP) {
- console.log("Detected NixOS, re-running electron-rebuild inside 'nix develop'...");
- try {
- execSync("nix develop -c pnpm exec tsx scripts/electron-rebuild.mts", {
- cwd: workspaceRoot,
- stdio: "inherit",
- env: { ...process.env, IN_NIX_SHELL: "1" }
- });
- process.exit(0);
- } catch (e) {
- console.error("Failed to run electron-rebuild inside 'nix develop'.");
- process.exit(1);
- }
-}
-
-function copyNativeDependencies(projectRoot: string) {
- const destPath = join(projectRoot, "node_modules/better-sqlite3");
-
- if (existsSync(destPath)) {
- rmSync(destPath, { recursive: true });
- }
- mkdirSync(destPath, { recursive: true });
-
- const sourcePath = join(workspaceRoot, "node_modules/better-sqlite3");
- if (!existsSync(sourcePath)) {
- console.warn("Nothing to rebuild as source path is missing:", sourcePath);
- console.info("For CI builds with filtered package installs, this is normal. For normal development, it's not.");
- process.exit(0);
- }
- cpSync(sourcePath, destPath, { recursive: true, dereference: true });
-}
-
-async function rebuildNativeDependencies(projectRoot: string) {
- const electronVersion = determineElectronVersion(projectRoot);
-
- if (!electronVersion) {
- console.error("Unable to determine Electron version.");
- process.exit(1);
- }
-
- const targetArch = process.env.TARGET_ARCH || process.arch;
- console.log(`Rebuilding ${projectRoot} with ${electronVersion} for ${targetArch}...`);
-
- const resolvedPath = resolve(projectRoot);
-
- // Inside a Nix build, @electron/rebuild tries to download Electron headers
- // from the internet which fails in the sandbox. Use node-gyp directly with
- // the pre-fetched headers provided via ELECTRON_NODEDIR instead.
- const nodedir = process.env.ELECTRON_NODEDIR;
- if (process.env.NIX_BUILD_TOP && nodedir) {
- const betterSqlite3 = join(resolvedPath, "node_modules/better-sqlite3");
- console.log(`Nix build detected, running node-gyp directly for ${betterSqlite3}...`);
- execSync(
- `node-gyp rebuild --release --target=${electronVersion} --arch=${targetArch} --nodedir=${nodedir}`,
- { cwd: betterSqlite3, stdio: "inherit" }
- );
- return;
- }
-
- await rebuild({
- projectRootPath: resolvedPath,
- buildPath: resolvedPath,
- electronVersion,
- arch: targetArch,
- force: true
- });
-}
-
-function determineElectronVersion(projectRoot: string) {
- const packageJson = JSON.parse(readFileSync(join(projectRoot, "package.json"), "utf-8"));
- console.log("Using Electron version from package.json");
- return packageJson.devDependencies.electron;
-}
-
-for (const projectRoot of [ "apps/desktop", "apps/edit-docs" ]) {
- copyNativeDependencies(projectRoot);
- await rebuildNativeDependencies(projectRoot);
-}
diff --git a/scripts/electron-start.mts b/scripts/electron-start.mts
index 26258e0810..b0270f1f1e 100644
--- a/scripts/electron-start.mts
+++ b/scripts/electron-start.mts
@@ -28,7 +28,11 @@ execSync(`${getElectronPath()} ${args.join(" ")} --no-sandbox`, {
NODE_ENV: "development",
TRILIUM_ENV: "dev",
TRILIUM_RESOURCE_DIR: "../server/src",
- BETTERSQLITE3_NATIVE_PATH: "node_modules/better-sqlite3/build/Release/better_sqlite3.node",
+ // No BETTERSQLITE3_NATIVE_PATH: since better-sqlite3 v13 the addon is
+ // N-API based and ships prebuilt binaries for every supported
+ // platform/arch, which load unchanged under Electron. Its own resolver
+ // picks prebuilds/<platform>-<arch>.node, so there is no Electron-
+ // specific build in build/Release/ to point at any more.
LD_LIBRARY_PATH
}
});