Status: Accepted (2026-11-28, O1). Amends 0001 (“there is no library build step”): it still holds for dev, tests and the web app.
Packages export TypeScript source, and Node 26 strips types at load time (ADR 0001). The stripper is a WebAssembly module instantiated per isolate on the first .ts file. That costs ~28 MiB RSS per isolate: an empty script measured 49 MiB as .js and 77 MiB as .ts. The realtime process runs one isolate per gateway thread and per owner thread (ADR 0020), so it pays this cost 8 times on Linux. Memory efficiency is a top priority (overview.md).
npm run build:server (deploy/build.mjs) runs tsc -p tsconfig.build.json, the TypeScript 7 compiler that is already installed, so there is no new dependency. It is emit only: noCheck, ESNext target, comments removed, and rewriteRelativeImportExtensions on. It compiles the src/ dirs of shared, doc, sync-client, server-common, api, realtime, docworker and mcp into dist/, keeping the repo layout.new URL('./x.ts', import.meta.url) worker URLs to .js;.ts;dist/<ws>/package.json with exports pointing at .js, and dist/node_modules/@linorahq/* links to the compiled packages;db/migrations and the doc fonts.npm run start:* run node --no-strip-types dist/apps/<tier>/src/main.js. With stripping disabled, a stray .ts is a startup error, not a silent 28 MiB.npm run dev:*), tests and benches keep running .ts directly. Typechecking stays npm run typecheck, per package.npm run build includes build:server, so the CONTRIBUTING gate and CI build it on every change.Linux, idle RSS from src to dist, medians of 3 ABBA runs (deploy/measure-rss.mjs; full tables in docs/ops/build.md):
| Tier | src | dist |
|---|---|---|
| api | 107 MiB | 68 MiB |
| realtime (5 gateways + 2 owners) | 330 MiB | 196 MiB |
| docworker | 107 MiB | 69 MiB |
| compactor | 108 MiB | 70 MiB |
| mcp | 119 MiB | 88 MiB |
import.meta.resolve('@linorahq/doc') for fonts and the migrations path would all need special handling. It also loses the 1:1 file mapping that makes stack traces readable without source maps.exports in each package: for example, a production condition pointing at dist. That edits every package manifest, which other packages own, and needs --conditions everywhere..ts in production and accepting the RSS: rejected; it adds about 134 MiB per realtime instance.new URL('./x.ts', import.meta.url) shape, which the build rewrites and verifies.RUNTIME_FILES in deploy/build.mjs.