-
Notifications
You must be signed in to change notification settings - Fork 56
Transition to official module support #166
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR transitions the @pipecat-ai/client-js package to official ES module support by adding "type": "module" to package.json and removing the separate "module" field. This simplifies the package configuration by committing fully to ES modules rather than providing dual CommonJS/ESM outputs.
- Adds
"type": "module"to mark the package as using ES modules - Removes the
"module"field that previously pointed todist/index.module.js - Retains only the
"main"field pointing todist/index.jsfor the single ESM output
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "name": "@pipecat-ai/client-js", | ||
| "version": "1.5.0", | ||
| "license": "BSD-2-Clause", | ||
| "type": "module", |
Copilot
AI
Dec 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding "type": "module" to package.json requires Jest/ts-jest ESM configuration. The current Jest configuration uses "preset": "ts-jest" without ESM-specific settings. When "type": "module" is set, ts-jest needs to use the "ts-jest/presets/default-esm" preset instead, and additional configuration is needed:
- Change the preset to "ts-jest/presets/default-esm"
- Add "extensionsToTreatAsEsm": [".ts"]
- Add "moduleNameMapper" with "^(\.{1,2}/.*)\.js$": "$1" to handle .js imports from .ts files
Without these changes, tests may fail when running with the ESM module type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤨 -- and yet, they ran and passed without these changes. of course, we don't have many so... 🤔
| "type": "module", | ||
| "main": "dist/index.js", | ||
| "module": "dist/index.module.js", | ||
| "types": "dist/index.d.ts", |
Copilot
AI
Dec 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing the "module" field while adding "type": "module" changes the package's export strategy. Consider adding an "exports" field to provide explicit entry points for modern Node.js and bundlers. This is the current best practice for ES modules:
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
}This provides better control over how the package is consumed and prevents deep imports. Note that client-react still uses the dual "main"/"module" approach, so this change creates inconsistency between the two packages in this monorepo.
| "types": "dist/index.d.ts", | |
| "types": "dist/index.d.ts", | |
| "exports": { | |
| ".": { | |
| "types": "./dist/index.d.ts", | |
| "default": "./dist/index.js" | |
| } | |
| }, |
|
blech. reading up more on this. The format we've gone with seems to be the preferred way by parcel -- it mentions that you can use |
@jptaylor @Regaddi -- Per #114 -- Is there any reason NOT to do this?