Conversation
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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.
🤨 -- 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", |
There was a problem hiding this comment.
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 |
|
I wonder if only adding the |
@jptaylor @Regaddi -- Per #114 -- Is there any reason NOT to do this?