Compile the API instead of running its TypeScript in production.
The unit's ExecStart named src/index.ts, so every start depended on the host having Node 22.18 or newer for native type stripping. A deploy onto a host with Node 20 met ERR_UNKNOWN_FILE_EXTENSION, exited in under a second, and was restarted 464 times over fifteen hours with nothing anywhere going red. api/tsconfig.json now emits to api/dist. The source keeps its explicit .ts import specifiers, which is what makes `node --watch src/index.ts` work in development; rewriteRelativeImportExtensions turns them into .js on the way out, so what runs in production is ordinary ESM that any Node from 20.18 up will start. `pnpm build` builds shared, then api, then web. `pnpm dev` is unchanged. deploy/ is tracked rather than ignored: the unit files are the thing an operator copies to /etc/systemd/system, and the alert unit added next has to live somewhere a deploy can find it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
06ba3d35e7
commit
65307ba278
+2
-1
@@ -4,8 +4,9 @@
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "tsc -p tsconfig.json",
|
||||
"dev": "node --env-file-if-exists=../.env --watch src/index.ts",
|
||||
"start": "node --env-file-if-exists=../.env src/index.ts",
|
||||
"start": "node --env-file-if-exists=../.env dist/index.js",
|
||||
"seed": "node --env-file-if-exists=../.env src/seed.ts",
|
||||
"migrate": "node --env-file-if-exists=../.env src/migrate.ts",
|
||||
"typecheck": "tsc -p tsconfig.json --noEmit",
|
||||
|
||||
+16
-1
@@ -7,7 +7,22 @@
|
||||
"strict": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"noImplicitOverride": true,
|
||||
"noEmit": true,
|
||||
/*
|
||||
* This project is compiled now, rather than run straight off `src/*.ts`.
|
||||
*
|
||||
* The reason is a fifteen-hour crash loop: the unit's ExecStart named `src/index.ts`,
|
||||
* the host's `/usr/bin/node` was 20, and native type stripping is 22.18 and newer, so
|
||||
* every start died on ERR_UNKNOWN_FILE_EXTENSION and systemd restarted it 464 times
|
||||
* without anything going red. Emitting plain `.js` removes the host's Node version
|
||||
* from the set of things that can break a deploy.
|
||||
*
|
||||
* `rewriteRelativeImportExtensions` is what lets the source keep its explicit `.ts`
|
||||
* specifiers — which is what makes `node --watch src/index.ts` work in development —
|
||||
* while the emitted files import `./config.js` and run anywhere.
|
||||
*/
|
||||
"outDir": "dist",
|
||||
"rootDir": "src",
|
||||
"sourceMap": true,
|
||||
"allowImportingTsExtensions": true,
|
||||
"rewriteRelativeImportExtensions": true,
|
||||
"skipLibCheck": true,
|
||||
|
||||
Reference in New Issue
Block a user