πͺ’ Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
chore(web): Avoid eslint heap issues (#19492)
Ben Bachemabb2f0280796
diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.ymlindex 78aed6c937..9a7fc3a6b5 100644--- a/.github/workflows/pipeline.yml+++ b/.github/workflows/pipeline.yml@@ -294,10 +294,10 @@ jobs:run: |cp .env.dev.example .env- name: lint web- # Three packages with four ESLint workers leave headroom on 16 vCPUs.- run: pnpm turbo run lint --filter=!ai-gateway --filter=!@langfuse/native --concurrency=3 -- --concurrency=4- # Rust packages lint with cargo, which rejects the trailing ESLint flag- # above, so they run outside that invocation (ai-gateway in its own job).+ # Respect package-level worker limits: web's typed linting duplicates+ # its TypeScript project state in each worker.+ run: pnpm turbo run lint --filter=!ai-gateway --filter=!@langfuse/native --concurrency=3+ # Rust packages lint separately (ai-gateway in its own job).- name: lint native addon (rustfmt, clippy)run: pnpm --filter @langfuse/native run lint- name: Install Rust dependency checkersdiff --git a/packages/icons/README.md b/packages/icons/README.mdindex eb60679664..cb692f6270 100644--- a/packages/icons/README.md+++ b/packages/icons/README.md@@ -53,7 +53,7 @@ These props deliberately bypass the design-system constraints. They can overrideThe root exports all Lucide icons and their aliases. `/si` exports Simple Icons; `/tb` exports Tabler icons. All exports are static, with pure wrapper calls and `sideEffects: false`, so unused icons can be tree-shaken. There is no runtime namespace lookup or icon registry.-Each icon wrapper lives in its own JavaScript file under `dist/generated/`, with a matching `.d.ts` declaration; aliases share the same wrapper. `dist/index.js`, `dist/si.js`, and `dist/tb.js` re-export those wrappers, preserving the public imports. TypeScript compiles the shared `src/create-icon.tsx` implementation and emits its declarations, so all generated icons use the same inferred component contract. The entire `dist/` directory is generated and gitignored. Setup generates the exports automatically. Turbo runs generation before package tests, typechecking, and dependent builds, and caches the generated files. The setup hook skips manifest-only Docker install layers; the subsequent build generates the files once source is available.+Each icon wrapper lives in its own JavaScript file under `dist/generated/`; aliases share the same wrapper. `dist/index.js`, `dist/si.js`, and `dist/tb.js` re-export those wrappers, preserving the public imports. Types are consolidated in `dist/index.d.ts`, `dist/si.d.ts`, and `dist/tb.d.ts` so TypeScript does not need to load a declaration module per icon. TypeScript compiles the shared `src/create-icon.tsx` implementation and emits its declarations, so all generated icons use the same inferred component contract. The entire `dist/` directory is generated and gitignored. Setup generates the exports automatically. Turbo runs generation before package tests, typechecking, and dependent builds, and caches the generated files. The setup hook skips manifest-only Docker install layers; the subsequent build generates the files once source is available.After updating the upstream libraries, regenerate and validate the exports:diff --git a/packages/icons/scripts/generate.cjs b/packages/icons/scripts/generate.cjsindex d40aa17332..05968e6ada 100644--- a/packages/icons/scripts/generate.cjs+++ b/packages/icons/scripts/generate.cjs@@ -12,7 +12,7 @@ for (const [entrypoint, library] of [`../dist/generated/${entrypoint}`,);fs.mkdirSync(outputDirectory, { recursive: true });- // Remove icons deleted or renamed by an upstream library update.+ // Remove stale icons and legacy per-icon declarations from earlier builds.for (const filename of fs.readdirSync(outputDirectory)) {if (filename.endsWith(".js") || filename.endsWith(".d.ts"))fs.unlinkSync(path.join(outputDirectory, filename));@@ -34,6 +34,11 @@ for (const [entrypoint, library] of [const lines = ["// Generated by pnpm --filter @langfuse/icons generate. Do not edit.",];+ // Keep declarations together so TypeScript need not load a module per icon.+ const declarations = [+ lines[0],+ 'import type { IconComponent } from "./create-icon.js";',+ ];for (const names of groups.values()) {const [name, ...aliases] = names;fs.writeFileSync(@@ -46,17 +51,16 @@ for (const [entrypoint, library] of ["",].join("\n"),);- fs.writeFileSync(- path.join(outputDirectory, `${name}.d.ts`),- [- lines[0],- 'import type { IconComponent } from "../../create-icon.js";',- `export declare const ${name}: IconComponent;`,- "",- ].join("\n"),- );+ const exports = [+ name,+ ...aliases.map((alias) => `${name} as ${alias}`),+ ].join(", ");lines.push(- `export { ${[name, ...aliases.map((alias) => `${name} as ${alias}`)].join(", ")} } from "./generated/${entrypoint}/${name}.js";`,+ `export { ${exports} } from "./generated/${entrypoint}/${name}.js";`,+ );+ declarations.push(+ `declare const ${name}: IconComponent;`,+ `export { ${exports} };`,);}fs.writeFileSync(@@ -66,7 +70,7 @@ for (const [entrypoint, library] of [fs.writeFileSync(path.join(__dirname, `../dist/${entrypoint}.d.ts`),[- ...lines,+ ...declarations,'export type { IconColor, IconComponent, IconProps, IconSize } from "./create-icon.js";',"",].join("\n"),diff --git a/packages/icons/tests/types.tsx b/packages/icons/tests/types.tsxindex 7157cab42d..e394816c38 100644--- a/packages/icons/tests/types.tsx+++ b/packages/icons/tests/types.tsx@@ -1,9 +1,10 @@import { createRef, type ComponentProps } from "react";-import { Search, type IconComponent } from "@langfuse/icons";+import { Search, SearchIcon, type IconComponent } from "@langfuse/icons";import { SiGithub } from "@langfuse/icons/si";import { TbBrandAzure } from "@langfuse/icons/tb";const icon: IconComponent = Search;+const alias: typeof Search = SearchIcon;const props: ComponentProps<typeof Search> = {size: "sm",ref: createRef<SVGSVGElement>(),@@ -47,5 +48,8 @@ const props: ComponentProps<typeof Search> = {<SiGithub size={24} />;// @ts-expect-error The same constraints apply to Tabler icons.<TbBrandAzure className="size-4" />;+// @ts-expect-error Aliases preserve the same semantic size constraints.+<SearchIcon size={16} />;void icon;+void alias;diff --git a/web/.storybook/main.ts b/web/.storybook/main.tsindex 7565aa5e5b..9d7e7b0640 100644--- a/web/.storybook/main.ts+++ b/web/.storybook/main.ts@@ -223,6 +223,11 @@ const config: StorybookConfig = {replacement: replacement as string,}));viteConfig.resolve.alias = [+ // Story importers are excluded from the production tsconfig.+ {+ find: /^@\//,+ replacement: fileURLToPath(new URL("../", import.meta.url)),+ },// The package also exposes a few named subpath exports (e.g.// `@langfuse/shared/query`, imported transitively via the chart-library's// PivotTable β widgets/utils). Those aren't under `src/`, so the two rulesdiff --git a/web/.storybook/tsconfig.json b/web/.storybook/tsconfig.jsonindex dfa298daef..d401111c23 100644--- a/web/.storybook/tsconfig.json+++ b/web/.storybook/tsconfig.json@@ -1,4 +1,3 @@{- "extends": "../tsconfig.json",- "include": ["**/*.ts", "**/*.tsx", "../next-env.d.ts", "../types/global.d.ts"]+ "extends": "../tsconfig.tests.json"}diff --git a/web/eslint.config.mjs b/web/eslint.config.mjsindex 5741c2f940..09c771909b 100644--- a/web/eslint.config.mjs+++ b/web/eslint.config.mjs@@ -72,6 +72,39 @@ export default [globalIgnores(["**/storybook-static/"]),...nextConfig,+ {+ name: "langfuse/web/test-and-story-typescript-project",+ files: [+ "**/__tests__/**/*.{ts,tsx,mts,cts}",+ "**/__e2e__/**/*.{ts,tsx,mts,cts}",+ "**/*.{test,spec,clienttest,servertest,story,stories}.{ts,tsx,mts,cts}",+ ".storybook/**/*.{ts,tsx,mts,cts}",+ "vitest.config.mts",+ "playwright.config.ts",+ ],+ languageOptions: {+ parserOptions: {+ // Project service discovers tsconfig.json, not sibling named configs.+ projectService: false,+ project: "./tsconfig.tests.json",+ tsconfigRootDir: import.meta.dirname,+ },+ },+ },+ {+ name: "langfuse/web/non-react-tests",+ files: [+ "**/*.clienttest.ts",+ "**/*.test.ts",+ "**/*.spec.ts",+ "**/__tests__/**/*.ts",+ ],+ rules: {+ // Compiler analysis serializes the AST through Babel, including large+ // JSON fixtures. These non-JSX tests do not define React components.+ "react-hooks/static-components": "off",+ },+ },{name: "langfuse/web/client-test-story-cache-key",files: ["src/**/*.clienttest.{ts,tsx}"],diff --git a/web/package.json b/web/package.jsonindex aca441c1a6..e1cdf7342d 100644--- a/web/package.json+++ b/web/package.json@@ -11,11 +11,11 @@"build:test": "INLINE_RUNTIME_CHUNK=false dotenv -e ../.env -- next build --experimental-build-mode compile","build:otel-worker": "DOCKER_BUILD=1 dotenv -e ../.env -- node scripts/build-otel-ingestion-worker.mjs","build:json-parser-worker": "node scripts/build-json-parser-worker.mjs",- "typecheck": "dotenv -e ../.env -- tsc -p tsconfig.json --noEmit --skipLibCheck --incremental --tsBuildInfoFile .tsbuildinfo",+ "typecheck": "dotenv -e ../.env -- tsc -p tsconfig.json --noEmit --skipLibCheck --incremental --tsBuildInfoFile .tsbuildinfo && dotenv -e ../.env -- tsc -p tsconfig.tests.json --noEmit --skipLibCheck --incremental --tsBuildInfoFile .tests.tsbuildinfo","dev": "dotenv -e ../.env -- next dev","dev:http": "dotenv -e ../.env -- next dev --experimental-https --experimental-https-key ./localhost+1-key.pem --experimental-https-cert ./localhost+1.pem",- "lint": "dotenv -e ../.env -- eslint --cache --cache-location .next/cache/eslint/ --max-warnings 0 --concurrency 2",- "lint:fix": "dotenv -e ../.env -- eslint . --cache --cache-location .next/cache/eslint/ --fix --concurrency 2",+ "lint": "dotenv -e ../.env -- node --max-old-space-size=8192 node_modules/eslint/bin/eslint.js --cache --cache-location .next/cache/eslint/ --max-warnings 0 --concurrency off",+ "lint:fix": "dotenv -e ../.env -- node --max-old-space-size=8192 node_modules/eslint/bin/eslint.js . --cache --cache-location .next/cache/eslint/ --fix --concurrency off","analyze": "dotenv -e ../.env -- next analyze","clean": "rm -rf node_modules","start": "dotenv -e ../.env -- sh -c 'NEXT_MANUAL_SIG_HANDLE=true next start'",diff --git a/web/scripts/structure/README.md b/web/scripts/structure/README.mdindex 9cecf268b6..9cdc6c11df 100644--- a/web/scripts/structure/README.md+++ b/web/scripts/structure/README.md@@ -72,7 +72,8 @@ Flags: `--dry-run` (print the plan and every rewrite, change nothing),`--no-siblings`, `--no-verify` (skip the closing `tsc` + `--diff`), `--no-color`.The rewrites come from TypeScript's own-`LanguageService.getEditsForFileRename` over `web/tsconfig.json` β the exact+`LanguageService.getEditsForFileRename` over the combined roots of+`web/tsconfig.json` and `web/tsconfig.tests.json` β the exactprimitive VS Code's "move file" uses β so `@/src/...` aliases, extension-lessspecifiers, index resolution and literal dynamic `import()` are the compiler'sproblem, not ours. Booting the service costs ~5β15s and every move after that@@ -120,24 +121,24 @@ Splitting a file and directory renames are not part of the surface## Rule β mechanism-| Rule | What | Counted by |-| ------ | --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |-| 1β4 | component/hook/fn/store/context file shape + naming; a `fns/` module folder groups one engine | census (TS parse) |-| 5 | kind folders closed list (+ `constants`, `types`; `docs` anywhere) | census (dir walk) |-| 6 | single-feature files live in the feature; **pages drive features** β a page route under `/sessions` owns `features/sessions`, even if another feature also imports the file | graph (used-in inversion + page slug) |-| 7 | no importing another component's internals | graph + `.dependency-cruiser.js` |-| 8 | cross-feature imports via a feature surface (`index.ts`, `server/index.ts`) | graph + `.dependency-cruiser.js` |-| 9 | `index.ts` at a feature root and its `server/` root | census |-| 10 | no client β `server/` (types excepted) | graph + `.dependency-cruiser.js` |-| 11 | no runtime import cycles | graph + `.dependency-cruiser.js` |-| 12 | `src/pages` files import only a Page component | graph + `.dependency-cruiser.js` |-| 13 | `components/ui` frozen | census (file count, baseline ratchets adds) |-| 14, 15 | design-system purity; git-mv moves | review / process β not counted |-| 16 | ESLint ignores at file level only | census (line-level disables) |-| 17 | baseline only shrinks | this baseline + `--diff` |-| 18 | fn/hook tests colocated flat | census |-| 19 | only tests import `__tests__` | graph + `.dependency-cruiser.js` |-| 20 | no unused exports | graph (file-level orphans; symbol-level needs a knip config β follow-up) |+| Rule | What | Counted by |+| ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |+| 1β4 | component/hook/fn/store/context file shape + naming; a `fns/` module folder groups one engine | census (TS parse) |+| 5 | kind folders closed list (+ `constants`, `types`; `docs` anywhere) | census (dir walk) |+| 6 | single-feature files live in the feature; **pages drive features** β a page route under `/sessions` owns `features/sessions`, even if another feature also imports the file | graph (used-in inversion + page slug) |+| 7 | no importing another component's internals | graph + `.dependency-cruiser.js` |+| 8 | cross-feature imports via a feature surface (`index.ts`, `server/index.ts`) | graph + `.dependency-cruiser.js` |+| 9 | `index.ts` at a feature root and its `server/` root | census |+| 10 | no client β `server/` (types excepted) | graph + `.dependency-cruiser.js` |+| 11 | no runtime import cycles | graph + `.dependency-cruiser.js` |+| 12 | `src/pages` files import only a Page component | graph + `.dependency-cruiser.js` |+| 13 | `components/ui` frozen | census (file count, baseline ratchets adds) |+| 14, 15 | design-system purity; git-mv moves | review / process β not counted |+| 16 | ESLint ignores at file level only | census (line-level disables) |+| 17 | baseline only shrinks | this baseline + `--diff` |+| 18 | fn/hook tests colocated flat | census |+| 19 | only tests import `__tests__` | graph + `.dependency-cruiser.js` |+| 20 | no unused exports | graph (file-level orphans; symbol-level needs a knip config β follow-up) |`.dependency-cruiser.js` carries the import rules as CI-ready warnings; thedetectors here are the exact reference implementation (the config's regexdiff --git a/web/scripts/structure/move.mjs b/web/scripts/structure/move.mjsindex a0a4eb826e..8020a79959 100644--- a/web/scripts/structure/move.mjs+++ b/web/scripts/structure/move.mjs@@ -327,25 +327,28 @@ console.log();// --- language service over a mutable in-memory layout ------------------------const t0 = Date.now();-const parsed = ts.getParsedCommandLineOfConfigFile(- `${webRoot}/tsconfig.json`,- {},- {- useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames,- readDirectory: ts.sys.readDirectory,- fileExists: ts.sys.fileExists,- readFile: ts.sys.readFile,- getCurrentDirectory: () => webRoot,- onUnRecoverableConfigFileDiagnostic: (dg) => {- console.error(ts.flattenDiagnosticMessageText(dg.messageText, "\n"));- process.exit(1);+const projects = ["tsconfig.json", "tsconfig.tests.json"].map((configName) => {+ const parsed = ts.getParsedCommandLineOfConfigFile(+ `${webRoot}/${configName}`,+ {},+ {+ useCaseSensitiveFileNames: ts.sys.useCaseSensitiveFileNames,+ readDirectory: ts.sys.readDirectory,+ fileExists: ts.sys.fileExists,+ readFile: ts.sys.readFile,+ getCurrentDirectory: () => webRoot,+ onUnRecoverableConfigFileDiagnostic: (dg) => {+ console.error(ts.flattenDiagnosticMessageText(dg.messageText, "\n"));+ process.exit(1);+ },},- },-);-if (!parsed) {- console.error("could not read web/tsconfig.json");- process.exit(1);-}+ );+ if (!parsed) {+ console.error(`could not read web/${configName}`);+ process.exit(1);+ }+ return parsed;+});/** @type {(p: string) => string} */const norm = (p) => p.replace(/\\/g, "/");@@ -356,7 +359,9 @@ const removed = new Set();/** @type {Map<string, number>} */const versions = new Map();/** @type {Set<string>} */-const scriptFileNames = new Set(parsed.fileNames.map(norm));+const scriptFileNames = new Set(+ projects.flatMap((project) => project.fileNames).map(norm),+);let projectVersion = 0;/** @type {(p: string) => string | undefined} */@@ -394,7 +399,7 @@ const lsHost = {},getProjectVersion: () => String(projectVersion),getCurrentDirectory: () => webRoot,- getCompilationSettings: () => parsed.options,+ getCompilationSettings: () => projects[0].options,getDefaultLibFileName: (o) => ts.getDefaultLibFilePath(o),// a case-only rename is only a rename under case-sensitive comparisonuseCaseSensitiveFileNames: () =>@@ -606,7 +611,7 @@ for (const [dest, original] of movedOriginal) {const resolved = ts.resolveModuleName(spec,dest,- parsed.options,+ projects[0].options,overlayResolutionHost,).resolvedModule?.resolvedFileName;const bucket =diff --git a/web/tsconfig.json b/web/tsconfig.jsonindex 1d4efb756a..a0baacf87a 100644--- a/web/tsconfig.json+++ b/web/tsconfig.json@@ -3,22 +3,27 @@"compilerOptions": {"declaration": false,"declarationMap": false,- "plugins": [- {- "name": "next"- }- ],"paths": {- "@/*": [- "./*"- ]+ "@/*": ["./*"]},"strictNullChecks": true,- "types": ["node", "vitest/globals", "vitest/importMeta", "@testing-library/jest-dom"]+ "types": ["node"]},"exclude": ["node_modules",- "sdk"+ "sdk",+ "storybook-static",+ ".storybook",+ "**/__tests__/**",+ "**/__e2e__/**",+ "**/*.test.*",+ "**/*.spec.*",+ "**/*.clienttest.*",+ "**/*.servertest.*",+ "**/*.story.*",+ "**/*.stories.*",+ "vitest.config.mts",+ "playwright.config.ts"],"include": ["**/*.cjs",@@ -28,8 +33,7 @@".eslintrc.js",".next/types/**/*.ts","next-env.d.ts",- "next-env.d.ts","src",- "types/global.d.ts"+ "types/**/*.d.ts"]}diff --git a/web/tsconfig.tests.json b/web/tsconfig.tests.jsonnew file mode 100644index 0000000000..f3aa647f4a--- /dev/null+++ b/web/tsconfig.tests.json@@ -0,0 +1,28 @@+{+ "extends": "./tsconfig.json",+ "compilerOptions": {+ "types": [+ "node",+ "vitest/globals",+ "vitest/importMeta",+ "@testing-library/jest-dom"+ ]+ },+ "exclude": ["node_modules", "sdk", "storybook-static"],+ "include": [+ "**/__tests__/**/*",+ "**/__e2e__/**/*",+ "**/*.test.*",+ "**/*.spec.*",+ "**/*.clienttest.*",+ "**/*.servertest.*",+ "**/*.story.*",+ "**/*.stories.*",+ ".storybook/**/*",+ "vitest.config.mts",+ "playwright.config.ts",+ "next-env.d.ts",+ "types/**/*.d.ts",+ "src/**/*.d.ts"+ ]+}diff --git a/web/vitest.config.mts b/web/vitest.config.mtsindex 67514f8c8e..c8a5388528 100644--- a/web/vitest.config.mts+++ b/web/vitest.config.mts@@ -7,16 +7,13 @@ import { expand } from "dotenv-expand";import { defineConfig } from "vitest/config";import react from "@vitejs/plugin-react";import tsconfigPaths from "vite-tsconfig-paths";+import { type Plugin } from "vite";import { VitestCiReporter } from "../scripts/vitest/ci-reporter";expand(config({ path: "../.env.test" }));expand(config({ path: "../.env" }));-const sharedExclude = [- "**/node_modules/**",- "**/.next/**",- "**/dist/**",-];+const sharedExclude = ["**/node_modules/**", "**/.next/**", "**/dist/**"];// The server suite spends more time importing the heavy @langfuse/shared// module graph per test file than running tests (measured in CI: 371s@@ -63,7 +60,7 @@ const sharedContextServerTestFiles = serverTestFiles.filter((file) => !isolatedServerTestFiles.includes(file),);-function markdownRawPlugin() {+function markdownRawPlugin(): Plugin {return {name: "markdown-raw",enforce: "pre",@@ -173,6 +170,8 @@ export default defineConfig({plugins: [markdownRawPlugin(), tsconfigPaths(), react()],resolve: {alias: [+ // Tests and stories are excluded from the tsconfig discovered by tsconfigPaths.+ { find: /^@\//, replacement: `${import.meta.dirname}/` },// next-query-params ships a CJS `pages` entry whose default-export// interop breaks when the package is inlined (server.deps.inline// below, needed so vi.mock("next/router") intercepts the adapter's