Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(js): Fix ESM builds #1163

Merged
Merged
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
15 changes: 15 additions & 0 deletions js/.changeset/smart-donuts-attack.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
"@arizeai/openinference-instrumentation-langchain": major
"@arizeai/openinference-instrumentation-openai": major
"@arizeai/openinference-semantic-conventions": major
"@arizeai/openinference-vercel": major
"@arizeai/openinference-core": major
---

ESM support

Packages are now shipped as "Dual Package" meaning that ESM and CJS module resolution
should be supported for each package.

Support is described as "experimental" because opentelemetry describes support for autoinstrumenting
ESM projects as "ongoing". See https://github.com/open-telemetry/opentelemetry-js/blob/61d5a0e291db26c2af638274947081b29db3f0ca/doc/esm-support.md
1 change: 1 addition & 0 deletions js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"prettier": "^3.3.3",
"rimraf": "^5.0.9",
"ts-jest": "^29.2.2",
"tsc-alias": "^1.8.10",
"typescript": "^5.5.4"
},
"engines": {
Expand Down
13 changes: 10 additions & 3 deletions js/packages/openinference-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@
"description": "OpenInference Core provides utilities shared by all OpenInference SDK packages.",
"scripts": {
"prebuild": "rimraf dist",
"build": "tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
"build": "tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json && tsc-alias -p tsconfig.esm.json",
"postbuild": "echo '{\"type\": \"module\"}' > ./dist/esm/package.json; rimraf dist/test",
cephalization marked this conversation as resolved.
Show resolved Hide resolved
"type:check": "tsc --noEmit",
"test": "jest"
},
"exports": {
".": {
"import": "./dist/esm/index.js",
"require": "./dist/src/index.js"
}
},
"files": [
"dist",
"src"
Expand All @@ -34,8 +41,8 @@
},
"dependencies": {
"@arizeai/openinference-semantic-conventions": "workspace:*",
"@opentelemetry/core": "^1.25.1",
"@opentelemetry/api": "^1.9.0"
"@opentelemetry/api": "^1.9.0",
"@opentelemetry/core": "^1.25.1"
},
"devDependencies": {
"@opentelemetry/context-async-hooks": "^1.25.1",
Expand Down
1 change: 1 addition & 0 deletions js/packages/openinference-core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from "./trace";
export * from "./utils";
export type * from "./utils/types";
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,19 @@
"url": "https://github.com/Arize-ai/openinference.git"
},
"scripts": {
"prebuild": "rimraf dist & pnpm run version:update",
"build": "tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
"prebuild": "rimraf dist && pnpm run version:update",
"build": "tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json && tsc-alias -p tsconfig.esm.json",
"postbuild": "echo '{\"type\": \"module\"}' > ./dist/esm/package.json && rimraf dist/test",
cephalization marked this conversation as resolved.
Show resolved Hide resolved
"version:update": "../../scripts/version-update.js",
"type:check": "tsc --noEmit",
"test": "jest"
},
"exports": {
".": {
"import": "./dist/esm/index.js",
"require": "./dist/src/index.js"
}
},
"keywords": [],
"files": [
"dist",
Expand Down
11 changes: 9 additions & 2 deletions js/packages/openinference-instrumentation-openai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,19 @@
"url": "https://github.com/Arize-ai/openinference.git"
},
"scripts": {
"prebuild": "rimraf dist & pnpm run version:update",
"build": "tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
"prebuild": "rimraf dist && pnpm run version:update",
"build": "tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json && tsc-alias -p tsconfig.esm.json",
"postbuild": "echo '{\"type\": \"module\"}' > ./dist/esm/package.json && rimraf dist/test",
"version:update": "../../scripts/version-update.js",
"type:check": "tsc --noEmit",
"test": "jest ."
},
"exports": {
".": {
"import": "./dist/esm/index.js",
"require": "./dist/src/index.js"
}
},
"dependencies": {
"@arizeai/openinference-core": "workspace:*",
"@arizeai/openinference-semantic-conventions": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@
"description": "This package provides OpenInference semantic conventions for tracing of LLM Applications.",
"scripts": {
"prebuild": "rimraf dist",
"build": "tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
"build": "tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json && tsc-alias -p tsconfig.esm.json",
"postbuild": "echo '{\"type\": \"module\"}' > ./dist/esm/package.json && rimraf dist/test",
"type:check": "tsc --noEmit",
"test": "echo \"NOOP: semantic conventions has no tests\" && exit 0"
},
"exports": {
".": {
"import": "./dist/esm/index.js",
"require": "./dist/src/index.js"
}
},
"files": [
"dist",
"src"
Expand Down
9 changes: 8 additions & 1 deletion js/packages/openinference-vercel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@
"description": "OpenInference utilities for ingesting Vercel AI SDK spans",
"scripts": {
"prebuild": "rimraf dist",
"build": "tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json",
"build": "tsc --build tsconfig.json tsconfig.esm.json tsconfig.esnext.json && tsc-alias -p tsconfig.esm.json",
"postbuild": "echo '{\"type\": \"module\"}' > ./dist/esm/package.json && rimraf dist/test",
"type:check": "tsc --noEmit",
"test": "jest"
},
"exports": {
".": {
"import": "./dist/esm/index.js",
"require": "./dist/src/index.js"
}
},
"files": [
"dist",
"src"
Expand Down
74 changes: 74 additions & 0 deletions js/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions js/tsconfig.base.esm.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
{
"extends": "./tsconfig.base.es5.json",
"extends": "./tsconfig.base.esnext.json",
"compilerOptions": {
"module": "ES6",
"moduleResolution": "node"
"target": "ES2020",
"moduleResolution": "node10",
"module": "ES2020"
},
"tsc-alias": {
"verbose": false,
"resolveFullPaths": true
}
}
Loading