trilium/scripts
Elian Doran fd7ee39963
build: ship only the better-sqlite3 files an artifact actually uses
Since v13 the package bundles a prebuilt binary for all eight platforms
it supports (~17 MB) on top of the SQLite amalgamation needed to compile
from scratch (~10 MB). A packaged artifact loads exactly one binary and
never compiles, so all of that but ~2 MB was dead weight:

  v0.104.1 (v12)   11.93 MB   deps/ + a compiled build/Release binary
  v13, untrimmed   27.0 MB    deps/ + eight prebuilds
  server, trimmed   4.5 MB    lib/ + linux-x64 + linuxmusl-x64
  desktop, trimmed  2.2 MB    lib/ + linux-x64

That is ~6 MB off each compressed Linux artifact, and leaves us below
what v0.104.1 shipped rather than 15 MB above it. lib/ plus one prebuild
is the complete runtime set -- verified by loading a copy pruned to just
those files and running a query against it.

Two things the trim has to get right, both covered:

Linux keeps the musl build alongside the glibc one. The server's dist is
produced once on a glibc runner and then consumed by both the Debian and
the Alpine images, and better-sqlite3 resolves linuxmusl-* at runtime on
the latter, so dropping it would break the amd64 image at startup. The
Electron artifacts opt out, since Electron ships no musl builds.

The platform and architecture are the ones being built *for*, not the
host's: the macOS runners are arm64 and also package darwin-x64, so
trimming by host arch would strip the binary that build needs.
TARGET_ARCH / MATRIX_ARCH already carry the target in CI.

An unsupported platform/arch throws rather than silently producing an
artifact with no native addon.

Also drops the better-sqlite3 cleanup from flake.nix's server install
phase: it removed deps/sqlite3 and the build/ scaffolding that held
build-time store paths, all of which the build now trims itself.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-25 18:07:02 +03:00
..
icon-packs feat(icon-pack-builder): integrate boxicons 3 with brands 2025-12-28 22:53:03 +02:00
icons feat(mobile/ios): add trilium icon 2026-04-22 14:43:10 +03:00
repo-migration chore(scripts): add proper typechecking 2025-12-08 14:13:18 +02:00
translation chore(scripts): improve messages for translation check script 2026-02-06 19:38:24 +02:00
analyze-perf.ts Revert "chore(scripts): remove analyze-perf" 2026-01-11 10:55:47 +02:00
build-portable-better-sqlite3.sh build(ci): rebuild better-sqlite3 against an older glibc for Linux releases 2026-07-25 17:59:19 +03:00
build-utils.ts build: ship only the better-sqlite3 files an artifact actually uses 2026-07-25 18:07:02 +03:00
check-version-consistency.ts fix(ci): sanity check does not account for version prefix 2026-03-01 17:43:41 +02:00
electron-run-prod.mts fix(desktop): make start-prod launch Electron correctly on NixOS 2026-07-18 13:29:30 +03:00
electron-start.mts build: adapt the native build pipeline to better-sqlite3 v13 2026-07-25 17:09:31 +03:00
filter-tsc-output.mts chore(scripts): integrate filter-tsc-output from standalone branch 2026-04-01 16:39:54 +03:00
generate-openapi.ts feat(views/geomap): remove old geo map type 2025-07-06 20:23:50 +03:00
tsconfig.json chore(scripts): fix typecheck issue 2026-01-04 23:38:51 +02:00
update-build-info.ts fix(scripts): update build info no longer updating 2026-04-07 16:00:44 +03:00
update-contributors.ts contributor list: update script name, change a comment 2026-04-19 18:33:35 +03:00
update-nightly-version.ts refactor(standalone): rename project from client-standalone 2026-05-16 08:57:55 +03:00
update-version.ts refactor(standalone): rename project from client-standalone 2026-05-16 08:57:55 +03:00
utils.mts fix(desktop): make start-prod launch Electron correctly on NixOS 2026-07-18 13:29:30 +03:00
wipe-node-modules.mts chore(scripts): add a way to wipe node modules 2026-03-26 11:27:46 +02:00