Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions js/.changeset/dry-cities-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@arizeai/openinference-genai": patch
---

feat: Add commonjs builds to openinference-genai
19 changes: 12 additions & 7 deletions js/packages/openinference-genai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,33 @@
"name": "@arizeai/openinference-genai",
"version": "0.1.0",
"private": false,
"type": "module",
"types": "dist/esm/index.d.ts",
"main": "dist/src/index.js",
"module": "dist/esm/index.js",
"types": "dist/src/index.d.ts",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Main and types fields point to non-existent paths

The main and types fields point to dist/src/index.js and dist/src/index.d.ts, but the build script only generates output to dist/commonjs/ and dist/esm/ directories. The tsconfig.commonjs.json has outDir: "dist/commonjs" with rootDir: "src", so files compile to dist/commonjs/index.js. The dist/src/ directory will never be created, causing Node.js to fail to resolve the package when these fallback fields are used.

Fix in Cursor Fix in Web

"description": "OpenInference utilities for converting OpenTelemetry GenAI span attributes to OpenInference span attributes",
"scripts": {
"prebuild": "rimraf dist",
"build": "tsc --build tsconfig.esm.json && tsc-alias -p tsconfig.esm.json",
"build": "tsc --build tsconfig.commonjs.json tsconfig.esm.json && tsc-alias -p tsconfig.esm.json",
"postbuild": "echo '{\"type\": \"module\"}' > ./dist/esm/package.json && rimraf dist/test dist/examples",
"type:check": "tsc --noEmit",
"test": "vitest"
},
"exports": {
".": {
"import": "./dist/esm/index.js"
"import": "./dist/esm/index.js",
"require": "./dist/commonjs/index.js"
},
"./attributes": {
"import": "./dist/esm/attributes.js"
"import": "./dist/esm/attributes.js",
"require": "./dist/commonjs/attributes.js"
},
"./utils": {
"import": "./dist/esm/utils.js"
"import": "./dist/esm/utils.js",
"require": "./dist/commonjs/utils.js"
},
"./types": {
"types": "./dist/esm/types.d.ts"
"types": "./dist/esm/types.d.ts",
"require": "./dist/commonjs/types.d.ts"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Require condition points to type definition file instead of JavaScript

The require condition for the ./types export points to ./dist/commonjs/types.d.ts, which is a TypeScript declaration file, not executable JavaScript. When CommonJS consumers use require("@arizeai/openinference-genai/types"), Node.js will attempt to load the .d.ts file as JavaScript and fail. The require condition needs to point to a .js file (e.g., ./dist/commonjs/types.js).

Fix in Cursor Fix in Web

}
},
"files": [
Expand Down
13 changes: 13 additions & 0 deletions js/packages/openinference-genai/tsconfig.commonjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "dist/commonjs",
"rootDir": "src",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"tsBuildInfoFile": "dist/commonjs/tsconfig.commonjs.tsbuildinfo",
"noEmit": false
},
"include": ["src/**/*.ts"],
"references": []
}
7 changes: 4 additions & 3 deletions js/packages/openinference-genai/tsconfig.esm.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"compilerOptions": {
"outDir": "dist/esm",
"rootDir": "src",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"tsBuildInfoFile": "dist/esm/tsconfig.esm.tsbuildinfo"
"module": "preserve",
"moduleResolution": "bundler",
"tsBuildInfoFile": "dist/esm/tsconfig.esm.tsbuildinfo",
"noEmit": false
},
"include": ["src/**/*.ts"],
"references": []
Expand Down
11 changes: 6 additions & 5 deletions js/packages/openinference-genai/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"extends": "../../tsconfig.base.esm.json",
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "dist",
"rootDir": ".",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"module": "preserve",
"moduleResolution": "bundler",
"types": ["vitest/globals"],
"lib": ["ESNext"],
"resolveJsonModule": true,
"strictNullChecks": true,
"noUncheckedIndexedAccess": true
"noUncheckedIndexedAccess": true,
"noEmit": true,
"tsBuildInfoFile": "dist/tsconfig.tsbuildinfo"
},
"files": [],
"include": [
Expand Down
Loading