diff --git a/.changeset/chilly-sites-greet.md b/.changeset/chilly-sites-greet.md new file mode 100644 index 000000000..0b766015b --- /dev/null +++ b/.changeset/chilly-sites-greet.md @@ -0,0 +1,5 @@ +--- +"braintrust": patch +--- + +fix(auto-instrumentation): Skip over file transforms in bundler plugins when id is undefined diff --git a/js/src/auto-instrumentations/bundler/plugin.ts b/js/src/auto-instrumentations/bundler/plugin.ts index 508bb8ae3..b9097da99 100644 --- a/js/src/auto-instrumentations/bundler/plugin.ts +++ b/js/src/auto-instrumentations/bundler/plugin.ts @@ -94,6 +94,11 @@ export const unplugin = createUnplugin((options = {}) => { name: "code-transformer", enforce: "pre", transform(code: string, id: string) { + if (!id) { + // Some modules apparently don't have an id? + return null; + } + // Convert file:// URLs to regular paths at entry point // Node.js ESM loader hooks provide file:// URLs, but downstream code expects paths const filePath = id.startsWith("file:") ? fileURLToPath(id) : id;