trails/apps/planner/app/lib
Ullrich Schäfer 10deae88c9
fix: extensionless server-side imports + lint rule to catch them
## Symptom

Grafana's \`app-crash-log\` alert fires on every deploy. The Loki query
that backs it (\`ERR_|FATAL|uncaughtException|…\`) matches:

  Error [ERR_MODULE_NOT_FOUND]: Cannot find module
  '/app/apps/journal/app/lib/logger.server' imported from
  '/app/apps/journal/app/lib/email.server.ts'

A real bug, not a false positive: \`email.server.ts\` line 2 was
\`import { logger } from \"./logger.server\"\` — no extension.

## Why typecheck didn't catch it

\`tsconfig.base.json\` sets \`moduleResolution: \"bundler\"\`. The bundler
resolver accepts extensionless relative imports because Vite / esbuild
/ webpack resolve them at build time. TypeScript was happy.

Production runs \`node --experimental-strip-types server.ts\`, which
uses Node's NodeNext ESM resolver — strict about extensions. The two
resolvers disagree silently for files Node loads directly (server.ts,
\`.server.ts\` modules dynamically imported from it, and jobs).

## Fix

1. **Added \`.ts\` extensions to the 4 broken imports** I could find:
   - \`apps/journal/app/lib/email.server.ts\` → \`./logger.server.ts\`
     (the actual deploy-blocker)
   - \`apps/planner/app/lib/brouter.ts\` → \`./route-merge.ts\`, \`./http.server.ts\`
   - \`apps/planner/app/lib/use-nearby-pois.ts\` → \`./overpass.ts\`
   - \`packages/map/src/MapView.tsx\` → \`./layers.ts\` (caught by the rule)

2. **Added \`eslint-plugin-import-x\` with \`import-x/extensions: always\`**,
   scoped to files Node actually executes raw:
   - \`apps/*/server.ts\`
   - \`apps/*/app/lib/**/*.server.ts\`
   - \`apps/*/app/jobs/**/*.ts\`
   - \`packages/*/src/**/*.{ts,tsx}\`

   Ignored: route-scoped \`*.server.ts\` files (bundled by Vite into the
   React Router build, never loaded by Node), and test files (Vitest's
   own resolver).

## What's still possible

- Non-\`.server.ts\` files in \`app/lib\` (e.g. \`legal.ts\`, \`actor-iri.ts\`)
  could still ship extensionless imports. They're not in the lint
  scope. If one breaks at runtime we can extend the glob — for now
  they tend to be tiny utility modules that don't import other
  relatives.
- The deeper fix would be \`moduleResolution: nodenext\` for server-side
  tsconfig, or bundling the server code so Node never sees raw \`.ts\`.
  Bigger surgery; the lint rule covers the failure mode for now.

Full repo: pnpm typecheck / lint / test all green after \`pnpm install\`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-26 08:08:19 +02:00
..
__screenshots__/elevation-chart-draw.browser.test.tsx chore: update visual snapshots [skip ci] 2026-05-10 17:15:46 +00:00
brouter.test.ts fix(planner/brouter): cap upstream response size to 10MB 2026-05-26 00:48:45 +02:00
brouter.ts fix: extensionless server-side imports + lint rule to catch them 2026-05-26 08:08:19 +02:00
crash-recovery.test.ts Add transactional emails (SMTP) and planner features (no-go areas, notes, crash recovery) 2026-03-26 01:00:42 +01:00
db.ts Add Drizzle ORM with shared db package (#10) 2026-03-22 22:35:50 +00:00
elevation-chart-draw.browser.test.tsx Fix Vitest browser provider setup and test cleanup 2026-05-10 19:01:24 +02:00
elevation-chart-draw.ts Split ElevationChart + PlannerMap into deep modules; add visual regression testing 2026-05-10 16:41:23 +02:00
host-election.test.ts Fix planner production server + use .ts extensions everywhere 2026-03-25 01:41:33 +01:00
host-election.ts Fix waypoint drag, host election, segment routing, debug panel 2026-03-23 08:52:52 +01:00
http.server.test.ts fix(planner/brouter): add 30s timeout to outbound fetch 2026-05-25 23:53:19 +02:00
http.server.ts fix(planner/brouter): add 30s timeout to outbound fetch 2026-05-25 23:53:19 +02:00
logger.server.test.ts feat(planner): per-request requestId propagated through logs 2026-05-25 22:43:58 +02:00
logger.server.ts feat(planner): per-request requestId propagated through logs 2026-05-25 22:43:58 +02:00
metrics.server.ts Failover across multiple Overpass upstreams 2026-04-21 07:36:10 +02:00
overnight.test.ts Add per-day map coloring and remaining unit tests 2026-04-11 00:12:27 +02:00
overnight.ts Add multi-day data model, computeDays, and GPX roundtrip 2026-04-10 23:51:31 +02:00
overpass.server.ts Fix planner build: move Overpass upstream fetch to overpass.server.ts 2026-04-23 22:40:15 +02:00
overpass.test.ts Add per-waypoint notes and nearby POI snap to Planner 2026-05-17 23:58:21 +02:00
overpass.ts Add per-waypoint notes and nearby POI snap to Planner 2026-05-17 23:58:21 +02:00
poi-cache.test.ts Add i18n keys and unit tests for overlays 2026-04-11 01:19:27 +02:00
poi-cache.ts Add Overpass client, POI categories, cache, and usePois hook 2026-04-11 01:15:34 +02:00
poi-categories.test.ts Extract @trails-cool/map-core package from Planner 2026-04-12 22:28:14 +02:00
poi-snap.ts Extract @trails-cool/map-core package from Planner 2026-04-12 22:28:14 +02:00
rate-limit.test.ts Fix planner production server + use .ts extensions everywhere 2026-03-25 01:41:33 +01:00
rate-limit.ts Increase route rate limit from 60 to 300 requests/hour 2026-04-11 02:05:41 +02:00
require-session.test.ts Session-bind /api/route and /api/overpass 2026-04-21 22:18:45 +02:00
require-session.ts Session-bind /api/route and /api/overpass 2026-04-21 22:18:45 +02:00
route-merge.test.ts Cache BRouter segments client-side, fetch only the diff 2026-04-24 17:57:54 +02:00
route-merge.ts Cache BRouter segments client-side, fetch only the diff 2026-04-24 17:57:54 +02:00
segment-cache.test.ts Cache BRouter segments client-side, fetch only the diff 2026-04-24 17:57:54 +02:00
segment-cache.ts Cache BRouter segments client-side, fetch only the diff 2026-04-24 17:57:54 +02:00
sessions.ts fix(planner): bound /api/sessions listing (default 50, max 200) 2026-05-26 00:46:38 +02:00
snap-to-poi.test.ts Add per-waypoint notes and nearby POI snap to Planner 2026-05-17 23:58:21 +02:00
url-validation.server.test.ts fix(planner): validate callback/returnUrl + cap session URL-param payloads 2026-05-26 00:05:47 +02:00
url-validation.server.ts fix(planner): validate callback/returnUrl + cap session URL-param payloads 2026-05-26 00:05:47 +02:00
use-days.ts Add multi-day data model, computeDays, and GPX roundtrip 2026-04-10 23:51:31 +02:00
use-elevation-data.ts Split ElevationChart + PlannerMap into deep modules; add visual regression testing 2026-05-10 16:41:23 +02:00
use-gpx-drop.ts Centralize waypoint Yjs serialization in waypointFromYMap/waypointToYMap 2026-05-18 21:02:27 +02:00
use-host-election.ts Deepen three architectural seams: FIT consolidation, host election extraction, injectable db 2026-05-10 15:52:31 +02:00
use-nearby-pois.ts fix: extensionless server-side imports + lint rule to catch them 2026-05-26 08:08:19 +02:00
use-pois.ts Session-bind /api/route and /api/overpass 2026-04-21 22:18:45 +02:00
use-profile-defaults.ts Extract @trails-cool/map-core package from Planner 2026-04-12 22:28:14 +02:00
use-routing.ts Deepen three architectural seams: FIT consolidation, host election extraction, injectable db 2026-05-10 15:52:31 +02:00
use-undo.test.ts Add undo/redo to planner 2026-04-04 10:04:01 +01:00
use-undo.ts Add undo/redo to planner 2026-04-04 10:04:01 +01:00
use-waypoint-manager.ts Centralize waypoint Yjs serialization in waypointFromYMap/waypointToYMap 2026-05-18 21:02:27 +02:00
use-yjs-poi-sync.ts Add Yjs sync for POI categories across participants 2026-04-11 02:28:11 +02:00
use-yjs.ts chore(ts): drop two more redundant casts 2026-05-26 01:02:49 +02:00
vite-yjs-plugin.ts Fix waypoint drag, host election, segment routing, debug panel 2026-03-23 08:52:52 +01:00
waypoint-ymap.ts Centralize waypoint Yjs serialization in waypointFromYMap/waypointToYMap 2026-05-18 21:02:27 +02:00
yjs-server.test.ts fix(planner): cap per-WS-frame + per-session Yjs doc size 2026-05-26 00:13:01 +02:00
yjs-server.ts fix(planner): require session row before accepting Yjs WebSocket upgrade 2026-05-26 00:24:16 +02:00