-
Notifications
You must be signed in to change notification settings - Fork 39
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
[feature request] Proper packaging for JS ESM builds #1144
Comments
@mshick thanks for catching this! We'll get it sorted. Thanks again! |
After investigation we will additionally need to upgrade typescript to 5.7 and use this flag https://devblogs.microsoft.com/typescript/announcing-typescript-5-7/#path-rewriting-for-relative-paths Otherwise nodejs will not be able to resolve our emitted imports in esm mode, as they do not include file extensions. |
https://github.com/justkey007/tsc-alias as a possible solution |
Packaging ESM using only TSC (no bundler) has long been a real pain in the butt. I tried a few tool-based solutions, but found that just adding |
I've got a PoC implemented following your suggestions w.r.t package.json, while fixing the file extension issues with I agree the file extension issue is interesting but makes some sense when you dive into the ESM specification 😅 Will bump when we've got something merged, thanks again for the shout! |
@mshick ESM builds are now properly packaged and shipped for all openinference packages. Let us know if you see any issues using ESM. So far it is known that auto-instrumentation does not work due to differences in opentelemetry when using cjs vs esm but we will look into this in the future. Manual instrumentation works as normal |
Nice, thanks for heads up. Just took a peek at the updated packages and they look good. |
Is your feature request related to a problem? Please describe.
When looking at the
dist
code on npm for@arizeai/openinference-vercel
and the various other@arizeai/*
packages, I noticed theesm
builds appear incorrect. The builds are using extension-less ESM-style imports and exports, e.g.,export { isOpenInferenceSpan } from "./utils";
, and they do not declare"type": "module"
. in thepackage.json
file. These modules won't work in a true ESM environment, and importing the package from a.mjs
file, relies on thecjs
build atdist/src
.Most users are probably importing into a TS environment with a bundler, and the only thing they'd miss out on here is tree shaking, but the fix is relatively simple so you might be interested in updating your boilerplate to do the following:
import { foo } from './util'
->import { foo } from './util.js'
dist/esm
folder has a package.json with{ "type": "module" }
. An npm script like this would do the trick:package.json
, e.g.,:Another nit,
@opentelemetry/sdk-trace-base
seems to be required for@arizeai/openinference-vercel
, but it is only listed as adevDependency
.I'd be happy to open a PR if you're interested.
The text was updated successfully, but these errors were encountered: