From 62b5fb998e187bb96def58182de7d0df0d36e2d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ullrich=20Sch=C3=A4fer?= Date: Wed, 25 Mar 2026 01:41:33 +0100 Subject: [PATCH] Fix planner production server + use .ts extensions everywhere MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix createRequestHandler → createRequestListener (@react-router/node removed the old API) - Move noEmit + allowImportingTsExtensions to tsconfig.base.json so all packages and apps inherit them consistently - Add explicit .ts extensions to all remaining relative imports across packages and apps Verified locally: node --experimental-strip-types server.ts starts and responds 200. Co-Authored-By: Claude Opus 4.6 (1M context) --- apps/journal/tsconfig.json | 2 -- apps/planner/app/lib/host-election.test.ts | 2 +- apps/planner/app/lib/rate-limit.test.ts | 2 +- apps/planner/app/lib/use-routing.ts | 4 ++-- apps/planner/server.ts | 13 +++++-------- apps/planner/tsconfig.json | 2 -- apps/planner/vite.config.ts | 2 +- packages/db/src/index.ts | 4 ++-- packages/gpx/src/generate.test.ts | 4 ++-- packages/gpx/src/generate.ts | 2 +- packages/gpx/src/index.ts | 6 +++--- packages/gpx/src/parse.test.ts | 2 +- packages/gpx/src/parse.ts | 2 +- packages/i18n/src/index.ts | 4 ++-- packages/map/src/index.ts | 12 ++++++------ packages/types/src/index.test.ts | 2 +- packages/ui/src/index.ts | 12 ++++++------ tsconfig.base.json | 4 +++- 18 files changed, 38 insertions(+), 43 deletions(-) diff --git a/apps/journal/tsconfig.json b/apps/journal/tsconfig.json index 0aab76e..3972ec5 100644 --- a/apps/journal/tsconfig.json +++ b/apps/journal/tsconfig.json @@ -8,8 +8,6 @@ "exclude": ["build", "node_modules"], "compilerOptions": { "rootDirs": [".", "./.react-router/types"], - "noEmit": true, - "allowImportingTsExtensions": true, "types": ["vite/client"], "paths": { "~/*": ["./app/*"] diff --git a/apps/planner/app/lib/host-election.test.ts b/apps/planner/app/lib/host-election.test.ts index 3467f04..4e7ec32 100644 --- a/apps/planner/app/lib/host-election.test.ts +++ b/apps/planner/app/lib/host-election.test.ts @@ -1,5 +1,5 @@ import { describe, it, expect } from "vitest"; -import { electHost } from "./host-election"; +import { electHost } from "./host-election.ts"; function makeStates( entries: Array<{ id: number; user?: boolean; role?: string }>, diff --git a/apps/planner/app/lib/rate-limit.test.ts b/apps/planner/app/lib/rate-limit.test.ts index a4ec910..4dba7fa 100644 --- a/apps/planner/app/lib/rate-limit.test.ts +++ b/apps/planner/app/lib/rate-limit.test.ts @@ -1,5 +1,5 @@ import { describe, it, expect } from "vitest"; -import { checkRateLimit } from "./rate-limit"; +import { checkRateLimit } from "./rate-limit.ts"; describe("checkRateLimit", () => { it("allows requests within limit", () => { diff --git a/apps/planner/app/lib/use-routing.ts b/apps/planner/app/lib/use-routing.ts index 227c967..88c2efa 100644 --- a/apps/planner/app/lib/use-routing.ts +++ b/apps/planner/app/lib/use-routing.ts @@ -1,7 +1,7 @@ import { useCallback, useEffect, useRef, useState } from "react"; import * as Y from "yjs"; -import type { YjsState } from "./use-yjs"; -import { electHost } from "./host-election"; +import type { YjsState } from "./use-yjs.ts"; +import { electHost } from "./host-election.ts"; interface RouteStats { distance?: number; diff --git a/apps/planner/server.ts b/apps/planner/server.ts index 4ef1758..097ddad 100644 --- a/apps/planner/server.ts +++ b/apps/planner/server.ts @@ -1,18 +1,15 @@ -import { createRequestHandler } from "@react-router/node"; +import { createRequestListener } from "@react-router/node"; import { createServer } from "node:http"; import { setupYjsWebSocket } from "./app/lib/yjs-server.ts"; const port = Number(process.env.PORT ?? 3001); -const handler = createRequestHandler( - // @ts-expect-error - build output types - await import("./build/server/index.js"), -); - -const server = createServer((req, res) => { - handler(req, res); +const listener = createRequestListener({ + build: () => import("./build/server/index.js") as never, }); +const server = createServer(listener); + setupYjsWebSocket(server); server.listen(port, () => { diff --git a/apps/planner/tsconfig.json b/apps/planner/tsconfig.json index 5cd30e8..09fed20 100644 --- a/apps/planner/tsconfig.json +++ b/apps/planner/tsconfig.json @@ -8,8 +8,6 @@ "exclude": ["build", "node_modules", "server.ts"], "compilerOptions": { "rootDirs": [".", "./.react-router/types"], - "noEmit": true, - "allowImportingTsExtensions": true, "types": ["vite/client"], "paths": { "~/*": ["./app/*"] diff --git a/apps/planner/vite.config.ts b/apps/planner/vite.config.ts index 311be5a..760df32 100644 --- a/apps/planner/vite.config.ts +++ b/apps/planner/vite.config.ts @@ -2,7 +2,7 @@ import { reactRouter } from "@react-router/dev/vite"; import tailwindcss from "@tailwindcss/vite"; import { defineConfig } from "vite"; import path from "node:path"; -import { yjsDevPlugin } from "./app/lib/vite-yjs-plugin"; +import { yjsDevPlugin } from "./app/lib/vite-yjs-plugin.ts"; export default defineConfig({ plugins: [tailwindcss(), reactRouter(), yjsDevPlugin()], diff --git a/packages/db/src/index.ts b/packages/db/src/index.ts index 5d5e6b8..8141386 100644 --- a/packages/db/src/index.ts +++ b/packages/db/src/index.ts @@ -1,7 +1,7 @@ import { drizzle } from "drizzle-orm/postgres-js"; import postgres from "postgres"; -import * as plannerSchema from "./schema/planner"; -import * as journalSchema from "./schema/journal"; +import * as plannerSchema from "./schema/planner.ts"; +import * as journalSchema from "./schema/journal.ts"; export function createDb(connectionString?: string) { const client = postgres( diff --git a/packages/gpx/src/generate.test.ts b/packages/gpx/src/generate.test.ts index c4e1a5b..6b4fd34 100644 --- a/packages/gpx/src/generate.test.ts +++ b/packages/gpx/src/generate.test.ts @@ -1,6 +1,6 @@ import { describe, it, expect } from "vitest"; -import { generateGpx } from "./generate"; -import { parseGpx } from "./parse"; +import { generateGpx } from "./generate.ts"; +import { parseGpx } from "./parse.ts"; describe("generateGpx", () => { it("generates valid GPX with name", () => { diff --git a/packages/gpx/src/generate.ts b/packages/gpx/src/generate.ts index 1bfcd8c..d0f0268 100644 --- a/packages/gpx/src/generate.ts +++ b/packages/gpx/src/generate.ts @@ -1,5 +1,5 @@ import type { Waypoint } from "@trails-cool/types"; -import type { TrackPoint } from "./types"; +import type { TrackPoint } from "./types.ts"; /** * Generate a GPX XML string from waypoints and track points. diff --git a/packages/gpx/src/index.ts b/packages/gpx/src/index.ts index 46ec02a..edc7f3d 100644 --- a/packages/gpx/src/index.ts +++ b/packages/gpx/src/index.ts @@ -1,3 +1,3 @@ -export { parseGpx, parseGpxAsync } from "./parse"; -export { generateGpx } from "./generate"; -export type { GpxData, TrackPoint, ElevationProfile } from "./types"; +export { parseGpx, parseGpxAsync } from "./parse.ts"; +export { generateGpx } from "./generate.ts"; +export type { GpxData, TrackPoint, ElevationProfile } from "./types.ts"; diff --git a/packages/gpx/src/parse.test.ts b/packages/gpx/src/parse.test.ts index dd31b56..f38ac8b 100644 --- a/packages/gpx/src/parse.test.ts +++ b/packages/gpx/src/parse.test.ts @@ -1,5 +1,5 @@ import { describe, it, expect } from "vitest"; -import { parseGpx } from "./parse"; +import { parseGpx } from "./parse.ts"; const sampleGpx = ` diff --git a/packages/gpx/src/parse.ts b/packages/gpx/src/parse.ts index b9cb5dc..d1b118b 100644 --- a/packages/gpx/src/parse.ts +++ b/packages/gpx/src/parse.ts @@ -1,5 +1,5 @@ import type { Waypoint } from "@trails-cool/types"; -import type { GpxData, TrackPoint, ElevationProfile } from "./types"; +import type { GpxData, TrackPoint, ElevationProfile } from "./types.ts"; /** * Parse a GPX XML string into structured data. diff --git a/packages/i18n/src/index.ts b/packages/i18n/src/index.ts index 8b069b6..807b0d9 100644 --- a/packages/i18n/src/index.ts +++ b/packages/i18n/src/index.ts @@ -1,8 +1,8 @@ import i18n from "i18next"; import { initReactI18next } from "react-i18next"; import LanguageDetector from "i18next-browser-languagedetector"; -import en from "./locales/en"; -import de from "./locales/de"; +import en from "./locales/en.ts"; +import de from "./locales/de.ts"; export const defaultNS = "common"; diff --git a/packages/map/src/index.ts b/packages/map/src/index.ts index a297f36..4e91e78 100644 --- a/packages/map/src/index.ts +++ b/packages/map/src/index.ts @@ -1,6 +1,6 @@ -export { MapView } from "./MapView"; -export type { MapViewProps } from "./MapView"; -export { RouteLayer } from "./RouteLayer"; -export type { RouteLayerProps } from "./RouteLayer"; -export { baseLayers } from "./layers"; -export type { TileLayerConfig } from "./layers"; +export { MapView } from "./MapView.tsx"; +export type { MapViewProps } from "./MapView.tsx"; +export { RouteLayer } from "./RouteLayer.tsx"; +export type { RouteLayerProps } from "./RouteLayer.tsx"; +export { baseLayers } from "./layers.ts"; +export type { TileLayerConfig } from "./layers.ts"; diff --git a/packages/types/src/index.test.ts b/packages/types/src/index.test.ts index 3578f0d..1a263db 100644 --- a/packages/types/src/index.test.ts +++ b/packages/types/src/index.test.ts @@ -1,5 +1,5 @@ import { describe, it, expect } from "vitest"; -import type { Waypoint, Route } from "./index"; +import type { Waypoint, Route } from "./index.ts"; describe("types", () => { it("Waypoint type accepts valid data", () => { diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts index e75bcca..b68472e 100644 --- a/packages/ui/src/index.ts +++ b/packages/ui/src/index.ts @@ -1,6 +1,6 @@ -export { Button } from "./Button"; -export type { ButtonProps } from "./Button"; -export { Input } from "./Input"; -export type { InputProps } from "./Input"; -export { Card } from "./Card"; -export type { CardProps } from "./Card"; +export { Button } from "./Button.tsx"; +export type { ButtonProps } from "./Button.tsx"; +export { Input } from "./Input.tsx"; +export type { InputProps } from "./Input.tsx"; +export { Card } from "./Card.tsx"; +export type { CardProps } from "./Card.tsx"; diff --git a/tsconfig.base.json b/tsconfig.base.json index 59163d2..ece6172 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -14,7 +14,9 @@ "declaration": true, "declarationMap": true, "sourceMap": true, - "noUncheckedIndexedAccess": true + "noUncheckedIndexedAccess": true, + "noEmit": true, + "allowImportingTsExtensions": true }, "exclude": ["node_modules", "build", "dist"] }