From c6e5589a685bd7f43da9a505a22a5ce509c9047a Mon Sep 17 00:00:00 2001 From: andresgutgon Date: Thu, 4 Sep 2025 19:56:42 +0200 Subject: [PATCH 1/5] Improve typescript performance --- .gitignore | 5 +++++ apps/web/tsconfig.json | 11 ++++------- apps/web/tsconfig.workers.json | 7 +++---- packages/core/tsconfig.json | 1 + 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 0f52687f64..7a5d291d0c 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ coverage # Turbo .turbo .tsbuildinfo +tsconfig.tsbuildinfo # Vim shit *.py-E @@ -60,7 +61,9 @@ apps/web/scripts-dist # File uploads in development apps/web/uploads apps/web/public/uploads +apps/web/public/storage uploads +storage # Temporal tmp @@ -89,4 +92,6 @@ __testing__ # New spans apps/web/ingest apps/workers/workspaces/*/traces +apps/web/tsc-tracing +*.tsbuildinfo diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.json index d7e6ea18ec..5e3e66acee 100644 --- a/apps/web/tsconfig.json +++ b/apps/web/tsconfig.json @@ -7,12 +7,11 @@ } ], "incremental": true, - "tsBuildInfoFile": ".tsbuildinfo", + "noEmit": true, "moduleResolution": "Bundler", "jsx": "preserve", - "typeRoots": [ - "./node_modules/@types" - ], + "skipLibCheck": true, + "types": ["node"], "baseUrl": ".", "paths": { "$/*": [ @@ -24,9 +23,7 @@ "./src/**/*.test.ts", "./src/**/*.ts", "./src/**/*.tsx", - "next-env.d.ts", - "next.config.js", - ".next/types/**/*.ts" + "next-env.d.ts" ], "exclude": [ "node_modules", diff --git a/apps/web/tsconfig.workers.json b/apps/web/tsconfig.workers.json index 985b8f663f..dd713a71e6 100644 --- a/apps/web/tsconfig.workers.json +++ b/apps/web/tsconfig.workers.json @@ -5,13 +5,12 @@ "module": "es2022", "noEmit": false, "moduleResolution": "Bundler", - "jsx": "preserve", - "typeRoots": ["./node_modules/@types"], + "skipLibCheck": true, "baseUrl": ".", "paths": { "$/*": ["./src/workers/*"], - "@latitude-data/constants": ["../../packages/constants/src/index.ts"], - "@latitude-data/constants/*": ["../../packages/constants/src/*"] + "@latitude-data/constants": ["../../packages/constants"], + "@latitude-data/constants/*": ["../../packages/constants/*"] } }, "include": ["./src/workers/**/*.ts"], diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json index 8104bb2c7a..b9ad1833df 100644 --- a/packages/core/tsconfig.json +++ b/packages/core/tsconfig.json @@ -1,6 +1,7 @@ { "extends": "@latitude-data/typescript-config/base.json", "compilerOptions": { + "noEmit": true, "moduleResolution": "Bundler", "jsx": "preserve" }, From 5da258ec45536d7a8189268437e623d3a058fc76 Mon Sep 17 00:00:00 2001 From: andresgutgon Date: Thu, 4 Sep 2025 20:17:48 +0200 Subject: [PATCH 2/5] feat: wip --- apps/web/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.json index 5e3e66acee..826c35c431 100644 --- a/apps/web/tsconfig.json +++ b/apps/web/tsconfig.json @@ -11,7 +11,7 @@ "moduleResolution": "Bundler", "jsx": "preserve", "skipLibCheck": true, - "types": ["node"], + "types": [], "baseUrl": ".", "paths": { "$/*": [ From aad56f7d274a28eecdd0d4e9fa22c94d6085726a Mon Sep 17 00:00:00 2001 From: andresgutgon Date: Thu, 4 Sep 2025 20:25:52 +0200 Subject: [PATCH 3/5] feat: wip --- packages/core/tsconfig.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json index b9ad1833df..cbdf8afd69 100644 --- a/packages/core/tsconfig.json +++ b/packages/core/tsconfig.json @@ -2,6 +2,8 @@ "extends": "@latitude-data/typescript-config/base.json", "compilerOptions": { "noEmit": true, + "incremental": true, + "tsBuildInfoFile": "node_modules/.cache/core.tsbuildinfo", "moduleResolution": "Bundler", "jsx": "preserve" }, From f32afc985e1c592ac1bcaea18e7a308e993e8c31 Mon Sep 17 00:00:00 2001 From: andresgutgon Date: Thu, 4 Sep 2025 20:47:24 +0200 Subject: [PATCH 4/5] WIP --- package.json | 3 ++- packages/constants/tsconfig.json | 4 +++- packages/env/tsconfig.json | 4 +++- packages/telemetry/typescript/tsconfig.json | 2 ++ packages/web-ui/tsconfig.json | 4 +++- tsconfig.json | 17 +++++++++++++++++ 6 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 tsconfig.json diff --git a/package.json b/package.json index 3935a45bbc..f0b834f5b8 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "watch:buildExamples": "chokidar 'examples/src/**/*' -c 'pnpm buildExamples'", "mintlify_docs": "cd docs && mintlify dev", "latitudeDocs": "pnpm buildExamples && concurrently \"pnpm watch:buildExamples\" \"pnpm mintlify_docs\"", - "tc": "turbo tc", + "tc": "tsc -b", + "tc:turbo": "turbo tc", "prettier": "prettier --write \"{apps,packages}/**/*.{ts,tsx,md}\" --ignore-path .prettierrcignore", "prettier:check": "prettier --check \"**/*.{ts,tsx,md}\" --ignore-path .prettierrcignore", "test": "turbo test", diff --git a/packages/constants/tsconfig.json b/packages/constants/tsconfig.json index 18d15be0a6..d3cbe77a82 100644 --- a/packages/constants/tsconfig.json +++ b/packages/constants/tsconfig.json @@ -2,7 +2,9 @@ "extends": "@latitude-data/typescript-config/base.json", "compilerOptions": { "moduleResolution": "Bundler", - "rootDir": "./src" + "rootDir": "./src", + "incremental": true, + "tsBuildInfoFile": "node_modules/.cache/tsconfig.tsbuildinfo" }, "include": ["src/**/*"], "exclude": ["node_modules"] diff --git a/packages/env/tsconfig.json b/packages/env/tsconfig.json index 18d15be0a6..d3cbe77a82 100644 --- a/packages/env/tsconfig.json +++ b/packages/env/tsconfig.json @@ -2,7 +2,9 @@ "extends": "@latitude-data/typescript-config/base.json", "compilerOptions": { "moduleResolution": "Bundler", - "rootDir": "./src" + "rootDir": "./src", + "incremental": true, + "tsBuildInfoFile": "node_modules/.cache/tsconfig.tsbuildinfo" }, "include": ["src/**/*"], "exclude": ["node_modules"] diff --git a/packages/telemetry/typescript/tsconfig.json b/packages/telemetry/typescript/tsconfig.json index 469df76a8b..87c19c740a 100644 --- a/packages/telemetry/typescript/tsconfig.json +++ b/packages/telemetry/typescript/tsconfig.json @@ -7,6 +7,8 @@ "outDir": "./dist", "rootDir": "../../", "baseUrl": ".", + "incremental": true, + "tsBuildInfoFile": "node_modules/.cache/tsconfig.tsbuildinfo", "paths": { "$telemetry/*": ["./src/*"], "@latitude-data/constants/*": ["../../constants/src/*"], diff --git a/packages/web-ui/tsconfig.json b/packages/web-ui/tsconfig.json index d7b6677089..94185eeced 100644 --- a/packages/web-ui/tsconfig.json +++ b/packages/web-ui/tsconfig.json @@ -4,7 +4,9 @@ "module": "ESNext", "moduleResolution": "Bundler", "types": ["node"], - "jsx": "preserve" + "jsx": "preserve", + "incremental": true, + "tsBuildInfoFile": "node_modules/.cache/tsconfig.tsbuildinfo" }, "include": ["src"], "exclude": ["node_modules", "dist"] diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000000..5796f3fc76 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,17 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "files": [], + "references": [ + { "path": "./packages/constants" }, + { "path": "./packages/env" }, + { "path": "./packages/telemetry/typescript" }, + { "path": "./packages/core" }, + { "path": "./packages/web-ui" }, + + { "path": "./apps/console" }, + { "path": "./apps/gateway" }, + { "path": "./apps/websockets" }, + { "path": "./apps/workers" }, + { "path": "./apps/web" } + ] +} From 51b57e2560e0ed15898182de09fd9c03ddd9e2d2 Mon Sep 17 00:00:00 2001 From: andresgutgon Date: Fri, 5 Sep 2025 20:47:30 +0200 Subject: [PATCH 5/5] WIP --- packages/telemetry/typescript/src/sdk/sdk.ts | 36 +++++++------------- 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/packages/telemetry/typescript/src/sdk/sdk.ts b/packages/telemetry/typescript/src/sdk/sdk.ts index 9874a23ab8..3909689685 100644 --- a/packages/telemetry/typescript/src/sdk/sdk.ts +++ b/packages/telemetry/typescript/src/sdk/sdk.ts @@ -52,21 +52,9 @@ import { VertexAIInstrumentation, } from '@traceloop/instrumentation-vertexai' -import type * as anthropic from '@anthropic-ai/sdk' -import type * as bedrock from '@aws-sdk/client-bedrock-runtime' -import type * as azure from '@azure/openai' -import type * as aiplatform from '@google-cloud/aiplatform' -import type * as vertexai from '@google-cloud/vertexai' import type * as langchain_runnables from '@langchain/core/runnables' import type * as langchain_vectorstores from '@langchain/core/vectorstores' import type * as latitude from '@latitude-data/sdk' -import type * as cohere from 'cohere-ai' -import type * as langchain_agents from 'langchain/agents' -import type * as langchain_chains from 'langchain/chains' -import type * as langchain_tools from 'langchain/tools' -import type * as llamaindex from 'llamaindex' -import type * as openai from 'openai' -import type * as togetherai from 'together-ai' const TRACES_URL = `${env.GATEWAY_BASE_URL}/api/v3/traces` const SERVICE_NAME = process.env.npm_package_name || 'unknown' @@ -122,23 +110,23 @@ export type TelemetryOptions = { [Instrumentation.Latitude]?: | typeof latitude.Latitude | LatitudeInstrumentationOptions - [Instrumentation.OpenAI]?: typeof openai.OpenAI - [Instrumentation.Anthropic]?: typeof anthropic - [Instrumentation.AzureOpenAI]?: typeof azure + [Instrumentation.OpenAI]?: typeof import('openai').OpenAI + [Instrumentation.Anthropic]?: import('@anthropic-ai/sdk').Anthropic + [Instrumentation.AzureOpenAI]?: typeof import('@azure/openai') [Instrumentation.VercelAI]?: 'manual' - [Instrumentation.VertexAI]?: typeof vertexai - [Instrumentation.AIPlatform]?: typeof aiplatform - [Instrumentation.Bedrock]?: typeof bedrock - [Instrumentation.TogetherAI]?: typeof togetherai.Together - [Instrumentation.Cohere]?: typeof cohere + [Instrumentation.VertexAI]?: import('@google-cloud/vertexai').VertexAI + [Instrumentation.AIPlatform]?: import('@google-cloud/aiplatform').v1.EndpointServiceClient + [Instrumentation.Bedrock]?: import('@aws-sdk/client-bedrock-runtime').BedrockRuntimeClient + [Instrumentation.TogetherAI]?: import('together-ai').default + [Instrumentation.Cohere]?: typeof import('cohere-ai').CohereClientV2 [Instrumentation.Langchain]?: { - chainsModule: typeof langchain_chains - agentsModule: typeof langchain_agents - toolsModule: typeof langchain_tools + chainsModule: import('langchain/chains').APIChain + agentsModule: import('langchain/agents').AgentExecutor + toolsModule: import('langchain/tools').Tool vectorStoreModule: typeof langchain_vectorstores runnablesModule: typeof langchain_runnables } - [Instrumentation.LlamaIndex]?: typeof llamaindex + [Instrumentation.LlamaIndex]?: import('llamaindex').OpenAI } disableBatch?: boolean exporter?: SpanExporter