Skip to content

Commit

Permalink
feat(js): Fix ESM builds (#1163)
Browse files Browse the repository at this point in the history
Co-authored-by: Mikyo King <[email protected]>
  • Loading branch information
cephalization and mikeldking authored Dec 12, 2024
1 parent 0cef233 commit 16a3815
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 12 deletions.
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",
"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";
11 changes: 9 additions & 2 deletions js/packages/openinference-instrumentation-langchain/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"
}
},
"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
9 changes: 8 additions & 1 deletion js/packages/openinference-semantic-conventions/package.json
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
}
}

0 comments on commit 16a3815

Please sign in to comment.