Skip to content

SSR Error When Compiling with Server Side Vite #114

@mwood23

Description

@mwood23

I'm getting this error when trying to consume @pipecat-ai/client-js

Error in renderToPipeableStream: SyntaxError: [vite] Named export 'LogLevel' not found. The requested module '@pipecat-ai/client-js' is a CommonJS module, which may not
 support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from '@pipecat-ai/client-js';
const {RTVIClient, LLMHelper, LogLevel} = pkg;

I'm not sure if CJS is preferred for some reason or not, but using "type": "module" in the package.json would fix it. If CJS is needed for some reason, can export maps be added? This fixes it for me:

diff --git a/package.json b/package.json
index 75195d82731f2baae100c293c071f5e0937d215d..3131e614de8f635259e7f50554e6c7f2b2063632 100644
--- a/package.json
+++ b/package.json
@@ -10,6 +10,10 @@
     "type": "git",
     "url": "git+https://github.com/pipecat-ai/pipecat-client-web.git"
   },
+  "exports": {
+    ".": {
+      "types": "./dist/index.d.ts",
+      "import": "./dist/index.module.js",
+      "require": "./dist/index.js"
+    }
+  },
   "files": [
     "dist",
     "package.json",

Note: you will also need to do this for client-react, daily-transport, and any other module published.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions