trilium/apps/edit-docs/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
..
build.ts build: ship only the better-sqlite3 files an artifact actually uses 2026-07-25 18:07:02 +03:00