From fa883399d5f017fa66875cde70553c91c62b84cb Mon Sep 17 00:00:00 2001 From: Stephen Belanger Date: Tue, 17 Mar 2026 02:21:14 +0800 Subject: [PATCH 1/5] Move auto-instrumentation bundler plugins to browser package --- integrations/browser-js/package.json | 22 ++++++- .../browser-js/src}/bundler/esbuild.ts | 2 +- .../browser-js/src}/bundler/plugin.ts | 12 ++-- .../browser-js/src}/bundler/rollup.ts | 2 +- .../types/module-details-from-path.d.ts | 11 ++++ .../browser-js/src}/bundler/vite.ts | 2 +- .../browser-js/src}/bundler/webpack.ts | 2 +- integrations/browser-js/tsconfig.json | 7 ++- integrations/browser-js/tsup.config.ts | 40 ++++++++---- js/package.json | 29 ++------- js/tsup.config.ts | 4 -- pnpm-lock.yaml | 63 +++++++------------ 12 files changed, 104 insertions(+), 92 deletions(-) rename {js/src/auto-instrumentations => integrations/browser-js/src}/bundler/esbuild.ts (88%) rename {js/src/auto-instrumentations => integrations/browser-js/src}/bundler/plugin.ts (94%) rename {js/src/auto-instrumentations => integrations/browser-js/src}/bundler/rollup.ts (88%) create mode 100644 integrations/browser-js/src/bundler/types/module-details-from-path.d.ts rename {js/src/auto-instrumentations => integrations/browser-js/src}/bundler/vite.ts (89%) rename {js/src/auto-instrumentations => integrations/browser-js/src}/bundler/webpack.ts (88%) diff --git a/integrations/browser-js/package.json b/integrations/browser-js/package.json index 646003908..e53dbd1c8 100644 --- a/integrations/browser-js/package.json +++ b/integrations/browser-js/package.json @@ -10,6 +10,22 @@ "types": "./dist/index.d.ts", "import": "./dist/index.js", "default": "./dist/index.js" + }, + "./vite": { + "types": "./dist/bundler/vite.d.ts", + "import": "./dist/bundler/vite.js" + }, + "./webpack": { + "types": "./dist/bundler/webpack.d.ts", + "import": "./dist/bundler/webpack.js" + }, + "./esbuild": { + "types": "./dist/bundler/esbuild.d.ts", + "import": "./dist/bundler/esbuild.js" + }, + "./rollup": { + "types": "./dist/bundler/rollup.d.ts", + "import": "./dist/bundler/rollup.js" } }, "files": [ @@ -23,8 +39,12 @@ "clean": "rm -rf dist" }, "dependencies": { + "@apm-js-collab/code-transformer": "^0.9.0", "als-browser": "^1.0.1", - "braintrust": ">=3.0.0-rc.29" + "braintrust": ">=3.0.0-rc.29", + "dc-browser": "^1.0.3", + "module-details-from-path": "^1.0.4", + "unplugin": "^2.3.5" }, "devDependencies": { "@types/node": "^20.10.5", diff --git a/js/src/auto-instrumentations/bundler/esbuild.ts b/integrations/browser-js/src/bundler/esbuild.ts similarity index 88% rename from js/src/auto-instrumentations/bundler/esbuild.ts rename to integrations/browser-js/src/bundler/esbuild.ts index 83278dbac..ed121b3d0 100644 --- a/js/src/auto-instrumentations/bundler/esbuild.ts +++ b/integrations/browser-js/src/bundler/esbuild.ts @@ -3,7 +3,7 @@ * * Usage: * ```typescript - * import { esbuildPlugin } from '@braintrust/auto-instrumentations/bundler/esbuild'; + * import { esbuildPlugin } from '@braintrust/browser/esbuild'; * * await esbuild.build({ * plugins: [esbuildPlugin()], diff --git a/js/src/auto-instrumentations/bundler/plugin.ts b/integrations/browser-js/src/bundler/plugin.ts similarity index 94% rename from js/src/auto-instrumentations/bundler/plugin.ts rename to integrations/browser-js/src/bundler/plugin.ts index 8e65d71c4..e422ea15d 100644 --- a/js/src/auto-instrumentations/bundler/plugin.ts +++ b/integrations/browser-js/src/bundler/plugin.ts @@ -20,11 +20,13 @@ import { extname, join, sep } from "path"; import { readFileSync } from "fs"; import { fileURLToPath } from "url"; import moduleDetailsFromPath from "module-details-from-path"; -import { openaiConfigs } from "../configs/openai"; -import { anthropicConfigs } from "../configs/anthropic"; -import { aiSDKConfigs } from "../configs/ai-sdk"; -import { claudeAgentSDKConfigs } from "../configs/claude-agent-sdk"; -import { googleGenAIConfigs } from "../configs/google-genai"; +import { + openaiConfigs, + anthropicConfigs, + aiSDKConfigs, + claudeAgentSDKConfigs, + googleGenAIConfigs, +} from "braintrust/auto-instrumentation-configs"; export interface BundlerPluginOptions { /** diff --git a/js/src/auto-instrumentations/bundler/rollup.ts b/integrations/browser-js/src/bundler/rollup.ts similarity index 88% rename from js/src/auto-instrumentations/bundler/rollup.ts rename to integrations/browser-js/src/bundler/rollup.ts index c89fbff3f..4b0ab7957 100644 --- a/js/src/auto-instrumentations/bundler/rollup.ts +++ b/integrations/browser-js/src/bundler/rollup.ts @@ -3,7 +3,7 @@ * * Usage: * ```typescript - * import { rollupPlugin } from '@braintrust/auto-instrumentations/bundler/rollup'; + * import { rollupPlugin } from '@braintrust/browser/rollup'; * * export default { * plugins: [rollupPlugin()] diff --git a/integrations/browser-js/src/bundler/types/module-details-from-path.d.ts b/integrations/browser-js/src/bundler/types/module-details-from-path.d.ts new file mode 100644 index 000000000..da289c802 --- /dev/null +++ b/integrations/browser-js/src/bundler/types/module-details-from-path.d.ts @@ -0,0 +1,11 @@ +declare module "module-details-from-path" { + interface ModuleDetails { + name: string; + basedir: string; + path: string; + } + + function moduleDetailsFromPath(filePath: string): ModuleDetails | null; + + export = moduleDetailsFromPath; +} diff --git a/js/src/auto-instrumentations/bundler/vite.ts b/integrations/browser-js/src/bundler/vite.ts similarity index 89% rename from js/src/auto-instrumentations/bundler/vite.ts rename to integrations/browser-js/src/bundler/vite.ts index ceb220f9a..8e14c5e46 100644 --- a/js/src/auto-instrumentations/bundler/vite.ts +++ b/integrations/browser-js/src/bundler/vite.ts @@ -3,7 +3,7 @@ * * Usage: * ```typescript - * import { vitePlugin } from '@braintrust/auto-instrumentations/bundler/vite'; + * import { vitePlugin } from '@braintrust/browser/vite'; * * export default { * plugins: [vitePlugin()], diff --git a/js/src/auto-instrumentations/bundler/webpack.ts b/integrations/browser-js/src/bundler/webpack.ts similarity index 88% rename from js/src/auto-instrumentations/bundler/webpack.ts rename to integrations/browser-js/src/bundler/webpack.ts index 19497e77c..00881c969 100644 --- a/js/src/auto-instrumentations/bundler/webpack.ts +++ b/integrations/browser-js/src/bundler/webpack.ts @@ -3,7 +3,7 @@ * * Usage: * ```javascript - * import { webpackPlugin } from 'braintrust/auto-instrumentations/bundler/webpack'; + * import { webpackPlugin } from '@braintrust/browser/webpack'; * * export default { * plugins: [webpackPlugin()], diff --git a/integrations/browser-js/tsconfig.json b/integrations/browser-js/tsconfig.json index 94649b1d8..3d51d55e4 100644 --- a/integrations/browser-js/tsconfig.json +++ b/integrations/browser-js/tsconfig.json @@ -8,7 +8,12 @@ "strict": true, "esModuleInterop": true, "skipLibCheck": true, - "resolveJsonModule": true + "resolveJsonModule": true, + "paths": { + "braintrust/auto-instrumentation-configs": [ + "../../js/dist/auto-instrumentations/index" + ] + } }, "include": ["src/**/*"], "exclude": ["node_modules", "dist"] diff --git a/integrations/browser-js/tsup.config.ts b/integrations/browser-js/tsup.config.ts index b532d4d5c..0d64c9dc3 100644 --- a/integrations/browser-js/tsup.config.ts +++ b/integrations/browser-js/tsup.config.ts @@ -1,14 +1,30 @@ import { defineConfig } from "tsup"; -export default defineConfig({ - entry: ["src/index.ts"], - format: ["esm"], - dts: true, - sourcemap: true, - clean: true, - external: ["braintrust", "zod"], - target: "es2022", - platform: "browser", - outDir: "./dist", - treeshake: true, -}); +export default defineConfig([ + { + entry: ["src/index.ts"], + format: ["esm"], + dts: true, + sourcemap: true, + clean: true, + external: ["braintrust", "zod"], + target: "es2022", + platform: "browser", + outDir: "./dist", + treeshake: true, + }, + { + entry: { + "bundler/vite": "src/bundler/vite.ts", + "bundler/webpack": "src/bundler/webpack.ts", + "bundler/esbuild": "src/bundler/esbuild.ts", + "bundler/rollup": "src/bundler/rollup.ts", + }, + format: ["esm"], + dts: true, + platform: "node", + external: ["braintrust", "@apm-js-collab/code-transformer", "zod"], + outDir: "./dist", + clean: false, + }, +]); diff --git a/js/package.json b/js/package.json index 781d0d05b..e01709d6d 100644 --- a/js/package.json +++ b/js/package.json @@ -75,29 +75,10 @@ "require": "./dist/instrumentation/index.js" }, "./hook.mjs": "./dist/auto-instrumentations/hook.mjs", - "./vite": { - "types": "./dist/auto-instrumentations/bundler/vite.d.ts", - "import": "./dist/auto-instrumentations/bundler/vite.mjs", - "module": "./dist/auto-instrumentations/bundler/vite.mjs", - "require": "./dist/auto-instrumentations/bundler/vite.js" - }, - "./webpack": { - "types": "./dist/auto-instrumentations/bundler/webpack.d.ts", - "import": "./dist/auto-instrumentations/bundler/webpack.mjs", - "module": "./dist/auto-instrumentations/bundler/webpack.mjs", - "require": "./dist/auto-instrumentations/bundler/webpack.js" - }, - "./esbuild": { - "types": "./dist/auto-instrumentations/bundler/esbuild.d.ts", - "import": "./dist/auto-instrumentations/bundler/esbuild.mjs", - "module": "./dist/auto-instrumentations/bundler/esbuild.mjs", - "require": "./dist/auto-instrumentations/bundler/esbuild.js" - }, - "./rollup": { - "types": "./dist/auto-instrumentations/bundler/rollup.d.ts", - "import": "./dist/auto-instrumentations/bundler/rollup.mjs", - "module": "./dist/auto-instrumentations/bundler/rollup.mjs", - "require": "./dist/auto-instrumentations/bundler/rollup.js" + "./auto-instrumentation-configs": { + "types": "./dist/auto-instrumentations/index.d.ts", + "import": "./dist/auto-instrumentations/index.mjs", + "require": "./dist/auto-instrumentations/index.cjs" } }, "files": [ @@ -204,7 +185,6 @@ "cli-progress": "^3.12.0", "cli-table3": "^0.6.5", "cors": "^2.8.5", - "dc-browser": "^1.0.3", "dotenv": "^16.4.5", "esbuild": "^0.27.0", "eventsource-parser": "^1.1.2", @@ -218,7 +198,6 @@ "simple-git": "^3.21.0", "source-map": "^0.7.4", "termi-link": "^1.0.1", - "unplugin": "^2.3.5", "uuid": "^9.0.1", "zod-to-json-schema": "^3.25.0" }, diff --git a/js/tsup.config.ts b/js/tsup.config.ts index 25c7341c6..e08b62135 100644 --- a/js/tsup.config.ts +++ b/js/tsup.config.ts @@ -91,10 +91,6 @@ export default defineConfig([ "src/auto-instrumentations/index.ts", "src/auto-instrumentations/loader/cjs-patch.ts", "src/auto-instrumentations/loader/get-package-version.ts", - "src/auto-instrumentations/bundler/vite.ts", - "src/auto-instrumentations/bundler/webpack.ts", - "src/auto-instrumentations/bundler/esbuild.ts", - "src/auto-instrumentations/bundler/rollup.ts", ], format: ["cjs", "esm"], outDir: "dist/auto-instrumentations", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cdd40425a..1516b8418 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -59,12 +59,24 @@ importers: integrations/browser-js: dependencies: + '@apm-js-collab/code-transformer': + specifier: ^0.9.0 + version: 0.9.0 als-browser: specifier: ^1.0.1 version: 1.0.1 braintrust: specifier: '>=3.0.0-rc.29' version: 3.0.0-rc.29(zod@4.2.1) + dc-browser: + specifier: ^1.0.3 + version: 1.0.3 + module-details-from-path: + specifier: ^1.0.4 + version: 1.0.4 + unplugin: + specifier: ^2.3.5 + version: 2.3.11 zod: specifier: ^3.25.34 || ^4.0 version: 4.2.1 @@ -1861,9 +1873,6 @@ packages: resolution: {integrity: sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} - '@jridgewell/gen-mapping@0.3.12': - resolution: {integrity: sha512-OuLGC46TjB5BbN1dH8JULVVZY4WTdkF7tV9Ys6wLL1rubZnCMstOhNHueU5bLCrnRuDhKPDM4g6sw4Bel5Gzqg==} - '@jridgewell/gen-mapping@0.3.13': resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==} @@ -1885,18 +1894,9 @@ packages: '@jridgewell/source-map@0.3.11': resolution: {integrity: sha512-ZMp1V8ZFcPG5dIWnQLr3NSI1MiCU7UETdS/A0G8V/XWHvJv3ZsFqutJn1Y5RPmAPX6F3BiE397OqveU/9NCuIA==} - '@jridgewell/sourcemap-codec@1.5.0': - resolution: {integrity: sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==} - '@jridgewell/sourcemap-codec@1.5.5': resolution: {integrity: sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==} - '@jridgewell/trace-mapping@0.3.25': - resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==} - - '@jridgewell/trace-mapping@0.3.29': - resolution: {integrity: sha512-uw6guiW/gcAGPDhLmd77/6lW8QLeiV5RUTsAX46Db6oLhGaVj4lhnPwb184s1bkc8kdVg/+h988dro8GRDpmYQ==} - '@jridgewell/trace-mapping@0.3.31': resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==} @@ -6197,8 +6197,8 @@ snapshots: '@ampproject/remapping@2.3.0': dependencies: - '@jridgewell/gen-mapping': 0.3.8 - '@jridgewell/trace-mapping': 0.3.25 + '@jridgewell/gen-mapping': 0.3.13 + '@jridgewell/trace-mapping': 0.3.31 '@anthropic-ai/claude-agent-sdk@0.1.23(zod@3.25.76)': dependencies: @@ -6328,16 +6328,16 @@ snapshots: '@babel/generator@7.24.7': dependencies: '@babel/types': 7.24.7 - '@jridgewell/gen-mapping': 0.3.8 - '@jridgewell/trace-mapping': 0.3.25 + '@jridgewell/gen-mapping': 0.3.13 + '@jridgewell/trace-mapping': 0.3.31 jsesc: 2.5.2 '@babel/generator@7.28.0': dependencies: '@babel/parser': 7.28.0 '@babel/types': 7.28.1 - '@jridgewell/gen-mapping': 0.3.12 - '@jridgewell/trace-mapping': 0.3.29 + '@jridgewell/gen-mapping': 0.3.13 + '@jridgewell/trace-mapping': 0.3.31 jsesc: 3.1.0 '@babel/generator@7.29.1': @@ -7564,7 +7564,7 @@ snapshots: dependencies: '@babel/core': 7.24.7 '@jest/types': 29.6.3 - '@jridgewell/trace-mapping': 0.3.25 + '@jridgewell/trace-mapping': 0.3.31 babel-plugin-istanbul: 6.1.1 chalk: 4.1.2 convert-source-map: 2.0.0 @@ -7589,11 +7589,6 @@ snapshots: '@types/yargs': 17.0.32 chalk: 4.1.2 - '@jridgewell/gen-mapping@0.3.12': - dependencies: - '@jridgewell/sourcemap-codec': 1.5.5 - '@jridgewell/trace-mapping': 0.3.31 - '@jridgewell/gen-mapping@0.3.13': dependencies: '@jridgewell/sourcemap-codec': 1.5.5 @@ -7602,8 +7597,8 @@ snapshots: '@jridgewell/gen-mapping@0.3.8': dependencies: '@jridgewell/set-array': 1.2.1 - '@jridgewell/sourcemap-codec': 1.5.0 - '@jridgewell/trace-mapping': 0.3.25 + '@jridgewell/sourcemap-codec': 1.5.5 + '@jridgewell/trace-mapping': 0.3.31 '@jridgewell/remapping@2.3.5': dependencies: @@ -7619,20 +7614,8 @@ snapshots: '@jridgewell/gen-mapping': 0.3.13 '@jridgewell/trace-mapping': 0.3.31 - '@jridgewell/sourcemap-codec@1.5.0': {} - '@jridgewell/sourcemap-codec@1.5.5': {} - '@jridgewell/trace-mapping@0.3.25': - dependencies: - '@jridgewell/resolve-uri': 3.1.2 - '@jridgewell/sourcemap-codec': 1.5.0 - - '@jridgewell/trace-mapping@0.3.29': - dependencies: - '@jridgewell/resolve-uri': 3.1.2 - '@jridgewell/sourcemap-codec': 1.5.5 - '@jridgewell/trace-mapping@0.3.31': dependencies: '@jridgewell/resolve-uri': 3.1.2 @@ -11055,7 +11038,7 @@ snapshots: mlly@1.8.0: dependencies: - acorn: 8.15.0 + acorn: 8.16.0 pathe: 2.0.3 pkg-types: 1.3.1 ufo: 1.6.1 @@ -12418,7 +12401,7 @@ snapshots: unplugin@2.3.11: dependencies: '@jridgewell/remapping': 2.3.5 - acorn: 8.15.0 + acorn: 8.16.0 picomatch: 4.0.3 webpack-virtual-modules: 0.6.2 From 2516b47ae058070d47938d172617c20bf0dfaa91 Mon Sep 17 00:00:00 2001 From: Stephen Belanger Date: Tue, 17 Mar 2026 02:28:23 +0800 Subject: [PATCH 2/5] chore: update pnpm lockfile after removing unplugin and dc-browser deps Co-Authored-By: Claude Sonnet 4.6 --- pnpm-lock.yaml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1516b8418..9efb01fdc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -327,9 +327,6 @@ importers: cors: specifier: ^2.8.5 version: 2.8.5 - dc-browser: - specifier: ^1.0.3 - version: 1.0.3 dotenv: specifier: ^16.4.5 version: 16.4.5 @@ -369,9 +366,6 @@ importers: termi-link: specifier: ^1.0.1 version: 1.1.0 - unplugin: - specifier: ^2.3.5 - version: 2.3.11 uuid: specifier: ^9.0.1 version: 9.0.1 From 673adb025b57f768fdb1021a170b80f3ada73f99 Mon Sep 17 00:00:00 2001 From: Stephen Belanger Date: Tue, 17 Mar 2026 13:45:05 +0800 Subject: [PATCH 3/5] fix: move dc-browser to devDependencies so it is available at build time dc-browser is bundled inline into dist/browser.mjs and does not need to be a runtime dependency, but it must be present for the build to resolve the import in src/browser/config.ts. Co-Authored-By: Claude Sonnet 4.6 --- js/package.json | 1 + pnpm-lock.yaml | 3 +++ 2 files changed, 4 insertions(+) diff --git a/js/package.json b/js/package.json index e01709d6d..e1e1df430 100644 --- a/js/package.json +++ b/js/package.json @@ -154,6 +154,7 @@ "async": "^3.2.5", "autoevals": "^0.0.131", "cross-env": "^7.0.3", + "dc-browser": "^1.0.3", "eslint-plugin-node-import": "^1.0.5", "jiti": "^2.6.1", "openai": "6.25.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9efb01fdc..3248ae958 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -445,6 +445,9 @@ importers: cross-env: specifier: ^7.0.3 version: 7.0.3 + dc-browser: + specifier: ^1.0.3 + version: 1.0.3 eslint-plugin-node-import: specifier: ^1.0.5 version: 1.0.5(eslint@9.39.3(jiti@2.6.1)) From 143eab9562c9b0cb4a3b41c1f4b9ecd6fdf57507 Mon Sep 17 00:00:00 2001 From: Stephen Belanger Date: Tue, 17 Mar 2026 23:21:33 +0800 Subject: [PATCH 4/5] fix: redirect bundler test imports to @braintrust/browser and alias braintrust subpath in vitest - Update test files to import bundler plugins from @braintrust/browser/{esbuild,vite,rollup} instead of the deleted js/src/auto-instrumentations/bundler/ source files - Add @braintrust/browser as a devDependency of braintrust for test access - Add vitest resolve alias for braintrust/auto-instrumentation-configs pointing to the workspace TypeScript source, bypassing the stale npm v3.0.0-rc.29 copy that pnpm installs in integrations/browser-js/node_modules (which predates that export) Co-Authored-By: Claude Sonnet 4.6 --- js/package.json | 1 + .../error-handling.test.ts | 21 +++---- .../event-content.test.ts | 60 +++++++------------ .../function-behavior.test.ts | 27 +++------ .../multiple-instrumentations.test.ts | 18 ++---- .../runtime-execution.test.ts | 27 +++------ .../streaming-and-responses.test.ts | 18 ++---- .../transformation.test.ts | 18 ++---- js/vitest.config.js | 6 ++ pnpm-lock.yaml | 16 +++-- 10 files changed, 82 insertions(+), 130 deletions(-) diff --git a/js/package.json b/js/package.json index e1e1df430..8ed770889 100644 --- a/js/package.json +++ b/js/package.json @@ -153,6 +153,7 @@ "ai": "^6.0.0", "async": "^3.2.5", "autoevals": "^0.0.131", + "@braintrust/browser": "workspace:*", "cross-env": "^7.0.3", "dc-browser": "^1.0.3", "eslint-plugin-node-import": "^1.0.5", diff --git a/js/tests/auto-instrumentations/error-handling.test.ts b/js/tests/auto-instrumentations/error-handling.test.ts index 52eb876f3..cf1e61147 100644 --- a/js/tests/auto-instrumentations/error-handling.test.ts +++ b/js/tests/auto-instrumentations/error-handling.test.ts @@ -76,8 +76,7 @@ describe("Error Handling", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -136,8 +135,7 @@ describe("Error Handling", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -187,8 +185,7 @@ describe("Error Handling", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -231,8 +228,7 @@ describe("Error Handling", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -284,8 +280,7 @@ describe("Error Handling", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -339,8 +334,7 @@ describe("Error Handling", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -403,8 +397,7 @@ describe("Error Handling", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], diff --git a/js/tests/auto-instrumentations/event-content.test.ts b/js/tests/auto-instrumentations/event-content.test.ts index 40e426a97..23eca106c 100644 --- a/js/tests/auto-instrumentations/event-content.test.ts +++ b/js/tests/auto-instrumentations/event-content.test.ts @@ -77,8 +77,7 @@ describe("Event Content Validation", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -151,8 +150,7 @@ describe("Event Content Validation", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -218,8 +216,7 @@ describe("Event Content Validation", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -298,8 +295,7 @@ describe("Event Content Validation", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -359,8 +355,7 @@ describe("Event Content Validation", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -413,8 +408,7 @@ describe("Event Content Validation", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -469,8 +463,7 @@ describe("Event Content Validation", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -527,8 +520,7 @@ describe("Event Content Validation", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -654,8 +646,7 @@ describe("Event Content Validation", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -729,8 +720,7 @@ describe("Event Content Validation", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -833,8 +823,7 @@ describe("Event Content Validation", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -940,8 +929,7 @@ describe("Event Content Validation", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -1047,8 +1035,7 @@ describe("Event Content Validation", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -1134,8 +1121,7 @@ describe("Event Content Validation", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -1235,8 +1221,7 @@ describe("Event Content Validation", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -1342,8 +1327,7 @@ describe("Event Content Validation", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -1418,8 +1402,7 @@ describe("Event Content Validation", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -1516,8 +1499,7 @@ describe("Event Content Validation", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -1605,8 +1587,7 @@ describe("Event Content Validation", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -1701,8 +1682,7 @@ describe("Event Content Validation", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], diff --git a/js/tests/auto-instrumentations/function-behavior.test.ts b/js/tests/auto-instrumentations/function-behavior.test.ts index 8f2fd32b5..dc6f2ad7d 100644 --- a/js/tests/auto-instrumentations/function-behavior.test.ts +++ b/js/tests/auto-instrumentations/function-behavior.test.ts @@ -66,8 +66,7 @@ describe("Function Behavior Preservation", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -134,8 +133,7 @@ describe("Function Behavior Preservation", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -181,8 +179,7 @@ describe("Function Behavior Preservation", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -233,8 +230,7 @@ describe("Function Behavior Preservation", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -287,8 +283,7 @@ describe("Function Behavior Preservation", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -341,8 +336,7 @@ describe("Function Behavior Preservation", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -395,8 +389,7 @@ describe("Function Behavior Preservation", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -441,8 +434,7 @@ describe("Function Behavior Preservation", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -492,8 +484,7 @@ describe("Function Behavior Preservation", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], diff --git a/js/tests/auto-instrumentations/multiple-instrumentations.test.ts b/js/tests/auto-instrumentations/multiple-instrumentations.test.ts index eabe2b0cd..555f4fce7 100644 --- a/js/tests/auto-instrumentations/multiple-instrumentations.test.ts +++ b/js/tests/auto-instrumentations/multiple-instrumentations.test.ts @@ -103,8 +103,7 @@ describe("Multiple Instrumentations", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -171,8 +170,7 @@ describe("Multiple Instrumentations", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -236,8 +234,7 @@ describe("Multiple Instrumentations", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -316,8 +313,7 @@ describe("Multiple Instrumentations", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -404,8 +400,7 @@ describe("Multiple Instrumentations", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); // Add custom instrumentation config const customConfig = { @@ -490,8 +485,7 @@ describe("Multiple Instrumentations", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], diff --git a/js/tests/auto-instrumentations/runtime-execution.test.ts b/js/tests/auto-instrumentations/runtime-execution.test.ts index f8641611b..d4a2cd4e3 100644 --- a/js/tests/auto-instrumentations/runtime-execution.test.ts +++ b/js/tests/auto-instrumentations/runtime-execution.test.ts @@ -66,8 +66,7 @@ describe("Runtime Execution of Bundled Code", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -125,8 +124,7 @@ describe("Runtime Execution of Bundled Code", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -191,8 +189,7 @@ describe("Runtime Execution of Bundled Code", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -236,8 +233,7 @@ describe("Runtime Execution of Bundled Code", () => { fs.writeFileSync(entryPoint, testCode); - const { vitePlugin } = - await import("../../src/auto-instrumentations/bundler/vite.js"); + const { vitePlugin } = await import("@braintrust/browser/vite"); await viteBuild({ root: fixturesDir, @@ -298,8 +294,7 @@ describe("Runtime Execution of Bundled Code", () => { fs.writeFileSync(entryPoint, testCode); - const { vitePlugin } = - await import("../../src/auto-instrumentations/bundler/vite.js"); + const { vitePlugin } = await import("@braintrust/browser/vite"); await viteBuild({ root: fixturesDir, @@ -353,8 +348,7 @@ describe("Runtime Execution of Bundled Code", () => { fs.writeFileSync(entryPoint, testCode); - const { rollupPlugin } = - await import("../../src/auto-instrumentations/bundler/rollup.js"); + const { rollupPlugin } = await import("@braintrust/browser/rollup"); // Simple resolver plugin const resolverPlugin = { @@ -422,8 +416,7 @@ describe("Runtime Execution of Bundled Code", () => { fs.writeFileSync(entryPoint, testCode); - const { rollupPlugin } = - await import("../../src/auto-instrumentations/bundler/rollup.js"); + const { rollupPlugin } = await import("@braintrust/browser/rollup"); const resolverPlugin = { name: "resolver", @@ -485,8 +478,7 @@ describe("Runtime Execution of Bundled Code", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -539,8 +531,7 @@ describe("Runtime Execution of Bundled Code", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], diff --git a/js/tests/auto-instrumentations/streaming-and-responses.test.ts b/js/tests/auto-instrumentations/streaming-and-responses.test.ts index 8d4a40ff5..c065e686f 100644 --- a/js/tests/auto-instrumentations/streaming-and-responses.test.ts +++ b/js/tests/auto-instrumentations/streaming-and-responses.test.ts @@ -155,8 +155,7 @@ describe("Streaming Methods and Responses API", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -216,8 +215,7 @@ describe("Streaming Methods and Responses API", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -310,8 +308,7 @@ describe("Streaming Methods and Responses API", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -400,8 +397,7 @@ describe("Streaming Methods and Responses API", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -461,8 +457,7 @@ describe("Streaming Methods and Responses API", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], @@ -554,8 +549,7 @@ describe("Streaming Methods and Responses API", () => { fs.writeFileSync(entryPoint, testCode); - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); await esbuild.build({ entryPoints: [entryPoint], diff --git a/js/tests/auto-instrumentations/transformation.test.ts b/js/tests/auto-instrumentations/transformation.test.ts index 96f2eb64a..1120068bd 100644 --- a/js/tests/auto-instrumentations/transformation.test.ts +++ b/js/tests/auto-instrumentations/transformation.test.ts @@ -39,8 +39,7 @@ describe("Orchestrion Transformation Tests", () => { describe("esbuild", () => { it("should transform OpenAI SDK code with tracingChannel", async () => { - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); const entryPoint = path.join(fixturesDir, "test-app.js"); const outfile = path.join(outputDir, "esbuild-bundle.js"); @@ -72,8 +71,7 @@ describe("Orchestrion Transformation Tests", () => { }); it("should bundle dc-browser module when browser: true", async () => { - const { esbuildPlugin } = - await import("../../src/auto-instrumentations/bundler/esbuild.js"); + const { esbuildPlugin } = await import("@braintrust/browser/esbuild"); const entryPoint = path.join(fixturesDir, "test-app.js"); const outfile = path.join(outputDir, "esbuild-browser-bundle.js"); @@ -111,8 +109,7 @@ describe("Orchestrion Transformation Tests", () => { describe("vite", () => { it("should transform OpenAI SDK code with tracingChannel", async () => { - const { vitePlugin } = - await import("../../src/auto-instrumentations/bundler/vite.js"); + const { vitePlugin } = await import("@braintrust/browser/vite"); const entryPoint = path.join(fixturesDir, "test-app.js"); const outDir = path.join(outputDir, "vite-dist"); @@ -153,8 +150,7 @@ describe("Orchestrion Transformation Tests", () => { }); it("should bundle dc-browser module when browser: true", async () => { - const { vitePlugin } = - await import("../../src/auto-instrumentations/bundler/vite.js"); + const { vitePlugin } = await import("@braintrust/browser/vite"); const entryPoint = path.join(fixturesDir, "test-app.js"); const outDir = path.join(outputDir, "vite-browser-dist"); @@ -199,8 +195,7 @@ describe("Orchestrion Transformation Tests", () => { describe("rollup", () => { it("should transform OpenAI SDK code with tracingChannel", async () => { const { rollup } = await import("rollup"); - const { rollupPlugin } = - await import("../../src/auto-instrumentations/bundler/rollup.js"); + const { rollupPlugin } = await import("@braintrust/browser/rollup"); const entryPoint = path.join(fixturesDir, "test-app.js"); const outfile = path.join(outputDir, "rollup-bundle.js"); @@ -248,8 +243,7 @@ describe("Orchestrion Transformation Tests", () => { it("should bundle dc-browser module when browser: true", async () => { const { rollup } = await import("rollup"); - const { rollupPlugin } = - await import("../../src/auto-instrumentations/bundler/rollup.js"); + const { rollupPlugin } = await import("@braintrust/browser/rollup"); const entryPoint = path.join(fixturesDir, "test-app.js"); const outfile = path.join(outputDir, "rollup-browser-bundle.js"); diff --git a/js/vitest.config.js b/js/vitest.config.js index 089f86712..cd4eb42cd 100644 --- a/js/vitest.config.js +++ b/js/vitest.config.js @@ -15,6 +15,12 @@ const config = { alias: { // Prevent resolution into vendor directories vendor: false, + // Force braintrust subpath imports to resolve to the workspace source, + // not the stale npm version pinned in integrations/browser-js/node_modules. + "braintrust/auto-instrumentation-configs": path.resolve( + __dirname, + "src/auto-instrumentations/index.ts", + ), }, }, server: { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3248ae958..8cdcde32e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -67,7 +67,7 @@ importers: version: 1.0.1 braintrust: specifier: '>=3.0.0-rc.29' - version: 3.0.0-rc.29(zod@4.2.1) + version: 3.4.0(zod@4.2.1) dc-browser: specifier: ^1.0.3 version: 1.0.3 @@ -379,6 +379,9 @@ importers: '@anthropic-ai/sdk': specifier: ^0.60.0 version: 0.60.0 + '@braintrust/browser': + specifier: workspace:* + version: link:../integrations/browser-js '@google/genai': specifier: ^1.25.0 version: 1.25.0(@modelcontextprotocol/sdk@1.18.0) @@ -3121,8 +3124,8 @@ packages: resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==} engines: {node: '>=8'} - braintrust@3.0.0-rc.29: - resolution: {integrity: sha512-MTY0hCsBlRZcpYUf+WYeQOFcKK6Wto9P71q5UktAhIna+Gr6ZDPfp7jKIl6Mv9O8cD+PKBYBvL7pPwNTIfLkeA==} + braintrust@3.4.0: + resolution: {integrity: sha512-LsyvraUPcW+EAiUd7N5iMePrHk4n0LJ3/S4DiBljj2pLsDSavic987RPStS9L6cJG6qXc6BKCwKaLQf/1JaPuQ==} hasBin: true peerDependencies: zod: ^3.25.34 || ^4.0 @@ -9171,17 +9174,20 @@ snapshots: dependencies: fill-range: 7.1.1 - braintrust@3.0.0-rc.29(zod@4.2.1): + braintrust@3.4.0(zod@4.2.1): dependencies: '@ai-sdk/provider': 1.1.3 + '@apm-js-collab/code-transformer': 0.9.0 '@next/env': 14.2.3 '@vercel/functions': 1.0.2 + ajv: 8.17.1 argparse: 2.0.1 boxen: 8.0.1 chalk: 4.1.2 cli-progress: 3.12.0 cli-table3: 0.6.5 cors: 2.8.5 + dc-browser: 1.0.3 dotenv: 16.4.5 esbuild: 0.27.0 eventsource-parser: 1.1.2 @@ -9189,11 +9195,13 @@ snapshots: graceful-fs: 4.2.11 http-errors: 2.0.0 minimatch: 9.0.5 + module-details-from-path: 1.0.4 mustache: 4.2.0 pluralize: 8.0.0 simple-git: 3.21.0 source-map: 0.7.6 termi-link: 1.1.0 + unplugin: 2.3.11 uuid: 9.0.1 zod: 4.2.1 zod-to-json-schema: 3.25.1(zod@4.2.1) From 6dd651bb329944c72afe97099df273efc725ee25 Mon Sep 17 00:00:00 2001 From: Stephen Belanger Date: Tue, 17 Mar 2026 23:39:58 +0800 Subject: [PATCH 5/5] fix: use vitest aliases for @braintrust/browser bundler plugins instead of workspace dep Adding @braintrust/browser as a devDep of braintrust created a circular dependency detected by Turborepo. Instead, alias the three bundler subpaths directly to their TypeScript source files in integrations/browser-js/src/bundler/ within vitest.config.js. Also alias braintrust/auto-instrumentation-configs to the workspace source to bypass the stale npm v3.0.0-rc.29 copy in integrations/browser-js/node_modules. Co-Authored-By: Claude Sonnet 4.6 --- js/package.json | 1 - js/vitest.config.js | 19 +++++++++++++++++-- pnpm-lock.yaml | 3 --- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/js/package.json b/js/package.json index 8ed770889..e1e1df430 100644 --- a/js/package.json +++ b/js/package.json @@ -153,7 +153,6 @@ "ai": "^6.0.0", "async": "^3.2.5", "autoevals": "^0.0.131", - "@braintrust/browser": "workspace:*", "cross-env": "^7.0.3", "dc-browser": "^1.0.3", "eslint-plugin-node-import": "^1.0.5", diff --git a/js/vitest.config.js b/js/vitest.config.js index cd4eb42cd..be94e109a 100644 --- a/js/vitest.config.js +++ b/js/vitest.config.js @@ -15,8 +15,23 @@ const config = { alias: { // Prevent resolution into vendor directories vendor: false, - // Force braintrust subpath imports to resolve to the workspace source, - // not the stale npm version pinned in integrations/browser-js/node_modules. + // Alias @braintrust/browser bundler subpaths to source files to avoid a + // circular workspace dependency (braintrust -> @braintrust/browser -> braintrust). + "@braintrust/browser/esbuild": path.resolve( + __dirname, + "../integrations/browser-js/src/bundler/esbuild.ts", + ), + "@braintrust/browser/vite": path.resolve( + __dirname, + "../integrations/browser-js/src/bundler/vite.ts", + ), + "@braintrust/browser/rollup": path.resolve( + __dirname, + "../integrations/browser-js/src/bundler/rollup.ts", + ), + // Redirect braintrust subpath import used by the browser bundler plugin to the + // workspace source, bypassing the stale npm v3.0.0-rc.29 copy in + // integrations/browser-js/node_modules (which predates this export). "braintrust/auto-instrumentation-configs": path.resolve( __dirname, "src/auto-instrumentations/index.ts", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8cdcde32e..f46f756dc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -379,9 +379,6 @@ importers: '@anthropic-ai/sdk': specifier: ^0.60.0 version: 0.60.0 - '@braintrust/browser': - specifier: workspace:* - version: link:../integrations/browser-js '@google/genai': specifier: ^1.25.0 version: 1.25.0(@modelcontextprotocol/sdk@1.18.0)