Skip to content

Commit c5e06b9

Browse files
committed
fix: lazy-load openapi-ts in mobility-formats so apps/api doesn't ship the TypeScript compiler
`@hey-api/openapi-ts` is a build-time SDK generator that imports the TypeScript compiler at module load. Importing it eagerly from `tomp.ts` made every transitive consumer of @openmapx/mobility-formats pull in `typescript`, including the apps/api esbuild bundle (which packs all `@openmapx/*` workspace deps). Production app-api containers crashed at startup with `ERR_MODULE_NOT_FOUND: Cannot find package 'typescript'` because typescript is a devDependency. Move the import into `generateTompSdk`, the only call site, so it stays out of the runtime bundle.
1 parent 5b5136d commit c5e06b9

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

packages/mobility-formats/tomp.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import { mkdir } from "node:fs/promises";
22
import { basename } from "node:path";
33
import { isDeepStrictEqual } from "node:util";
4-
import { createClient as generateOpenApiClient } from "@hey-api/openapi-ts";
54
import { dereference, sanitize, validate } from "@scalar/openapi-parser";
65
import YAML from "yaml";
76

7+
// `@hey-api/openapi-ts` is a build-time SDK generator that pulls in the full
8+
// TypeScript compiler. Importing it eagerly inflates downstream bundles
9+
// (apps/api ships dist/server.js via esbuild) and forces every transitive
10+
// consumer of this package to keep `typescript` as a runtime dependency.
11+
// `generateTompSdk` is the only caller, so load it lazily there.
12+
813
const TOMP_HTTP_METHODS = [
914
"delete",
1015
"get",
@@ -468,6 +473,7 @@ export async function generateTompSdk(options: GenerateTompSdkOptions): Promise<
468473
{ client: "@hey-api/client-fetch", name: "@hey-api/sdk" },
469474
];
470475

476+
const { createClient: generateOpenApiClient } = await import("@hey-api/openapi-ts");
471477
await generateOpenApiClient({
472478
input: document as never,
473479
output: options.outputPath,

0 commit comments

Comments
 (0)